Skip to content

Commit 29b68e7

Browse files
Remove unused disable asserts + add one more Wycherproof test ot stdlib
1 parent e315d8e commit 29b68e7

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,6 @@ TYPED_TEST(EcdsaTests, InvalidS)
443443

444444
TYPED_TEST(EcdsaTests, HighS)
445445
{
446-
// Disable asserts because native ecdsa verification raises an error if s >= (n+1)/2
447-
BB_DISABLE_ASSERTS();
448446
TestFixture::test_verify_signature(/*random_signature=*/false, TestFixture::TamperingMode::HighS);
449447
}
450448

@@ -460,24 +458,16 @@ TYPED_TEST(EcdsaTests, ZeroS)
460458

461459
TYPED_TEST(EcdsaTests, InvalidPubKey)
462460
{
463-
// Disable asserts because `validate_on_curve` raises an error in the `mult_madd` function:
464-
// BB_ASSERT_EQ(remainder_1024.lo, uint512_t(0))
465-
BB_DISABLE_ASSERTS();
466461
TestFixture::test_verify_signature(/*random_signature=*/false, TestFixture::TamperingMode::InvalidPubKey);
467462
}
468463

469464
TYPED_TEST(EcdsaTests, InfinityPubKey)
470465
{
471-
// Disable asserts to avoid errors trying to invert zero
472-
BB_DISABLE_ASSERTS();
473466
TestFixture::test_verify_signature(/*random_signature=*/false, TestFixture::TamperingMode::InfinityPubKey);
474467
}
475468

476469
TYPED_TEST(EcdsaTests, InfinityScalarMul)
477470
{
478-
// Disable asserts because native ecdsa verification raises an error if the result of the scalar multiplication is
479-
// the point at infinity
480-
BB_DISABLE_ASSERTS();
481471
TestFixture::test_verify_signature(/*random_signature=*/false, TestFixture::TamperingMode::InfinityScalarMul);
482472
}
483473

@@ -507,9 +497,6 @@ TYPED_TEST(EcdsaTests, SignatureGenerator)
507497

508498
TEST(EcdsaTests, Secp256k1PointAtInfinityRegression)
509499
{
510-
// Disable asserts because native ecdsa verification raises an error if the result of the scalar multiplication is
511-
// the point at infinity
512-
BB_DISABLE_ASSERTS();
513500
using Curve = stdlib::secp256k1<UltraCircuitBuilder>;
514501

515502
using FqNative = Curve::fq;

barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_tests_data.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ const std::vector<WycherproofSecp256k1> secp256k1_tests{
8181
.is_circuit_satisfied = true,
8282
.comment = "Edge case public key, y coordinate is small",
8383
},
84+
// Modular inverse edge case
85+
WycherproofSecp256k1{
86+
.x = WycherproofSecp256k1::Fq("0x9171fec3ca20806bc084f12f0760911b60990bd80e5b2a71ca03a048b20f837e"),
87+
.y = WycherproofSecp256k1::Fq("0x634fd17863761b2958d2be4e149f8d3d7abbdc18be03f451ab6c17fa0a1f8330"),
88+
.message = { 0x31, 0x32, 0x33, 0x34, 0x30, 0x30 },
89+
.r = WycherproofSecp256k1::Fr("0x55555555555555555555555555555554e8e4f44ce51835693ff0ca2ef01215c1"),
90+
.s = WycherproofSecp256k1::Fr("0x2736d76e412246e097148e2bf62915614eb7c428913a58eb5e9cd4674a9423de"),
91+
.is_valid_signature = true,
92+
.is_circuit_satisfied = true,
93+
.comment = "Modular inverse edge case",
94+
},
8495
};
8596

8697
/**
@@ -122,5 +133,16 @@ const std::vector<WycherproofSecp256r1> secp256r1_tests{
122133
.is_circuit_satisfied = true,
123134
.comment = "Edge case public key, x-coordinate has many trailing zeros",
124135
},
136+
// Edge case public key test
137+
WycherproofSecp256r1{
138+
.x = WycherproofSecp256r1::Fq("0x2927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838"),
139+
.y = WycherproofSecp256r1::Fq("0xc7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e"),
140+
.message = { 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65 },
141+
.r = WycherproofSecp256r1::Fr("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
142+
.s = WycherproofSecp256r1::Fr("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550"),
143+
.is_valid_signature = false,
144+
.is_circuit_satisfied = true,
145+
.comment = "Signature with special case values r=n and s=n - 1",
146+
},
125147
};
126148
} // namespace bb::stdlib

0 commit comments

Comments
 (0)