Merge pull request #13 from zcash/cofactorcurve

impl CofactorCurve for Pallas and Vesta
This commit is contained in:
str4d 2021-06-04 20:24:31 +01:00 committed by GitHub
commit d8547d2326
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 2 deletions

View file

@ -7,5 +7,11 @@ and this project adheres to Rust's notion of
## [Unreleased] ## [Unreleased]
## [0.1.1] - 2021-06-04
## 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 ## [0.1.0] - 2021-06-01
Initial release! Initial release!

View file

@ -1,7 +1,7 @@
[package] [package]
name = "pasta_curves" name = "pasta_curves"
description = "Implementation of the Pallas and Vesta (Pasta) curve cycle" description = "Implementation of the Pallas and Vesta (Pasta) curve cycle"
version = "0.1.0" version = "0.1.1"
authors = [ authors = [
"Sean Bowe <sean@electriccoin.co>", "Sean Bowe <sean@electriccoin.co>",
"Ying Tong Lai <yingtong@electriccoin.co>", "Ying Tong Lai <yingtong@electriccoin.co>",

View file

@ -7,7 +7,7 @@ use core::iter::Sum;
use core::ops::{Add, Mul, Neg, Sub}; use core::ops::{Add, Mul, Neg, Sub};
use ff::Field; use ff::Field;
use group::{ use group::{
cofactor::CofactorGroup, cofactor::{CofactorCurve, CofactorGroup},
prime::{PrimeCurve, PrimeCurveAffine, PrimeGroup}, prime::{PrimeCurve, PrimeCurveAffine, PrimeGroup},
Curve as _, Group as _, GroupEncoding, Curve as _, Group as _, GroupEncoding,
}; };
@ -218,6 +218,10 @@ macro_rules! new_curve_impl {
type Affine = $name_affine; type Affine = $name_affine;
} }
impl CofactorCurve for $name {
type Affine = $name_affine;
}
impl GroupEncoding for $name { impl GroupEncoding for $name {
type Repr = [u8; 32]; 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 { impl GroupEncoding for $name_affine {
type Repr = [u8; 32]; type Repr = [u8; 32];