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

Add BLS-on-BN254 scheme for EVM networks #1304

Merged
merged 6 commits into from
May 21, 2024

Conversation

kevincharm
Copy link
Contributor

@kevincharm kevincharm commented Feb 11, 2024

Many new rollups & networks are coming online, and many of them need good quality onchain randomness! This PR adds a BLS-on-BN254 scheme that is maximally compatible with EVM networks, with signatures on G1.

A test network has been deployed here.

A verifier contract has been deployed to Base. The repo can be found at fairylabs/anyrand. Example fulfillment tx.

@CluEleSsUK
Copy link
Contributor

lgtm! Just waiting on the kyber stuff to get reviewed then we can update the go.mod accordingly and merge away

crypto/schemes.go Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
test/default.toml Outdated Show resolved Hide resolved
@kevincharm kevincharm marked this pull request as draft March 19, 2024 16:54
@kevincharm kevincharm marked this pull request as ready for review March 20, 2024 00:28
@kevincharm
Copy link
Contributor Author

I've updated kyber to the newly cut 1.3.0 release which contains other changes besides the addition of BN254. Also deployed the updated verifier contracts just to make sure everything works end-to-end :)
https://basescan.org/tx/0xd258c1d9aa9d1a64633783267775b96548b2471c1a3ba8c2fb614decc059a414#eventlog

CluEleSsUK
CluEleSsUK previously approved these changes Mar 20, 2024
Comment on lines 225 to 226
// See: https://github.com/jonboulle/clockwork/commit/276013b7b35d157f1a3e88c12ba6cf7480f8669f
dt.clock = clock.NewFakeClockAt(time.Date(1984, time.April, 4, 0, 0, 0, 0, time.UTC))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, this seems to predate creation of drand itself, so we should always have been using the "new" value from 2015.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is very weird indeed. I first changed it to the newer value before I realised the test had the old value hardcoded.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was previously buried in the clockworks library - hence why we had a unix epoch literal in the test before

@AnomalRoil
Copy link
Member

So. The only thing that's currently preventing me from merging this is that we're actually doing most of the recent dev on the branch feature/drand-v2.0.0 would you mind rebasing this against that branch and doing the PR against that branch rather @kevincharm ?

@kevincharm
Copy link
Contributor Author

will do!

@kevincharm kevincharm changed the base branch from master to feature/drand-v2.0.0 April 2, 2024 00:50
@AnomalRoil
Copy link
Member

Have you tried running all tests using the SCHEME_ID env variable as well?
Maybe you could add this scheme to the CI tests:

scheme_id: [ "pedersen-bls-chained", "pedersen-bls-unchained", "bls-unchained-on-g1", "bls-unchained-g1-rfc9380" ]

@kevincharm
Copy link
Contributor Author

@AnomalRoil I found a couple of issues running the tests under the new scheme (please see the inline comments). Sorry I should have double checked the drand tests when working on kyber, some of these could have been avoided.

Also I cannot get the TestBeaconSimple test to pass, keeps running into a race condition. Any ideas on what could be the issue there?

@kevincharm
Copy link
Contributor Author

I opened a new PR on kyber to address the race issues and get the drand tests passing: drand/kyber#59

@kevincharm
Copy link
Contributor Author

I updated kyber to the latest commit (no tag yet), and all tests appear to be passing on my machine with SCHEME_ID=bls-bn254-unchained-on-g1. Also added this scheme to the rest of the other CI test jobs, so hopefully everything passes there 🤞

@AnomalRoil AnomalRoil merged commit 15282bd into drand:feature/drand-v2.0.0 May 21, 2024
61 of 62 checks passed
CluEleSsUK pushed a commit that referenced this pull request Jun 28, 2024
* add bls-bn254-unchained-on-g1 scheme
* check equality of chain info/public key using Equal instead of comparing values in tests
* update kyber
* add bls-bn254-unchained-on-g1 scheme to all other CI test jobs
AnomalRoil pushed a commit that referenced this pull request Jun 28, 2024
* add bls-bn254-unchained-on-g1 scheme
* check equality of chain info/public key using Equal instead of comparing values in tests
* update kyber
* add bls-bn254-unchained-on-g1 scheme to all other CI test jobs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants