This is a repository for creating sample code to perform "BLS signature aggregation" using herumi/bls-go-binary.
Signature aggregation is the aggregation of multiple signatures, generated by multiple private keys, into a single signature. The aggregated signature can be verified using multiple public keys that are pairs of the private keys that generate the signature. In addition, BLS public keys can aggregate multiple public keys.
See main.go for the specific code. The following is the result of the execution.
▶ $ go test -bench . -benchmem
% go test -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/herumi/bls-eth-go-binary
BenchmarkBLS/Key-Pair_Generation-8 7742 151558 ns/op
BenchmarkBLS/Sign-8 5294 232674 ns/op
BenchmarkBLS/Verify-8 1010 1149041 ns/op
[BLS] private key: 32 bytes, public key: 96 bytes, signature: 48 bytes
BenchmarkEd25519/Key-Pair_Generation-8 25459 47311 ns/op
BenchmarkEd25519/Sign-8 23902 48841 ns/op
BenchmarkEd25519/Verify-8 9898 129513 ns/op
[Ed25519] private key: 64 bytes, public key: 32 bytes, signature: 64 bytes
BenchmarkECDSA/Key-Pair_Generation-8 78411 14663 ns/op
BenchmarkECDSA/Sign-8 49320 24263 ns/op
BenchmarkECDSA/Verify-8 16366 74319 ns/op
[ECDSA] private key: 96 bytes, public key: 64 bytes, signature: 64 bytes
BenchmarkSecp256k1/Key-Pair_Generation-8 22346 53540 ns/op
BenchmarkSecp256k1/Sign-8 13569 91215 ns/op
BenchmarkSecp256k1/Verify-8 9688 124046 ns/op
[ECDSA (secp256k1)] private key: 96 bytes, public key: 64 bytes, signature: 64 bytes
BenchmarkBLSSignatureAggregation/Signatures_Aggregation[1]-8 11499210 96.2 ns/op
BenchmarkBLSSignatureAggregation/Signatures_Aggregation[2]-8 1681064 723 ns/op
BenchmarkBLSSignatureAggregation/Signatures_Aggregation[4]-8 617895 1979 ns/op
BenchmarkBLSSignatureAggregation/Signatures_Aggregation[10]-8 200535 5651 ns/op
BenchmarkBLSSignatureAggregation/Signatures_Aggregation[21]-8 96157 12462 ns/op
BenchmarkBLSSignatureAggregation/Signatures_Aggregation[46]-8 42156 28417 ns/op
BenchmarkBLSSignatureAggregation/Signatures_Aggregation[100]-8 19039 62396 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[1]-8 964 1165108 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[2]-8 1014 1159274 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[4]-8 984 1153306 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[10]-8 1004 1196626 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[21]-8 912 1196352 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[46]-8 926 1257405 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[100]-8 874 1345655 ns/op
BenchmarkBLSSignatureAggregation/Public_Keys_Aggregation[1]-8 8234521 128 ns/op
BenchmarkBLSSignatureAggregation/Public_Keys_Aggregation[2]-8 679708 1935 ns/op
BenchmarkBLSSignatureAggregation/Public_Keys_Aggregation[4]-8 208042 5409 ns/op
BenchmarkBLSSignatureAggregation/Public_Keys_Aggregation[10]-8 73802 16147 ns/op
BenchmarkBLSSignatureAggregation/Public_Keys_Aggregation[21]-8 31640 36093 ns/op
BenchmarkBLSSignatureAggregation/Public_Keys_Aggregation[46]-8 14922 78852 ns/op
BenchmarkBLSSignatureAggregation/Public_Keys_Aggregation[100]-8 6961 175474 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[1]_by_Aggregated_Public_Key-8 1003 1172332 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[2]_by_Aggregated_Public_Key-8 990 1159117 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[4]_by_Aggregated_Public_Key-8 1004 1165515 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[10]_by_Aggregated_Public_Key-8 1004 1177069 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[21]_by_Aggregated_Public_Key-8 994 1188179 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[46]_by_Aggregated_Public_Key-8 987 1200957 ns/op
BenchmarkBLSSignatureAggregation/Aggregated_Signature_Verification[100]_by_Aggregated_Public_Key-8 908 3219806 ns/op
BenchmarkBLSSignatureAggregation/AggregateSigsForDiffMsg[1]-8 8932548 122 ns/op
BenchmarkBLSSignatureAggregation/AggregateSigsForDiffMsg[2]-8 1000000 1130 ns/op
BenchmarkBLSSignatureAggregation/AggregateSigsForDiffMsg[4]-8 369801 2842 ns/op
BenchmarkBLSSignatureAggregation/AggregateSigsForDiffMsg[10]-8 179419 6161 ns/op
BenchmarkBLSSignatureAggregation/AggregateSigsForDiffMsg[21]-8 83547 14009 ns/op
BenchmarkBLSSignatureAggregation/AggregateSigsForDiffMsg[46]-8 38156 31310 ns/op
BenchmarkBLSSignatureAggregation/AggregateSigsForDiffMsg[100]-8 17504 77609 ns/op
BenchmarkBLSSignatureAggregation/VerifyAggrSigsForDiffMsg[1]-8 849 1329866 ns/op
BenchmarkBLSSignatureAggregation/VerifyAggrSigsForDiffMsg[2]-8 648 1916088 ns/op
BenchmarkBLSSignatureAggregation/VerifyAggrSigsForDiffMsg[4]-8 404 3046083 ns/op
BenchmarkBLSSignatureAggregation/VerifyAggrSigsForDiffMsg[10]-8 165 7307559 ns/op
BenchmarkBLSSignatureAggregation/VerifyAggrSigsForDiffMsg[21]-8 79 14443697 ns/op
BenchmarkBLSSignatureAggregation/VerifyAggrSigsForDiffMsg[46]-8 32 36547031 ns/op
BenchmarkBLSSignatureAggregation/VerifyAggrSigsForDiffMsg[100]-8 14 73168560 ns/op
PASS
ok github.com/herumi/bls-eth-go-binary 79.621s
In aggregated signature and public key, I generated 10 key-pairs, created 10 signatures for one message, and aggregated them into a single signature. It's able to verify the aggregated signature using 10 public keys or one public key that aggregates them.
The order in which signatures are aggregated and the order of public keys has no effect on verification.
Data | BLS | BLS (ETH) | Ed25519 | ECDSA (p256) | ECDSA (secp256k1) |
---|---|---|---|---|---|
Private Key | 32 bytes | 32 bytes | 64 bytes | 96 bytes | 96 bytes |
Public Key | 96 bytes | 48 bytes | 32 bytes | 64 bytes | 64 bytes |
Signature | 48 bytes | 96 bytes | 64 bytes | 64 bytes | 64 bytes |
Aggregated Signature | 48 bytes | 96 bytes | - | - | - |
Aggregated Public Key | 96 bytes | 48 bytes | - | - | - |
The table above shows that aggregated public key and aggregated signature have the same size as regular public key and signature.
Follows are the execution times for 1) key-pair generation, 2) signing with a single private key, and 3) verifying a single signature with a single public key by bls_test.go:
BLS | Ed25519 | ECDSA (p256) | ECDSA (secp256k1) | |
---|---|---|---|---|
Key-Pair Generation | 151,558ns | 47,311ns | 14,663ns | 53,540ns |
Sign | 232,674ns | 48,841ns | 24,263ns | 91,215ns |
Verify | 1,149,041ns | 129,513ns | 74,319ns | 124,046ns |
We can see that BLS signatures are generally slower than ed25519 and ECDSA.
The time for signatures and public keys aggregation increases in proportion to their number. However, the verification for the aggregated signature is completed in constant time. In the case of signatures for different messages, the verification time is proportional to the number of signatures, even for aggregated signatures.