7#ifndef SECP256K1_FIELD_IMPL_H
8#define SECP256K1_FIELD_IMPL_H
10#if defined HAVE_CONFIG_H
16#if defined(SECP256K1_WIDEMUL_INT128)
18#elif defined(SECP256K1_WIDEMUL_INT64)
21#error "Please select wide multiplication implementation"
26 secp256k1_fe_negate(&na,
a, 1);
27 secp256k1_fe_add(&na, b);
28 return secp256k1_fe_normalizes_to_zero(&na);
33 secp256k1_fe_negate(&na,
a, 1);
34 secp256k1_fe_add(&na, b);
35 return secp256k1_fe_normalizes_to_zero_var(&na);
48 secp256k1_fe x2, x3, x6, x9, x11, x22, x44, x88, x176, x220, x223, t1;
58 secp256k1_fe_sqr(&x2,
a);
59 secp256k1_fe_mul(&x2, &x2,
a);
61 secp256k1_fe_sqr(&x3, &x2);
62 secp256k1_fe_mul(&x3, &x3,
a);
66 secp256k1_fe_sqr(&x6, &x6);
68 secp256k1_fe_mul(&x6, &x6, &x3);
72 secp256k1_fe_sqr(&x9, &x9);
74 secp256k1_fe_mul(&x9, &x9, &x3);
78 secp256k1_fe_sqr(&x11, &x11);
80 secp256k1_fe_mul(&x11, &x11, &x2);
83 for (
j=0;
j<11;
j++) {
84 secp256k1_fe_sqr(&x22, &x22);
86 secp256k1_fe_mul(&x22, &x22, &x11);
89 for (
j=0;
j<22;
j++) {
90 secp256k1_fe_sqr(&x44, &x44);
92 secp256k1_fe_mul(&x44, &x44, &x22);
95 for (
j=0;
j<44;
j++) {
96 secp256k1_fe_sqr(&x88, &x88);
98 secp256k1_fe_mul(&x88, &x88, &x44);
101 for (
j=0;
j<88;
j++) {
102 secp256k1_fe_sqr(&x176, &x176);
104 secp256k1_fe_mul(&x176, &x176, &x88);
107 for (
j=0;
j<44;
j++) {
108 secp256k1_fe_sqr(&x220, &x220);
110 secp256k1_fe_mul(&x220, &x220, &x44);
113 for (
j=0;
j<3;
j++) {
114 secp256k1_fe_sqr(&x223, &x223);
116 secp256k1_fe_mul(&x223, &x223, &x3);
121 for (
j=0;
j<23;
j++) {
122 secp256k1_fe_sqr(&t1, &t1);
124 secp256k1_fe_mul(&t1, &t1, &x22);
125 for (
j=0;
j<6;
j++) {
126 secp256k1_fe_sqr(&t1, &t1);
128 secp256k1_fe_mul(&t1, &t1, &x2);
129 secp256k1_fe_sqr(&t1, &t1);
130 secp256k1_fe_sqr(
r, &t1);
134 secp256k1_fe_sqr(&t1,
r);
135 return secp256k1_fe_equal(&t1,
a);
#define VERIFY_CHECK(cond)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a