Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #42

Merged
merged 33 commits into from
Apr 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
11e762c
Update Try and Increment hashing
ValarDragon Mar 14, 2018
bfaea98
Use standardized counter formatting
ValarDragon Mar 14, 2018
b3c9a1c
Add back Shallue - van de Woestijne encoding
ValarDragon Mar 14, 2018
4e39731
Add interface to dis2's bls12 implementation
ValarDragon Mar 14, 2018
151a284
Fix for interfacied-Fq* in bls12.
dis2 Mar 16, 2018
aa36a52
bls12: Cope whenever common G intf gets inferred.
dis2 Mar 16, 2018
5fc49f6
Switch bls12 to use Fouque Tibouchi as specified in ebfull/pairing#30
ValarDragon Mar 16, 2018
a6fbd0d
Include point addition to Fouque Tibouchi hashing. Minor refactoring.
ValarDragon Mar 18, 2018
0065e8f
Remove kangaroo twelve, add blind bls12 hashing
ValarDragon Mar 19, 2018
a8f4fba
Merge pull request #30 from Project-Arda/hashing
jlandrews Mar 21, 2018
b5081ab
Refactor curves and schemes into folders
ValarDragon Mar 22, 2018
8eb27c6
Merge pull request #31 from Project-Arda/refactor
jlandrews Mar 22, 2018
7e757dd
Add testing for parity, fix bls12 degenerate cases.
ValarDragon Mar 23, 2018
f4e77cc
Add testcase generation for G1 Hashing
ValarDragon Mar 24, 2018
68d5174
Update hashing to match ebfull/bls12#30. It now matches that specific…
ValarDragon Mar 25, 2018
96b3e0e
Check the size of data when unmarshalling bls12 G1 & G2
ValarDragon Mar 26, 2018
8489719
Add second type of BLS signature
ValarDragon Mar 26, 2018
e368502
Add Dan Boneh's new method
ValarDragon Mar 26, 2018
09ce6e2
Merge pull request #34 from Project-Arda/new_blstypes
jlandrews Mar 27, 2018
32e35e9
Add point at infinity
ValarDragon Mar 27, 2018
12df07e
Add blake2b state reuse
ValarDragon Mar 28, 2018
06c7902
Merge branch 'develop' into hashing
ValarDragon Mar 28, 2018
453e051
Merge pull request #35 from Project-Arda/hashing
jlandrews Mar 29, 2018
60b0333
Added basic multisig with multiplicity verification
UnitylChaos Mar 27, 2018
481eb14
bgls: minor refactor, abstract scaling the public keys.
ValarDragon Mar 29, 2018
726636f
Abstract Point interface for Point1 and Point2
ValarDragon Mar 29, 2018
a35ccbc
blake2b: Use State reuse with go's official repo.
ValarDragon Mar 31, 2018
4ea3743
Add MakeG2Point to curve interface
ValarDragon Apr 1, 2018
3b11221
Move generic point interfaces from bgls to curves
ValarDragon Apr 2, 2018
c2134b2
bgls: Add documentation, minor refactor, fix linting, fix Kosk
ValarDragon Apr 6, 2018
e52b8df
Switch to using product of pairings when applicable
ValarDragon Apr 6, 2018
3811fb1
bgls: standardize order of parameters, add docs
ValarDragon Apr 6, 2018
ff5d5c7
Update README to mention bls12
ValarDragon Apr 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Larger testcases can be generated locally
testcases/*

# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
Expand Down
39 changes: 23 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
Master: [![Build Status](https://travis-ci.org/Project-Arda/bgls.svg?branch=master)](https://travis-ci.org/Project-Arda/bgls)
Develop: [![Build Status](https://travis-ci.org/Project-Arda/bgls.svg?branch=develop)](https://travis-ci.org/Project-Arda/bgls)

Aggregate and Multi Signatures based on BGLS over Alt bn128
Aggregate and Multi Signatures based on BGLS over Alt bn128 and BLS12-381

This library provides no security against side channel attacks. We provide no security guarantees of this implementation.

## Design
The goal of this library is to create an efficient and secure ad hoc aggregate and multi signature scheme. It relies on [alt bn128](https://github.com/ethereum/go-ethereum/tree/master/crypto/bn256) for curve and pairing operations. It implements hashing of arbitrary byte data to curve points, the standard BGLS scheme for aggregate signatures, and a custom multi signature scheme.
The goal of this library is to create an efficient and secure ad hoc aggregate and multi signature scheme. It supports the curves [bls12-381](https://github.com/dis2/bls12) and [alt bn128](https://github.com/ethereum/go-ethereum/tree/master/crypto/bn256). It implements hashing of arbitrary byte data to curve points, the standard BGLS scheme for aggregate signatures, and a custom multi signature scheme.

### Multi Signature
The multi signature scheme is a modification of the BGLS scheme, where all signatures are on the same message. This allows verification with a constant number of pairing operations, at the cost of being insecure to chosen key attacks. To fix the chosen key attack, users are required to prove knowledge of their secret key, through the use of the Schnorr scheme applied to their public key.
The multi signature scheme is a modification of the BGLS scheme, where all signatures are on the same message. This allows verification with a constant number of pairing operations, at the cost of being insecure to rogue public key attacks. We have three separate solutions to the rogue public key attack implemented. (Proving knowlege of the secret key, Enforcing that messages are distinct, and performing aggregation with hashed exponents. These are described in Dan Boneh's [recent paper]((https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html)))

## Curves
### Bls12-381

This is the set of curves which zcash is switching too. Its official documentation is located [here](https://github.com/ebfull/pairing/tree/master/src/bls12_381).

### Alt bn128

The group `G_1` is a cyclic group of prime order on the curve `Y^2 = X^3 + 3` defined over the field `F_p` with `p = 21888242871839275222246405745257275088696311157297823662689037894645226208583`.
Expand All @@ -28,24 +32,26 @@ The generator `g_2` is defined as: `(1155973203298638710799100402139228578392581
The identity element for both groups (The point at infinity in affine space) is internally represented as `(0,0)`

## Benchmarks
The following benchmarks are from a 3.80GHz i7-7700HQ CPU with 16GB ram. The aggregate verification is utilizing parallelization for the pairing operations. The multisignature has parellilization for the two involved pairing operations, and parallelization for the pairing checks at the end.
The following benchmarks are from a 3.80GHz i7-7700HQ CPU with 16GB ram. The aggregate verification is utilizing parallelization for the pairing operations. The multisignature has parellilization for the two involved pairing operations, and parallelization for the pairing checks at the end. Note, all of the benchmarks need to be updated.

For reference, the pairing operation (the slowest operation involved) takes ~1.6 milliseconds.
For reference, the pairing operation on Altbn128 (the slowest operation involved) takes ~1.9 milliseconds.
```
BenchmarkG1-8 10000 141018 ns/op
BenchmarkG2-8 3000 471002 ns/op
BenchmarkPairing-8 1000 1609893 ns/op
PASS
ok github.com/ethereum/go-ethereum/crypto/bn256/cloudflare 4.725s
BenchmarkPairing-8 1000 1958898 ns/op
```
and for Bls12 its:
```
BenchmarkPairGT-8 1000 1539918 ns/op
```

- `Signing` ~.22 milliseconds
- `Signature verification` ~3.1 milliseconds, using two pairings.
- `Multi Signature verification` ~2 milliseconds + ~1.1 microseconds per signer, two pairings + n point additions
- `Aggregate Signature verification` ~.36 milliseconds per signer/message pair, with n+1 pairings run in parallel. (4.45x speedup with 8 cores)

The following benchmarks are done with altbn128, before the product of pairings
abstraction was included. These need to be updated.
```
$ go test github.com/Project-Arda/bgls/ -v -bench .
$ go test github.com/Project-Arda/bgls/bgls/ -v -bench .
BenchmarkKeygen-8 3000 434484 ns/op
BenchmarkAltBnHashToCurve-8 20000 91947 ns/op
BenchmarkSigning-8 10000 218670 ns/op
Expand All @@ -71,21 +77,22 @@ ok golang.org/x/crypto/ed25519 5.750s
```

### Hashing
The hashing algorithm is currently try-and-increment, and we support SHA3, Kangaroo twelve, Keccak256, and Blake2b.
Currently only hashing to G1 is supported. Hashing to G2 is planned.
For altbn128, the hashing algorithm is currently try-and-increment, and we support SHA3, Kangaroo twelve, Keccak256, and Blake2b.

We previously used a direct implementation of [Indifferentiable Hashing to Barreto–Naehrig Curves](http://www.di.ens.fr/~fouque/pub/latincrypt12.pdf) using blake2b. This was removed because it can't be implemented in the EVM due to gas costs, and because it will not work for BLS12-381.
For bls12-381, we are using [Fouque-Tibouchi hashing](http://www.di.ens.fr/~fouque/pub/latincrypt12.pdf) using blake2b. This is interoperable with ebfull's repository.

## Future work
- Optimize bigint allocations.
- Add utility operations for serialization of keys/signatures.
- Implement a better Hashing algorithm, such as Elligator Squared.
- Integrate [BLS12-381](https://github.com/ebfull/pairing/tree/master/src/bls12_381) with go bindings.
- Add hashing to G2
- Integrations with [bgls-on-evm](https://github.com/jlandrews/bgls-on-evm).
- Add tests to show that none of the functions mutate data.
- More complete usage documentation.
- Add buffering for the channels used in parallelization.
- Make upstream libraries implement [product of pairings algorithms](https://eprint.iacr.org/2006/172.pdf)

## References
- Dan Boneh [Methods to prevent the rogue public key attack](https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html)
- Dan Boneh, Craig Gentry, Ben Lynn, and Hovav Shacham. [Aggregate and verifiably encrypted signatures from bilinear maps](https://www.iacr.org/archive/eurocrypt2003/26560416/26560416.pdf)
- Pierre-Alain Fouque and Mehdi Tibouchi. [Indifferentiable Hashing to
Barreto–Naehrig Curves](http://www.di.ens.fr/~fouque/pub/latincrypt12.pdf)
Expand Down
255 changes: 0 additions & 255 deletions bgls.go

This file was deleted.

Loading