Closed DrPeterVanNostrand closed 4 years ago
Not needed anymore, we are now using blstrs
and paired
, with the goal to merge them into a single implementation at some point. We might consider updating our APIs there to match bls12-381
but this will be work happening there first.
Description
Currently we depend on filecoin's fork of
pairing
, it would be ideal to switch that dependency to thebls12-381
crate. Thebls12-381
crate refactors out thebls12_381
module frompairing
and makes some improvements to the API which are currently using.It would be ideal to switch this dependency for the following reasons:
bls12-381
has a much better API (types from abstract algebra are now named how you would see them in cryptography papers), which makes the code much easier to readpairing
andff
), which makes the code much easier to read and modifybls12-381
,jubjub
,group
, any improvements that they make will be added to these crates and (probably) not topairing
.Things that have not (as of today) changed from
pairing
tobls12-381
:Why we can't switch today
We use Zcash's
sapling-crypto
crate which depends onpairing
. Sapling has not yet been ported to using the newbls12-381
crate. Some of the functionality that we rely on has been refactored out ofsapling-crypto
into the cratejubjub
, but this refactor does not include every part of Sapling that we depend on (mainly Pedersen hash, params, and circuit).Notes for when switching from
pairing
tobls12-381
The the two crates are almost identical except for:
Fr
inpairing
) for the Bls12-381 curve group are now calledScalar
inbls12-381
. TheFrRepr
type has been completely removed :)Fq
inpairing
) are now calledFp
inbls12-381
Fq2
,Fq6
, andFq12
inpairing
) are now calledFp2
,Fp6
, andFp12
bls12-381
now default to constant time (and return constant-timesubtle
wrapper types for booleans and options - this is fine as these wrapper types can be converted into their Rust primitives).pairing
, i.e. the bytes and limbs that you pass in to create a scalar, or read out, are little endian), howeverbls12-381
now big-endian encodes base field elements (which were little-endian inpairing
).