mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +00:00
Merge pull request #223 from zcash/cofactor-group
impl group::cofactor::CofactorGroup for Pallas and Vesta
This commit is contained in:
commit
8122ef3d5d
1 changed files with 20 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue