Skip to content

Commit 8fe002e

Browse files
committed
p256+p384: define CurveEquationAProperties
1 parent 1741bac commit 8fe002e

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

p256/src/arithmetic.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::NistP256;
1111
use elliptic_curve::{
1212
AffineArithmetic, PrimeCurveArithmetic, ProjectiveArithmetic, ScalarArithmetic,
1313
};
14-
use primeorder::PrimeCurveParams;
14+
use primeorder::{CurveEquationAIsMinusThree, PrimeCurveParams};
1515

1616
/// Elliptic curve point in affine coordinates.
1717
pub type AffinePoint = primeorder::AffinePoint<NistP256>;
@@ -21,6 +21,7 @@ pub type ProjectivePoint = primeorder::ProjectivePoint<NistP256>;
2121

2222
impl PrimeCurveParams for NistP256 {
2323
type FieldElement = FieldElement;
24+
type CurveEquationAProperties = CurveEquationAIsMinusThree;
2425

2526
const ZERO: FieldElement = FieldElement::ZERO;
2627
const ONE: FieldElement = FieldElement::ONE;

p256/tests/projective.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use elliptic_curve::{
88
};
99
use p256::test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS};
1010
use p256::{AffinePoint, ProjectivePoint, Scalar};
11+
use primeorder::Double;
1112

1213
/// Assert that the provided projective point matches the given test vector.
1314
// TODO(tarcieri): use coordinate APIs. See zkcrypto/group#30

p384/src/arithmetic.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::NistP384;
1616
use elliptic_curve::{
1717
AffineArithmetic, PrimeCurveArithmetic, ProjectiveArithmetic, ScalarArithmetic,
1818
};
19-
use primeorder::PrimeCurveParams;
19+
use primeorder::{CurveEquationAIsMinusThree, PrimeCurveParams};
2020

2121
/// Elliptic curve point in affine coordinates.
2222
pub type AffinePoint = primeorder::AffinePoint<NistP384>;
@@ -26,6 +26,7 @@ pub type ProjectivePoint = primeorder::ProjectivePoint<NistP384>;
2626

2727
impl PrimeCurveParams for NistP384 {
2828
type FieldElement = FieldElement;
29+
type CurveEquationAProperties = CurveEquationAIsMinusThree;
2930

3031
const ZERO: FieldElement = FieldElement::ZERO;
3132
const ONE: FieldElement = FieldElement::ONE;

p384/tests/projective.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use p384::{
1010
test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS},
1111
AffinePoint, ProjectivePoint, Scalar,
1212
};
13+
use primeorder::Double;
1314

1415
/// Assert that the provided projective point matches the given test vector.
1516
// TODO(tarcieri): use coordinate APIs. See zkcrypto/group#30

primeorder/src/projective.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,10 @@ impl<C> Double for ProjectivePoint<C>
205205
where
206206
C: PrimeCurveParams<CurveEquationAProperties = CurveEquationAIsMinusThree>,
207207
{
208-
/// We implement the exception-free point doubling formula from
209-
/// Renes-Costello-Batina 2015 (Algorithm 6), for prime order short
210-
/// Weierstrass curves `y² = x³ + ax + b` where `a = -3`.
208+
/// Adapted from Renes-Costello-Batina 2015 (Algorithm 6)
209+
///
210+
/// Exception-free point doubling formula for prime order short Weierstrass
211+
/// curves `y² = x³ + ax + b` where `a = -3`.
211212
///
212213
/// The comments after each lines indicate which algorithm steps
213214
/// are being performed.

0 commit comments

Comments
 (0)