ta/wallet_ta.c
/**
  * Subtract (r = op1 - op2) two multi-precision numbers of arbitrary size,
  * ignoring the current prime finite field. In other words, this does
  * multi-precision binary subtraction. It is to be used
  * internally (only by the functions of the TA itself).
  * \param r The result will be written into here.
  * \param op1 The operand to subtract from. This may alias r.
  * \param op2 The operand to subtract off op1. This may alias r or op1.
  * \param op_size Size, in bytes, of the operands and the result.
  * \return 1 if borrow occurred, 0 if no borrow occurred.
  */
Subtract (r = op1 - op2) two multi-precision numbers of arbitrary size,
ignoring the current prime finite field. In other words, this does
multi-precision binary subtraction. It is to be used
internally (only by the functions of the TA itself).
\param r The result will be written into here.
\param op1 The operand to subtract from. This may alias r.
\param op2 The operand to subtract off op1. This may alias r or op1.
\param op_size Size, in bytes, of the operands and the result.
\return 1 if borrow occurred, 0 if no borrow occurred.
Subtract ( r = op1 - op2 ) two multi - precision numbers of arbitrary size ignoring the current prime finite field . In other words this does multi - precision binary subtraction . It is to be used internally ( only by the functions of the TA itself ) . \ param r The result will be written into here . \ param op1 The operand to subtract from . This may alias r . \ param op2 The operand to subtract off op1 . This may alias r or op1 . \ param op_size Size in bytes of the operands and the result . \ return 1 if borrow occurred 0 if no borrow occurred .
static uint8_t big_subtract_variable_size_no_modulo_internal(uint8_t *r, uint8_t *op1, uint8_t *op2, uint8_t op_size)
{
	uint16_t partial;
	uint8_t borrow;
	uint8_t i;
	borrow = 0;
	for (i = 0; i < op_size; i++)
	{
		partial = (uint16_t)((uint16_t)op1[i] - (uint16_t)op2[i] - (uint16_t)borrow);
		r[i] = (uint8_t)partial;
		borrow = (uint8_t)((uint8_t)(partial >> 8) & 1);
	}
	return borrow;
}
static uint8_t big_subtract_variable_size_no_modulo_internal ( uint8_t * r , uint8_t * op1 , uint8_t * op2 , uint8_t op_size ) { uint16_t partial ; uint8_t borrow ; uint8_t i ; borrow = 0 ; for ( i = 0 ; i < op_size ; i ++ ) { partial = ( uint16_t ) ( ( uint16_t ) op1 [ i ] - ( uint16_t ) op2 [ i ] - ( uint16_t ) borrow ) ; r [ i ] = ( uint8_t ) partial ; borrow = ( uint8_t ) ( ( uint8_t ) ( partial >> 8 ) & 1 ) ; } return borrow ; }
Subtract (r = op1 - op2) two multi-precision numbers of arbitrary size,
 ignoring the current prime finite field.
Subtract ( r = op1 - op2 ) two multi - precision numbers of arbitrary size ignoring the current prime finite field .