@@ -309,6 +309,36 @@ contract Secp256k1Test is Test {
309
309
Secp256k1.doublePoint (x, y);
310
310
}
311
311
312
+ // ! -----------------------------------------------------------------------------------------------------------------------
313
+ // ! doublePointUnchecked() TESTS
314
+ // ! -----------------------------------------------------------------------------------------------------------------------
315
+ function doublePointUnchecked () public pure {
316
+ (uint256 x , uint256 y ) = Secp256k1.doublePointUnchecked (Gx, Gy);
317
+ assertEq (x, G2x);
318
+ assertEq (y, G2y);
319
+
320
+ // Just checking that this wont fail
321
+ (uint256 G3x , uint256 G3y ) = Secp256k1.doublePointUnchecked (G2x, G2y);
322
+ Secp256k1.doublePointUnchecked (G3x, G3y);
323
+ }
324
+
325
+ function test_doublePointUnchecked_Infinity () public pure {
326
+ (uint256 x , uint256 y ) = Secp256k1.doublePointUnchecked (0 , 0 );
327
+ assertEq (x, 0 );
328
+ assertEq (y, 0 );
329
+ }
330
+
331
+ // ! Expecting revert with internal function calls -> https://book.getfoundry.sh/cheatcodes/expect-revert?highlight=expectRevert#error
332
+ /// forge-config: default.allow_internal_expect_revert = true
333
+ function testFuzz_doublePointUnchecked_RevertIf_OutOfBounds (uint256 x , uint256 y ) public {
334
+ x = bound (x, Secp256k1.p + 1 , UINT256_MAX);
335
+ y = bound (y, Secp256k1.p + 1 , UINT256_MAX);
336
+ console.log (x, y);
337
+ // underflow or overflow
338
+ vm.expectRevert (0x11 );
339
+ Secp256k1.doublePointUnchecked (x, y);
340
+ }
341
+
312
342
// ! -----------------------------------------------------------------------------------------------------------------------
313
343
// ! modInverse() TESTS
314
344
// ! -----------------------------------------------------------------------------------------------------------------------
0 commit comments