ext/lib/crypto/tinycrypt/source/ecc.c
/*
 * Elliptic curve point doubling in Jacobi coordinates: P = P + P.
 *
 * Requires 4 squares and 4 multiplications.
 */
Elliptic curve point doubling in Jacobi coordinates: P = P + P.
Requires 4 squares and 4 multiplications.
Elliptic curve point doubling in Jacobi coordinates : P = P + P . Requires 4 squares and 4 multiplications .
static void EccPoint_double(EccPointJacobi *P)
{
	uint32_t m[NUM_ECC_DIGITS], s[NUM_ECC_DIGITS], t[NUM_ECC_DIGITS];
	vli_modSquare_fast(t, P->Z);
	vli_modSub(m, P->X, t, curve_p);
	vli_modAdd(s, P->X, t, curve_p);
	vli_modMult_fast(m, m, s);
	vli_modAdd(s, m, m, curve_p);
	vli_modAdd(m, s, m, curve_p); 
	vli_modSquare_fast(t, P->Y);
	vli_modMult_fast(s, P->X, t);
	vli_modAdd(s, s, s, curve_p);
	vli_modAdd(s, s, s, curve_p); 
	vli_modMult_fast(P->Z, P->Y, P->Z);
	vli_modAdd(P->Z, P->Z, P->Z, curve_p); 
	vli_modSquare_fast(P->X, m);
	vli_modSub(P->X, P->X, s, curve_p);
	vli_modSub(P->X, P->X, s, curve_p); 
	vli_modSquare_fast(P->Y, t);
	vli_modAdd(P->Y, P->Y, P->Y, curve_p);
	vli_modAdd(P->Y, P->Y, P->Y, curve_p);
	vli_modAdd(P->Y, P->Y, P->Y, curve_p);
	vli_modSub(t, s, P->X, curve_p);
	vli_modMult_fast(t, t, m);
	vli_modSub(P->Y, t, P->Y, curve_p); 
}
static void EccPoint_double ( EccPointJacobi * P ) { uint32_t m [ NUM_ECC_DIGITS ] , s [ NUM_ECC_DIGITS ] , t [ NUM_ECC_DIGITS ] ; vli_modSquare_fast ( t , P -> Z ) ; vli_modSub ( m , P -> X , t , curve_p ) ; vli_modAdd ( s , P -> X , t , curve_p ) ; vli_modMult_fast ( m , m , s ) ; vli_modAdd ( s , m , m , curve_p ) ; vli_modAdd ( m , s , m , curve_p ) ; vli_modSquare_fast ( t , P -> Y ) ; vli_modMult_fast ( s , P -> X , t ) ; vli_modAdd ( s , s , s , curve_p ) ; vli_modAdd ( s , s , s , curve_p ) ; vli_modMult_fast ( P -> Z , P -> Y , P -> Z ) ; vli_modAdd ( P -> Z , P -> Z , P -> Z , curve_p ) ; vli_modSquare_fast ( P -> X , m ) ; vli_modSub ( P -> X , P -> X , s , curve_p ) ; vli_modSub ( P -> X , P -> X , s , curve_p ) ; vli_modSquare_fast ( P -> Y , t ) ; vli_modAdd ( P -> Y , P -> Y , P -> Y , curve_p ) ; vli_modAdd ( P -> Y , P -> Y , P -> Y , curve_p ) ; vli_modAdd ( P -> Y , P -> Y , P -> Y , curve_p ) ; vli_modSub ( t , s , P -> X , curve_p ) ; vli_modMult_fast ( t , t , m ) ; vli_modSub ( P -> Y , t , P -> Y , curve_p ) ; }
Elliptic curve point doubling in Jacobi coordinates: P = P + P.
 Requires 4 squares and 4 multiplications.
Elliptic curve point doubling in Jacobi coordinates : P = P + P . Requires 4 squares and 4 multiplications .
/* m = 3X^2 - 3Z^4 */ /* s = 4XY^2 */ /* Z' = 2YZ */ /* X' = m^2 - 2s */ /* Y' = m(s - X') - 8Y^4 */