Skip to main content

hmac_sha512_fixed

Function hmac_sha512_fixed 

Source
pub fn hmac_sha512_fixed(
    builder: &mut CircuitBuilder,
    key: &[Wire],
    message: &[Wire],
    message_len_bytes: usize,
) -> [Wire; 8]
Expand description

Computes HMAC-SHA512 on a fixed-length message with a given key.

Implements the HMAC construction: H((K ⊕ opad) || H((K ⊕ ipad) || M)) where H is SHA-512, and ipad/opad are the inner and outer padding constants.

§Arguments

  • builder - The circuit builder to add constraints to
  • key - The secret key as wires (words in big-endian format)
  • message - The message to authenticate as wires (words in big-endian format)
  • message_len_bytes - The actual message length in bytes

§Returns

  • Array of 8 wires containing the 512-bit HMAC output

§Preconditions

  • Key length must be at most 128 bytes (SHA-512 block size): key.len() <= 16
  • Message length must match wire count: message.len() == message_len_bytes.div_ceil(8)