Skip to content

Commit

Permalink
Add subgroup checks to BLS-12 mul amd multiexp precompiles (#166)
Browse files Browse the repository at this point in the history
Add the subgroup checks, to keep up with the latest EIP-2537 spec revisions.

Signed-off-by: Danno Ferrin <[email protected]>
  • Loading branch information
shemnon authored May 6, 2024
1 parent ce7d0f3 commit 34f4c9a
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
url = https://github.com/bitcoin-core/secp256k1.git
[submodule "bls12-381/updated-eip1962"]
path = bls12-381/updated-eip1962
url = https://github.com/garyschulte/eip1962.git
url = git@github.com:shemnon/matterlabs_eip1962.git
[submodule "secp256r1/besu-native-ec"]
path = secp256r1/besu-native-ec
url = [email protected]:ConsenSys/besu-native-ec.git
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void shouldCalculate() {
final Bytes expectedComputation =
expectedResult == null ? null : Bytes.fromHexString(expectedResult);
if (errorLength.getValue() > 0) {
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).isEqualTo(notes);
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).contains(notes);
assertThat(outputLength.getValue()).isZero();
} else {
final Bytes actualComputation = Bytes.wrap(output, 0, outputLength.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void shouldCalculate() {
final Bytes expectedComputation =
expectedResult == null ? null : Bytes.fromHexString(expectedResult);
if (errorLength.getValue() > 0) {
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).isEqualTo(notes);
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).contains(notes);
assertThat(outputLength.getValue()).isZero();
} else {
final Bytes actualComputation = Bytes.wrap(output, 0, outputLength.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void shouldCalculate() {
final Bytes expectedComputation =
expectedResult == null ? null : Bytes.fromHexString(expectedResult);
if (errorLength.getValue() > 0) {
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).isEqualTo(notes);
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).contains(notes);
assertThat(outputLength.getValue()).isZero();
} else {
final Bytes actualComputation = Bytes.wrap(output, 0, outputLength.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void shouldCalculate() {
final Bytes expectedComputation =
expectedResult == null ? null : Bytes.fromHexString(expectedResult);
if (errorLength.getValue() > 0) {
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).isEqualTo(notes);
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).contains(notes);
assertThat(outputLength.getValue()).isZero();
} else {
final Bytes actualComputation = Bytes.wrap(output, 0, outputLength.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void shouldCalculate() {
final Bytes expectedComputation =
expectedResult == null ? null : Bytes.fromHexString(expectedResult);
if (errorLength.getValue() > 0) {
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).isEqualTo(notes);
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).contains(notes);
assertThat(outputLength.getValue()).isZero();
} else {
final Bytes actualComputation = Bytes.wrap(output, 0, outputLength.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void shouldCalculate() {
final Bytes expectedComputation =
expectedResult == null ? null : Bytes.fromHexString(expectedResult);
if (errorLength.getValue() > 0) {
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).isEqualTo(notes);
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).contains(notes);
assertThat(outputLength.getValue()).isZero();
} else {
final Bytes actualComputation = Bytes.wrap(output, 0, outputLength.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void shouldCalculate() {
final Bytes expectedComputation =
expectedResult == null ? null : Bytes.fromHexString(expectedResult);
if (errorLength.getValue() > 0) {
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).isEqualTo(notes);
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).contains(notes);
assertThat(outputLength.getValue()).isZero();
} else {
final Bytes actualComputation = Bytes.wrap(output, 0, outputLength.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void shouldCalculate() {
final Bytes expectedComputation =
expectedResult == null ? null : Bytes.fromHexString(expectedResult);
if (errorLength.getValue() > 0) {
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).isEqualTo(notes);
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).contains(notes);
assertThat(outputLength.getValue()).isZero();
} else {
final Bytes actualComputation = Bytes.wrap(output, 0, outputLength.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void shouldCalculate() {
final Bytes expectedComputation =
expectedResult == null ? null : Bytes.fromHexString(expectedResult);
if (errorLength.getValue() > 0) {
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).isEqualTo(notes);
assertThat(new String(error, 0, errorLength.getValue(), UTF_8)).contains(notes);
assertThat(outputLength.getValue()).isZero();
} else {
final Bytes actualComputation = Bytes.wrap(output, 0, outputLength.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ input,result,gas,notes
000000000000000000000000000000000106df8eba767e90cce0eabdaacc24d8e226c6865012ef8cb1460de5a319d443fdc6b4f4e58fb668943e0528b1809da10000000000000000000000000000000019789f464c95c179af18704c0b67b881991880f75ee7b03b9feafa3eafcd0f7d30a17fdd9cf439ff7fe683adca2083b50000000000000000000000000000000017a81b957a12adf474a2913e8636f169ea9cd10be62c16b88f95f5caf661f158a032a9f7d249fdf2765caa1564bed0570000000000000000000000000000000017fbf2abc62dc2678b65d509e19c9c9c5d961c72565649a078da8dff98be6236ef314e9ff8022f639ff565353345c230,00000000000000000000000000000000002c8bc5f39b2c9fea01372429e92a9c945fad152da67174f4e478fdead734d50f6e2da867c235f1f2f11bdfee67d2a7000000000000000000000000000000000c1dd27aad9f5d48c4824da3071daedf0c7a0e2a0b0ed39c50c9d25e61334a9c96765e049542ccaa00e0eccb316eec08,600,
000000000000000000000000000000000012196c5a43d69224d8713389285f26b98f86ee910ab3dd668e413738282003cc5b7357af9a7af54bb713d62255e80f560000000000000000000000000000000006ba8102bfbeea4416b710c73e8cce3032c31c6269c44906f8ac4f7874ce99fb17559992486528963884ce429a992fee000000000000000000000000000000000001101098f5c39893765766af4512a0c74e1bb89bc7e6fdf14e3e7337d257cc0f94658179d83320b99f31ff94cd2bac0000000000000000000000000000000003e1a9f9f44ca2cdab4f43a1a3ee3470fdf90b2fc228eb3b709fcd72f014838ac82a6d797aeefed9a0804b22ed1ce8f7,,,invalid input parameters, invalid input length for G1 addition
00000000000000000000000000000012196c5a43d69224d8713389285f26b98f86ee910ab3dd668e413738282003cc5b7357af9a7af54bb713d62255e80f560000000000000000000000000000000006ba8102bfbeea4416b710c73e8cce3032c31c6269c44906f8ac4f7874ce99fb17559992486528963884ce429a992fee000000000000000000000000000000000001101098f5c39893765766af4512a0c74e1bb89bc7e6fdf14e3e7337d257cc0f94658179d83320b99f31ff94cd2bac0000000000000000000000000000000003e1a9f9f44ca2cdab4f43a1a3ee3470fdf90b2fc228eb3b709fcd72f014838ac82a6d797aeefed9a0804b22ed1ce8f7,,,invalid input parameters, invalid input length for G1 addition
0000000000000000000000000000000012196c5a43d69224d8713389285f26b98f86ee910ab3dd668e413738282003cc5b7357af9a7af54bb713d62255e80f570000000000000000000000000000000006ba8102bfbeea4416b710c73e8cce3032c31c6269c44906f8ac4f7874ce99fb17559992486528963884ce429a992fee000000000000000000000000000000000001101098f5c39893765766af4512a0c74e1bb89bc7e6fdf14e3e7337d257cc0f94658179d83320b99f31ff94cd2bac0000000000000000000000000000000003e1a9f9f44ca2cdab4f43a1a3ee3470fdf90b2fc228eb3b709fcd72f014838ac82a6d797aeefed9a0804b22ed1ce8f7,,,invalid input parameters, Point 0 is not on curve, file src/public_interface/eip2537/mod.rs, line 49
0000000000000000000000000000000012196c5a43d69224d8713389285f26b98f86ee910ab3dd668e413738282003cc5b7357af9a7af54bb713d62255e80f560000000000000000000000000000000006ba8102bfbeea4416b710c73e8cce3032c31c6269c44906f8ac4f7874ce99fb17559992486528963884ce429a992fee000000000000000000000000000000000001101098f5c39893765766af4512a0c74e1bb89bc7e6fdf14e3e7337d257cc0f94658179d83320b99f31ff94cd2bad0000000000000000000000000000000003e1a9f9f44ca2cdab4f43a1a3ee3470fdf90b2fc228eb3b709fcd72f014838ac82a6d797aeefed9a0804b22ed1ce8f7,,,invalid input parameters, Point 1 is not on curve, file src/public_interface/eip2537/mod.rs, line 54
0000000000000000000000000000000012196c5a43d69224d8713389285f26b98f86ee910ab3dd668e413738282003cc5b7357af9a7af54bb713d62255e80f570000000000000000000000000000000006ba8102bfbeea4416b710c73e8cce3032c31c6269c44906f8ac4f7874ce99fb17559992486528963884ce429a992fee000000000000000000000000000000000001101098f5c39893765766af4512a0c74e1bb89bc7e6fdf14e3e7337d257cc0f94658179d83320b99f31ff94cd2bac0000000000000000000000000000000003e1a9f9f44ca2cdab4f43a1a3ee3470fdf90b2fc228eb3b709fcd72f014838ac82a6d797aeefed9a0804b22ed1ce8f7,,,invalid input parameters, Point 0 is not on curve, file src/public_interface/eip2537/mod.rs
0000000000000000000000000000000012196c5a43d69224d8713389285f26b98f86ee910ab3dd668e413738282003cc5b7357af9a7af54bb713d62255e80f560000000000000000000000000000000006ba8102bfbeea4416b710c73e8cce3032c31c6269c44906f8ac4f7874ce99fb17559992486528963884ce429a992fee000000000000000000000000000000000001101098f5c39893765766af4512a0c74e1bb89bc7e6fdf14e3e7337d257cc0f94658179d83320b99f31ff94cd2bad0000000000000000000000000000000003e1a9f9f44ca2cdab4f43a1a3ee3470fdf90b2fc228eb3b709fcd72f014838ac82a6d797aeefed9a0804b22ed1ce8f7,,,invalid input parameters, Point 1 is not on curve, file src/public_interface/eip2537/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,5 @@ input,result,gas,notes
000000000000000000000000000000000106df8eba767e90cce0eabdaacc24d8e226c6865012ef8cb1460de5a319d443fdc6b4f4e58fb668943e0528b1809da10000000000000000000000000000000019789f464c95c179af18704c0b67b881991880f75ee7b03b9feafa3eafcd0f7d30a17fdd9cf439ff7fe683adca2083b57cf23dee8d95d94046678f3bdb4b0ea3d4e3a1a2f07f582e2a98ad6eb7562cbf,000000000000000000000000000000000bf700422a382546a74376b0292f3a49ceff5597f0d2b726b1ff099bcda7ba92238a21db12eff5c314a29dd2387bec850000000000000000000000000000000005e22e3c772f3634b1ccf4e311241977eb20e7269540ef22d379de26ab80c58461dfa3b67848e0d584fb11de1917949a,12000,
00000000000000000000000000000012196c5a43d69224d8713389285f26b98f86ee910ab3dd668e413738282003cc5b7357af9a7af54bb713d62255e80f560000000000000000000000000000000006ba8102bfbeea4416b710c73e8cce3032c31c6269c44906f8ac4f7874ce99fb17559992486528963884ce429a992feeb3c940fe79b6966489b527955de7599194a9ac69a6ff58b8d99e7b1084f0464e,,,invalid input parameters, invalid input length for G1 multiplication
000000000000000000000000000000000012196c5a43d69224d8713389285f26b98f86ee910ab3dd668e413738282003cc5b7357af9a7af54bb713d62255e80f560000000000000000000000000000000006ba8102bfbeea4416b710c73e8cce3032c31c6269c44906f8ac4f7874ce99fb17559992486528963884ce429a992feeb3c940fe79b6966489b527955de7599194a9ac69a6ff58b8d99e7b1084f0464e,,,invalid input parameters, invalid input length for G1 multiplication
0000000000000000000000000000000012196c5a43d69224d8713389285f26b98f86ee910ab3dd668e413738282003cc5b7357af9a7af54bb713d62255e80f570000000000000000000000000000000006ba8102bfbeea4416b710c73e8cce3032c31c6269c44906f8ac4f7874ce99fb17559992486528963884ce429a992feeb3c940fe79b6966489b527955de7599194a9ac69a6ff58b8d99e7b1084f0464e,,,invalid input parameters, Point is not on curve, file src/public_interface/eip2537/mod.rs, line 79
0000000000000000000000000000000012196c5a43d69224d8713389285f26b98f86ee910ab3dd668e413738282003cc5b7357af9a7af54bb713d62255e80f570000000000000000000000000000000006ba8102bfbeea4416b710c73e8cce3032c31c6269c44906f8ac4f7874ce99fb17559992486528963884ce429a992feeb3c940fe79b6966489b527955de7599194a9ac69a6ff58b8d99e7b1084f0464e,,,invalid input parameters, Point is not on curve, file src/public_interface/eip2537/mod.rs
0x000000000000000000000000000000000123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef00000000000000000000000000000000193fb7cedb32b2c3adc06ec11a96bc0d661869316f5e4a577a9f7c179593987beb4fb2ee424dbb2f5dd891e228b46c4a0000000000000000000000000000000000000000000000000000000000000002,,,Point is not in the expected subgroup
Loading

0 comments on commit 34f4c9a

Please sign in to comment.