Created
March 24, 2021 16:48
-
-
Save JayKickliter/a61a4732daf7bcb022dca438e95dcea7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl CurveAffine for G1Affine { | |
type Engine = Bls12; | |
type Scalar = Fr; | |
type Base = Fq; | |
type Prepared = G1Prepared; | |
type Projective = G1; | |
type Uncompressed = G1Uncompressed; | |
type Compressed = G1Compressed; | |
type Pair = G2Affine; | |
type PairingResult = Fq12; | |
fn zero() -> Self { | |
G1Affine { | |
x: Fq::zero(), | |
y: Fq::one(), | |
infinity: true, | |
} | |
} | |
fn one() -> Self { | |
Self::get_generator() | |
} | |
fn is_zero(&self) -> bool { | |
self.infinity | |
} | |
fn mul<S: Into<<Self::Scalar as PrimeField>::Repr>>(&self, by: S) -> G1 { | |
let bits = BitIterator::new(by.into()); | |
self.mul_bits(bits) | |
} | |
fn negate(&mut self) { | |
if !self.is_zero() { | |
self.y.negate(); | |
} | |
} | |
fn prepare(&self) -> Self::Prepared { | |
G1Prepared::from_affine(*self) | |
} | |
fn pairing_with(&self, other: &Self::Pair) -> Self::PairingResult { | |
self.perform_pairing(other) | |
} | |
fn into_projective(&self) -> G1 { | |
(*self).into() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment