You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
I'm designing a new "core" for the cryptography in this library, mostly in the interest of performance and flexibility.
Features include:
The library will support multiple BN curve implementations all behind this abstract API. In particular, I plan to integrate a stronger curve construction which should be more secure and more useful for zk-SNARKs.
The user can perform miller loops (with any number of point tuples) manually if they want to avoid unnecessary final exponentiations or redundant ate loops. The Ethereum folks will need to expose all of this functionality in their precompiles if they want to give users maximum performance and flexibility, especially if you need to use newer zk-SNARK schemes or do batch/probablistic verification of proofs.
The user can perform G2 precomputation for the miller loop manually.
Support for mixed addition.
Support for curve point compression (the same way that Zcash compresses proofs).
API preview:
pubtraitField<E:Engine>:Sized +
Eq +
PartialEq +
Copy +
Clone +
Send +
Sync +
Debug +
'static
{fnzero() -> Self;fnone(&E) -> Self;fnrandom<R: rand::Rng>(&E,&mutR) -> Self;fnis_zero(&self) -> bool;fnsquare(&mutself,&E);fndouble(&mutself,&E);fnnegate(&mutself,&E);fnadd_assign(&mutself,&E,other:&Self);fnsub_assign(&mutself,&E,other:&Self);fnmul_assign(&mutself,&E,other:&Self);fninverse(&self,&E) -> Option<Self>;fnsqrt(&self,&E) -> Option<Self>;fnpowi<I:IntoIterator<Item=u64>>(&self,engine:&E,exp:I) -> Self;fnpowb<I:IntoIterator<Item=bool>>(&self,engine:&E,exp:I) -> Self;}pubtraitPrimeField<E:Engine>:Field<E>{typeRepr:AsRef<[u64]>;fnfrom_str(&E,s:&str) -> Result<Self,()>;fnfrom_repr(&E,Self::Repr) -> Result<Self,()>;fninto_repr(&self,&E) -> Self::Repr;}/// A representation of a group element that can be serialized and deserialized,/// but is not guaranteed to be a point on the curve.pubtraitGroupRepresentation<E:Engine,F:Field<E>,G:Group<E,F>>:Copy +
Clone +
Sized +
Send +
Sync +
Debug +
'static
{/// Attempt to parse the representation as an element on/// the curve in the affine.fnto_affine(&self,&E) -> Option<G::Affine>;/// This is like `to_affine` except the caller is/// responsible for ensuring the point is on the curve./// If it isn't, this function is allowed to panic,/// but not guaranteed to.fnto_affine_unchecked(&self,&E) -> G::Affine;}pubtraitGroupAffine<E:Engine,F:Field<E>,G:Group<E,F>>:Copy +
Clone +
Sized +
Send +
Sync +
Debug +
PartialEq +
Eq +
'static
{fnto_jacobian(&self,&E) -> G;fnto_compressed(&self,&E) -> G::Compressed;fnto_uncompressed(&self,&E) -> G::Uncompressed;}pubtraitGroup<E:Engine,F:Field<E>>:Sized +
Eq +
PartialEq +
Copy +
Clone +
Send +
Sync +
Debug +
'static
{typeAffine:GroupAffine<E,F,Self>;typeCompressed:GroupRepresentation<E,F,Self>;typeUncompressed:GroupRepresentation<E,F,Self>;typePrepared:Clone + 'static;fnzero(&E) -> Self;fnone(&E) -> Self;fnrandom<R: rand::Rng>(&E,&mutR) -> Self;fnis_zero(&E) -> Self;fnto_affine(&self,&E) -> Self::Affine;fnprepare(&self,&E) -> Self::Prepared;fndouble(&mutself,&E);fnnegate(&mutself,engine:&E);fnadd_assign(&mutself,&E,other:&Self);fnadd_assign_mixed(&mutself,&E,other:&Self::Affine);fnmul_assign(&mutself,&E,other:&E::Fr);}pubtraitEngine:Sized{typeFq:PrimeField<Self>;typeFr:PrimeField<Self>;typeFqe:Field<Self>;typeFqk:Field<Self>;typeG1:Group<Self,Self::Fq>;typeG2:Group<Self,Self::Fqe>;fnnew() -> Self;fnmiller_loop<'a,I>(&self,I) -> Self::FqkwhereI:IntoIterator<Item=&'a (&'a <Self::G1asGroup<Self,Self::Fq>>::Prepared,&'a <Self::G2asGroup<Self,Self::Fqe>>::Prepared)>;fnfinal_exponentiation(&self,&Self::Fqk) -> Self::Fqk;fnpairing(&self,p:&Self::G1,q:&Self::G2) -> Self::Fqk{self.final_exponentiation(&self.miller_loop([(&p.prepare(self),&q.prepare(self))].into_iter()))}}
The text was updated successfully, but these errors were encountered:
I'm designing a new "core" for the cryptography in this library, mostly in the interest of performance and flexibility.
Features include:
API preview:
The text was updated successfully, but these errors were encountered: