Skip to content

Instantly share code, notes, and snippets.

@JayKickliter
Created March 24, 2021 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayKickliter/a61a4732daf7bcb022dca438e95dcea7 to your computer and use it in GitHub Desktop.
Save JayKickliter/a61a4732daf7bcb022dca438e95dcea7 to your computer and use it in GitHub Desktop.
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