ta/wallet_ta.c
/**
  * Compute op1 modulo #n, where op1 is a 32 byte multi-precision number.
  * The "modulo" part makes it sound like this function does division
  * somewhere, but since #n is also a 32 byte multi-precision number, all
  * this function actually does is subtract #n off op1 if op1 is >= #n. It is
  * to be used internally (only by the functions of the TA itself).
  * \param session_data A data pointer to a session context.
  * \param r The 32 byte result will be written into here.
  * \param op1 The 32 byte operand to apply the modulo to. This may alias r.
  */
Compute op1 modulo #n, where op1 is a 32 byte multi-precision number.
The "modulo" part makes it sound like this function does division
somewhere, but since #n is also a 32 byte multi-precision number, all
this function actually does is subtract #n off op1 if op1 is >= #n. It is
to be used internally (only by the functions of the TA itself).
\param session_data A data pointer to a session context.
\param r The 32 byte result will be written into here.
\param op1 The 32 byte operand to apply the modulo to. This may alias r.
Compute op1 modulo #n where op1 is a 32 byte multi - precision number . The " modulo " part makes it sound like this function does division somewhere but since #n is also a 32 byte multi - precision number all this function actually does is subtract #n off op1 if op1 is > = #n . It is to be used internally ( only by the functions of the TA itself ) . \ param session_data A data pointer to a session context . \ param r The 32 byte result will be written into here . \ param op1 The 32 byte operand to apply the modulo to . This may alias r .
static void big_modulo_internal(Session_data * session_data, BigNum256 r, BigNum256 op1)
{
	uint8_t cmp;
	uint8_t *lookup[2];
	uint8_t zero[32];
	big_set_zero_internal(zero);
	cmp = (uint8_t)(big_compare_internal(op1, session_data->n) ^ BIGCMP_LESS);
	cmp = (uint8_t)((((uint16_t)(-(int)cmp)) >> 8) + 1);
	lookup[0] = session_data->n;
	lookup[1] = zero;
	big_subtract_no_modulo_internal(r, op1, lookup[cmp]);
}
static void big_modulo_internal ( Session_data * session_data , BigNum256 r , BigNum256 op1 ) { uint8_t cmp ; uint8_t * lookup [ 2 ] ; uint8_t zero [ 32 ] ; big_set_zero_internal ( zero ) ; cmp = ( uint8_t ) ( big_compare_internal ( op1 , session_data -> n ) ^ BIGCMP_LESS ) ; cmp = ( uint8_t ) ( ( ( ( uint16_t ) ( - ( int ) cmp ) ) >> 8 ) + 1 ) ; lookup [ 0 ] = session_data -> n ; lookup [ 1 ] = zero ; big_subtract_no_modulo_internal ( r , op1 , lookup [ cmp ] ) ; }
Compute op1 modulo #n, where op1 is a 32 byte multi-precision number.
Compute op1 modulo #n where op1 is a 32 byte multi - precision number .
/*
	 * The following 2 lines do:
	 * cmp = "bigCompare(op1, n) == BIGCMP_LESS ? 1 : 0".
	 */