Merge pull request #223 from zcash/cofactor-group

impl group::cofactor::CofactorGroup for Pallas and Vesta
This commit is contained in:
ebfull 2021-03-02 08:32:28 -07:00 committed by GitHub
commit 8122ef3d5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ use core::iter::Sum;
use core::ops::{Add, Mul, Neg, Sub};
use ff::Field;
use group::{
cofactor::CofactorGroup,
prime::{PrimeCurve, PrimeCurveAffine, PrimeGroup},
Curve as _, Group as _, GroupEncoding,
};
@ -186,6 +187,25 @@ macro_rules! new_curve_impl {
impl PrimeGroup for $name {}
impl CofactorGroup for $name {
type Subgroup = $name;
fn clear_cofactor(&self) -> Self {
// This is a prime-order group, with a cofactor of 1.
*self
}
fn into_subgroup(self) -> CtOption<Self::Subgroup> {
// Nothing to do here.
CtOption::new(self, 1.into())
}
fn is_torsion_free(&self) -> Choice {
// Shortcut: all points in a prime-order group are torsion free.
1.into()
}
}
impl PrimeCurve for $name {
type Affine = $name_affine;
}