status-im / nim-blscurve

Nim implementation of BLS signature scheme (Boneh-Lynn-Shacham) over Barreto-Lynn-Scott (BLS) curve BLS12-381
Apache License 2.0
26 stars 11 forks source link

Batched signatures verification #52

Closed mratsim closed 4 years ago

mratsim commented 4 years ago

One of the upcoming requirements will be catching up to the blockchain and receiving a batch of blocks that will need to be verified.

Assuming we need to verify 3 days of blocks which is below the weak subjectivity period, we would have:

At the current speed on a low power mobile device (https://github.com/status-im/nim-blscurve/issues/28) we can lower bound to 30 blocks per second per core

So catching up to 3 days of blocks would require 1440s (24min) for cryptography alone on a single core.

We can batch signature verifications by doing multiexponentiation using Pippenger algorithm and get 2x speedups

See Vitalik's writeup: https://ethresear.ch/t/simple-guide-to-fast-linear-combinations-aka-multiexponentiations/7238

Aztec implementation: https://github.com/AztecProtocol/barretenberg/blob/master/barretenberg/src/aztec/ecc/curves/bn254/scalar_multiplication/scalar_multiplication.cpp#L113

Gnark implementation: https://github.com/ConsenSys/gnark/blob/d160f27275a740b879d4132138e642c9c6ea1b0c/ecc/bls381/g1.go#L388

Note: this is different from aggregate signature verification which is implemented.