Skip to main content

ct_add_mod_mp_mp

Function ct_add_mod_mp_mp 

Source
pub fn ct_add_mod_mp_mp<T0: MpMutUInt, T1: MpUIntCommon, NT: MpUIntCommon>(
    op0: &mut T0,
    op1: &T1,
    n: &NT,
) -> Result<(), CtAddModMpMpError>
Expand description

Add two multiprecision integers modulo a third one.

The multiprecision integers may be of different representations.

Replace op0 by the sum of op0 and op1 modulo n. Both operands must be less than n on input, and so is the result.

Execution time depends only on the multiprecision integers’ lengths in units of bytes and is otherwise constant as far as branching is concerned. If n’s length exceeds op0’s, the length check additionally depends on the value of n’s excess high bytes, c.f. MpUIntCommon::len_is_compatible_with(). See ct_add_mp_mp() for plain, non-modular addition.

§Arguments

  • op0 - The first addend. Must be less than n. It will be overwritten by the resulting sum modulo n.
  • op1 - The second addend. Must be less than n. Its length in units of bytes isn’t restricted otherwise.
  • n - The modulus. Must be non-zero. Its length in units of bytes must fit into op0’s.

§Errors

Returns CtAddModMpMpError::InconsistentOperandLengths if n’s length doesn’t fit into op0’s.