mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +00:00
impl CofactorCurve for Pallas and Vesta
They already implement CofactorGroup (trivially, with the prime-order subgroup being Self); this just enables Pallas and Vesta to be used in cofactor-aware protocols that also want to leverage the affine point representation.
This commit is contained in:
parent
93df9c0cb9
commit
a6b018fb0e
2 changed files with 30 additions and 1 deletions
|
|
@ -6,6 +6,10 @@ and this project adheres to Rust's notion of
|
|||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
## Added
|
||||
- Implementations of `group::cofactor::{CofactorCurve, CofactorCurveAffine}` for
|
||||
Pallas and Vesta, enabling them to be used in cofactor-aware protocols that
|
||||
also want to leverage the affine point representation.
|
||||
|
||||
## [0.1.0] - 2021-06-01
|
||||
Initial release!
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use core::iter::Sum;
|
|||
use core::ops::{Add, Mul, Neg, Sub};
|
||||
use ff::Field;
|
||||
use group::{
|
||||
cofactor::CofactorGroup,
|
||||
cofactor::{CofactorCurve, CofactorGroup},
|
||||
prime::{PrimeCurve, PrimeCurveAffine, PrimeGroup},
|
||||
Curve as _, Group as _, GroupEncoding,
|
||||
};
|
||||
|
|
@ -218,6 +218,10 @@ macro_rules! new_curve_impl {
|
|||
type Affine = $name_affine;
|
||||
}
|
||||
|
||||
impl CofactorCurve for $name {
|
||||
type Affine = $name_affine;
|
||||
}
|
||||
|
||||
impl GroupEncoding for $name {
|
||||
type Repr = [u8; 32];
|
||||
|
||||
|
|
@ -594,6 +598,27 @@ macro_rules! new_curve_impl {
|
|||
}
|
||||
}
|
||||
|
||||
impl group::cofactor::CofactorCurveAffine for $name_affine {
|
||||
type Curve = $name;
|
||||
type Scalar = $scalar;
|
||||
|
||||
fn identity() -> Self {
|
||||
<Self as PrimeCurveAffine>::identity()
|
||||
}
|
||||
|
||||
fn generator() -> Self {
|
||||
<Self as PrimeCurveAffine>::generator()
|
||||
}
|
||||
|
||||
fn is_identity(&self) -> Choice {
|
||||
<Self as PrimeCurveAffine>::is_identity(self)
|
||||
}
|
||||
|
||||
fn to_curve(&self) -> Self::Curve {
|
||||
<Self as PrimeCurveAffine>::to_curve(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl GroupEncoding for $name_affine {
|
||||
type Repr = [u8; 32];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue