Skip to main content

hook_rsa_mul_mod

Function hook_rsa_mul_mod 

Source
pub fn hook_rsa_mul_mod(buf: &[u8]) -> Result<Vec<u8>, ExitCode>
Expand description

Given the product of some 256-byte numbers and a modulus, this function does a modular reduction and hints back the values to the vm in order to constrain it.

ยงArguments

  • env - The environment in which the hook is invoked.
  • buf - The buffer containing the le bytes of the 512 byte product and the 256 byte modulus.

Returns The le bytes of the product % modulus (512 bytes) and the quotient floor(product/modulus) (256 bytes).

WANRING: This function is used to perform a modular reduction outside of the zkVM context. These values must be constrained by the zkVM for correctness.