ChainSafe / blst-ts

Typescript wrapper for https://github.com/supranational/blst native bindings, a highly performant BLS12-381 signature library
Other
18 stars 13 forks source link

fix: remove JS glue code from spec tests and fix native implementations #146

Closed matthewkeil closed 4 months ago

matthewkeil commented 5 months ago

Split off from https://github.com/ChainSafe/blst-ts/pull/143

Note Putting PR in draft until #144 and #145 get merged. This branch builds on the code in those two, so will need to rebase this work after merging those.

Motivations

Updates the spec tests and code to remove all JS glue code that was being implemented to get specs to pass. Originally this repo was based on the SWIG version of the code which was not editable. To accommodate the specs some try/catch and conditionals were added to get things compliant.

This PR removed all the glue code in the testing files and ensured that all conditions are handled directly by the native code.

These changes were driven by the removal of bls from lodestar. There was some glue code in there in addition to the spec tests.

Now all functions take the spec data input and pass it directly to the function calls. All output is also directly taken and passed to the expectation to ensure the base layer is 100% compliant with the spec.

github-actions[bot] commented 5 months ago

Performance Report

✔️ no performance regression detected

Full benchmark results | Benchmark suite | Current: 6a7318bc0511f3dd75625bf39d7f60ba5de62236 | Previous: - | Ratio | |-|-|-|-| | PublicKey serialization | 939.00 ns/op | | PublicKey deserialize | 22.249 us/op | | PublicKey deserialize and validate - 1 keys | 83.494 us/op | | PublicKey deserialize and validate - 100 keys | 8.2749 ms/op | | PublicKey deserialize and validate - 10000 keys | 831.67 ms/op | | SecretKey.fromKeygen | 2.5370 us/op | | SecretKey serialization | 840.00 ns/op | | SecretKey deserialization | 1.8400 us/op | | SecretKey.toPublicKey | 138.37 us/op | | SecretKey.sign | 529.52 us/op | | Signature serialization | 1.0690 us/op | | Signature deserialize | 44.668 us/op | | Signatures deserialize and validate - 1 sets | 120.33 us/op | | Signatures deserialize and validate - 100 sets | 11.950 ms/op | | Signatures deserialize and validate - 10000 sets | 1.1985 s/op | | aggregatePublicKeys - 1 sets | 2.5760 us/op | | aggregatePublicKeys - 8 sets | 10.427 us/op | | aggregatePublicKeys - 32 sets | 37.840 us/op | | aggregatePublicKeys - 128 sets | 147.59 us/op | | aggregatePublicKeys - 256 sets | 295.21 us/op | | aggregateSignatures - 1 sets | 4.1870 us/op | | aggregateSignatures - 8 sets | 24.018 us/op | | aggregateSignatures - 32 sets | 91.416 us/op | | aggregateSignatures - 128 sets | 360.18 us/op | | aggregateSignatures - 256 sets | 726.60 us/op | | aggregateVerify - 1 sets | 1.5741 ms/op | | aggregateVerify - 8 sets | 5.7377 ms/op | | aggregateVerify - 32 sets | 20.328 ms/op | | aggregateVerify - 128 sets | 78.684 ms/op | | aggregateVerify - 256 sets | 156.55 ms/op | | verifyMultipleAggregateSignatures - 1 sets | 1.7456 ms/op | | verifyMultipleAggregateSignatures - 8 sets | 7.0464 ms/op | | verifyMultipleAggregateSignatures - 32 sets | 25.603 ms/op | | verifyMultipleAggregateSignatures - 128 sets | 99.811 ms/op | | verifyMultipleAggregateSignatures - 256 sets | 198.91 ms/op | | Same message - 1 sets | 1.7038 ms/op | | Same message - 8 sets | 2.5806 ms/op | | Same message - 32 sets | 5.5472 ms/op | | Same message - 128 sets | 17.316 ms/op | | Same message - 256 sets | 33.035 ms/op | | libuv multithreading - addVerificationRandomness true | 23.795 s/op | | libuv multithreading - addVerificationRandomness false | 23.736 s/op |

by benchmarkbot/action