ta/wallet_ta.c
/**
  * Add (r = (op1 + op2) modulo #n) two 32 byte multi-precision numbers under
  * the current prime finite field. 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 first 32 byte operand to add. This may alias r.
  * \param op2 The second 32 byte operand to add. This may alias r or op1.
  * \warning op1 and op2 must both be < #n.
  */
Add (r = (op1 + op2) modulo #n) two 32 byte multi-precision numbers under
the current prime finite field. 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 first 32 byte operand to add. This may alias r.
\param op2 The second 32 byte operand to add. This may alias r or op1.
\warning op1 and op2 must both be < #n.
Add ( r = ( op1 + op2 ) modulo #n ) two 32 byte multi - precision numbers under the current prime finite field . 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 first 32 byte operand to add . This may alias r . \ param op2 The second 32 byte operand to add . This may alias r or op1 . \ warning op1 and op2 must both be < #n .
static void big_add_internal(Session_data * session_data, BigNum256 r, BigNum256 op1, BigNum256 op2)
{
	uint8_t too_big;
	uint8_t cmp;
	uint8_t *lookup[2];
	uint8_t zero[32];
	big_set_zero_internal(zero);
	too_big = big_add_variable_size_no_modulo_internal(r, op1, op2, 32);
	cmp = (uint8_t)(big_compare_internal(r, session_data->n) ^ BIGCMP_LESS);
	cmp = (uint8_t)((((uint16_t)(-(int)cmp)) >> 8) & 1);
	too_big |= cmp;
	lookup[0] = zero;
	lookup[1] = session_data->n;
	big_subtract_no_modulo_internal(r, r, lookup[too_big]);
}
static void big_add_internal ( Session_data * session_data , BigNum256 r , BigNum256 op1 , BigNum256 op2 ) { uint8_t too_big ; uint8_t cmp ; uint8_t * lookup [ 2 ] ; uint8_t zero [ 32 ] ; big_set_zero_internal ( zero ) ; too_big = big_add_variable_size_no_modulo_internal ( r , op1 , op2 , 32 ) ; cmp = ( uint8_t ) ( big_compare_internal ( r , session_data -> n ) ^ BIGCMP_LESS ) ; cmp = ( uint8_t ) ( ( ( ( uint16_t ) ( - ( int ) cmp ) ) >> 8 ) & 1 ) ; too_big |= cmp ; lookup [ 0 ] = zero ; lookup [ 1 ] = session_data -> n ; big_subtract_no_modulo_internal ( r , r , lookup [ too_big ] ) ; }
Add (r = (op1 + op2) modulo #n) two 32 byte multi-precision numbers under
 the current prime finite field.
Add ( r = ( op1 + op2 ) modulo #n ) two 32 byte multi - precision numbers under the current prime finite field .
/*
	assert(big_compare_internal(op1, n) == BIGCMP_LESS);
	assert(big_compare_internal(op2, n) == BIGCMP_LESS);
	*/