@@ -147,8 +147,54 @@ contract Secp256k1Test is Test {
147
147
// ! -----------------------------------------------------------------------------------------------------------------------
148
148
// ! addPoints() TESTS
149
149
// ! -----------------------------------------------------------------------------------------------------------------------
150
+ // TODO -> invalid point P1, P2
151
+ // TODO -> invalid coordinates
152
+ // TODO -> valid sum with diff points
153
+ // TODO -> using infinity point for P1 and P2
154
+ // TODO -> Double point check for valid points
155
+ // TODO -> G + GNeg = (0,0)
156
+ function test_addPoints_WithInfinity () public pure {
157
+ (uint256 x , uint256 y ) = Secp256k1.addPoints (0 , 0 , Gx, Gy);
158
+ assertEq (x, Gx);
159
+ assertEq (y, Gy);
160
+
161
+ (uint256 x1 , uint256 y1 ) = Secp256k1.addPoints (Gx, Gy, 0 , 0 );
162
+ assertEq (x1, Gx);
163
+ assertEq (y1, Gy);
164
+ }
165
+
166
+ function test_addPoints_WorkingExamples () public pure {
167
+ (uint256 x , uint256 y ) = Secp256k1.addPoints (0 , 0 , G2x, G2y);
168
+ assertEq (x, G2x);
169
+ assertEq (y, G2y);
170
+
171
+ (uint256 x1 , uint256 y1 ) = Secp256k1.addPoints (G2x, G2y, 0 , 0 );
172
+ assertEq (x1, G2x);
173
+ assertEq (y1, G2y);
174
+
175
+ (uint256 x2 , uint256 y2 ) = Secp256k1.addPoints (Gx, GyNeg, 0 , 0 );
176
+ assertEq (x2, Gx);
177
+ assertEq (y2, GyNeg);
178
+
179
+ (uint256 x3 , uint256 y3 ) = Secp256k1.addPoints (0 , 0 , Gx, GyNeg);
180
+ assertEq (x3, Gx);
181
+ assertEq (y3, GyNeg);
150
182
151
- function test_addPoints () public {}
183
+ Secp256k1.addPoints (Gx, Gy, G2x, G2y);
184
+ Secp256k1.addPoints (G2x, G2y, Gx, GyNeg);
185
+ }
186
+
187
+ function test_addPoints_Double () public pure {
188
+ (uint256 x , uint256 y ) = Secp256k1.addPoints (Gx, Gy, Gx, Gy);
189
+ assertEq (x, G2x);
190
+ assertEq (y, G2y);
191
+ }
192
+
193
+ function test_addPoints_AddNegated () public pure {
194
+ (uint256 x , uint256 y ) = Secp256k1.addPoints (Gx, Gy, Gx, GyNeg);
195
+ assertEq (x, 0 );
196
+ assertEq (y, 0 );
197
+ }
152
198
153
199
function test_addPointsGasCosts () public view {
154
200
// Test 1: Point doubling (G + G)
0 commit comments