@@ -111,10 +111,20 @@ static void shallue_van_de_woestijne(secp256k1_ge* ge, const secp256k1_fe* t) {
111
111
wd = 1 + b + t^2
112
112
x3d = c^2 * t^2 = -3 * t^2
113
113
114
- so that
114
+ so that if j != 0, then
115
115
116
116
1 / wd = 1/j * x3d
117
117
1 / x3d = 1/j * wd
118
+
119
+ x1 = d - c * t^2 * x3d / j
120
+ x3 = 1 + wd^3 / j
121
+
122
+ If j = 0, the function outputs the point (d, f(d)). This point is equal
123
+ to (x1, f(x1)) as defined above if division by 0 is defined to be 0. In
124
+ below code this is not special-cased because secp256k1_fe_inv returns 0
125
+ on input 0.
126
+
127
+ j = 0 happens only when t = 0 (since wd != 0 as -8 is not a square).
118
128
*/
119
129
120
130
static const secp256k1_fe negc = SECP256K1_FE_CONST (0xf5d2d456 , 0xcaf80e20 , 0xdcc88f3d , 0x586869d3 , 0x39e092ea , 0x25eb132b , 0x8272d850 , 0xe32a03dd );
@@ -123,23 +133,41 @@ static void shallue_van_de_woestijne(secp256k1_ge* ge, const secp256k1_fe* t) {
123
133
secp256k1_fe wd , x3d , jinv , tmp , x1 , x2 , x3 , alphain , betain , gammain , y1 , y2 , y3 ;
124
134
int alphaquad , betaquad ;
125
135
136
+ /* wd = t^2 */
126
137
secp256k1_fe_sqr (& wd , t ); /* mag 1 */
138
+ /* x1 = -c * t^2 */
127
139
secp256k1_fe_mul (& x1 , & negc , & wd ); /* mag 1 */
140
+ /* x3d = t^2 */
128
141
x3d = wd ; /* mag 1 */
142
+ /* x3d = 3 * t^2 */
129
143
secp256k1_fe_mul_int (& x3d , 3 ); /* mag 3 */
144
+ /* x3d = -3 * t^2 */
130
145
secp256k1_fe_negate (& x3d , & x3d , 3 ); /* mag 4 */
146
+ /* wd = 1 + b + t^2 */
131
147
secp256k1_fe_add_int (& wd , SECP256K1_B + 1 ); /* mag 2 */
148
+ /* jinv = wd * x3d */
132
149
secp256k1_fe_mul (& jinv , & wd , & x3d ); /* mag 1 */
150
+ /* jinv = 1/(wd * x3d) */
133
151
secp256k1_fe_inv (& jinv , & jinv ); /* mag 1 */
152
+ /* x1 = -c * t^2 * x3d */
134
153
secp256k1_fe_mul (& x1 , & x1 , & x3d ); /* mag 1 */
154
+ /* x1 = -c * t^2 * x3d * 1/j */
135
155
secp256k1_fe_mul (& x1 , & x1 , & jinv ); /* mag 1 */
156
+ /* x1 = d + -c * t^2 * x3d * 1/j */
136
157
secp256k1_fe_add (& x1 , & d ); /* mag 2 */
158
+ /* x2 = x1 */
137
159
x2 = x1 ; /* mag 2 */
160
+ /* x2 = x1 + 1 */
138
161
secp256k1_fe_add_int (& x2 , 1 ); /* mag 3 */
162
+ /* x2 = - (x1 + 1) */
139
163
secp256k1_fe_negate (& x2 , & x2 , 3 ); /* mag 4 */
164
+ /* x3 = wd^2 */
140
165
secp256k1_fe_sqr (& x3 , & wd ); /* mag 1 */
166
+ /* x3 = wd^3 */
141
167
secp256k1_fe_mul (& x3 , & x3 , & wd ); /* mag 1 */
168
+ /* x3 = wd^3 * 1/j */
142
169
secp256k1_fe_mul (& x3 , & x3 , & jinv ); /* mag 1 */
170
+ /* x3 = 1 + (wd^3 * 1/j) */
143
171
secp256k1_fe_add_int (& x3 , 1 ); /* mag 2 */
144
172
145
173
secp256k1_fe_sqr (& alphain , & x1 ); /* mag 1 */
0 commit comments