Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support BLS12-381 (based on
bls12_381
crate) (#8)
Add curve BLS12-381. Targets `ff = "0.13.0"`. ### Sources: - https://github.com/privacy-scaling-explorations/bls12_381 (all types, majority of trait impls, and tests) - https://github.com/privacy-scaling-explorations/halo2curves/blob/support_bls12-381/src/bls12_381/mod.rs (endomorphism) The decision to copy implementation from `bls12_381` crate is explained by the numerous additional trait impls needed to be compatible with `halo2-lib`. See bellow. ### Additional changes - implement `ff::PrimeField` for [Fp](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/fp.rs#L366-L396C2), [Scalar](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/scalar.rs#L723-L752), [Fp2](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/fp2.rs#L625-L680). - implement misc traits for halo2lib compatibility for [Fp](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/fp.rs#L960-L1000), [Scalar](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/scalar.rs#L825-L856), [Fp2](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/fp2.rs#L682-L696) - implement ff::Field for [Fp2](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/fp2.rs#L416-L599C6) including [`sqrt_ratio`](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/fp2.rs#L495-L599C6). - implement `CurveAffine` and `CurveAffineExt` for [G1](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/g1.rs#L491-L539) and [G2](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/g2.rs#L1341-L1388) - switch to LE encoding for [Fp](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/fp.rs#L413-L517), [G1Affine](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/g1.rs#L1198-L1231) and [G2Affine](https://github.com/timoftime/halo2curves/blob/support_bls12-381/src/bls12_381/g2.rs#L1254-L1284) for compatibility with halo2lib - BE encoding is kept in a separate methods to remain compatible with test vectors, and since BE is more commonly used for BLS12 (e.g. Ethereum) - use local `arithmetic.rs` funcs and a `derive` module instead of https://github.com/privacy-scaling-explorations/bls12_381/blob/main/src/util.rs
- Loading branch information