Skip to content

Commit

Permalink
bls12381: Add map_to_g2 implementation (#35)
Browse files Browse the repository at this point in the history
* WIP: Add initial map_to_g2 skeleton

* replace psi with correct version, add psi2
* clear_cofactor and subgroup_check for G2 working
* initial G1 subgroup check skeleton

* Working iso3_map, finished osswu2 but not working

* Fix iso3_map den_0/den_1 exception case

* Fix osswu2 and get all main tests passing

One of the problems seems to be that constant elements (e.g. created
with `from_dec`) do not seem to work correctly with some operations.
Specifically, the `.neg()` calls for `xi` and `a` were just not doing
anything. This needs more investigation.

* Finalize missing functions and first cleanup pass

* Add assert_is_on_curve for both G1 and G2
* Fix G1 phi endomorphism, subgroup_check, add tests
* Update Cargo.toml to enable "experimental" feature for exposing
hash_to_g2 stuff in bls12_381
* Fix README link
* Remove handful of unnecessary constant allocations
* Make sgn0 work for constants and add handful more test cases
* Remove debug and commented out code chunks
* Remove debug panic!s

* Move sgn0 to bellpepper-emulated

Also undo the pub(crate) changes

* Change default test field to BN256 and limb params

This requires a small change in pairing.rs to prevent overflow

Also change the default limb counts to 55/7, which gives a significant
reduction in constraints for BN256

* Replace FIXME with eprintln!

* Lower reductions and remove unnecessary TODOs

The TODOs aren't as relevant because the current choice already uses
fewer contraints than the alternative

* Add docstrings for G1 and G2 functions

* Cleanup opt_simple_swu2 and fix lints

* Comment out test_random_multi_pairing for CI

* Comment out the other pairing test as well

* Attempt to run pairing tests in CI again

* Attempt to refresh CI

* Readd `fail-fast: false`

* Add comment to Fp12::square

Also fix a few poorly named namespaces

* Update expected test results after rebase
  • Loading branch information
wwared authored Feb 26, 2024
1 parent 68172e9 commit ae5a150
Show file tree
Hide file tree
Showing 13 changed files with 1,602 additions and 403 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ concurrency:

jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: gh-32vcpu-128gbram-ubuntu-2204
strategy:
matrix:
os:
- ubuntu-latest
fail-fast: false
env:
RUSTFLAGS: -D warnings
Expand Down
6 changes: 3 additions & 3 deletions crates/bls12381/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "bellpepper-bls12381"
version = "0.2.0"
edition = "2021"
authors = ["Gustavo <gustavo@wrinqle.net>"]
authors = ["Lurk Lab Engineering <engineering@lurk-lab.com>"]
license.workspace=true
description = "Bellpepper circuit implementation of BLS12-381 pairing and curve operations"
documentation = "https://docs.rs/bellpepper-bls12381"
Expand All @@ -19,8 +19,8 @@ num-bigint = { workspace = true, features = ["rand"] }
num-integer = { workspace = true }
num-traits = { workspace = true}
rand = { workspace = true}
bls12_381 = { git = "https://github.com/wrinqle/bls12_381" }
bls12_381 = { git = "https://github.com/wrinqle/bls12_381", features = ["experimental"] }

[dev-dependencies]
expect-test = "1.4.1"
pasta_curves = "0.5.1"
halo2curves = "0.6.1"
2 changes: 1 addition & 1 deletion crates/bls12381/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bellpepper-bls12381

Emulated pairing and elliptic curve library using [bellpepper](https://github.com/lurk-lab/bellpepper) inspired by the [emulated](https://github.com/Consensys/gnark/tree/master/std/math/emulated) package in [Gnark](https://github.com/Consensys/gnark)
Emulated pairing and elliptic curve library using [bellpepper](https://github.com/lurk-lab/bellpepper) inspired by the [emulated](https://github.com/Consensys/gnark/tree/master/std/algebra/emulated) package in [Gnark](https://github.com/Consensys/gnark)

## License

Expand Down
Loading

0 comments on commit ae5a150

Please sign in to comment.