1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
pub(crate) mod field;
#[cfg(feature = "hash2curve")]
mod hash2curve;
pub(crate) mod scalar;
pub(crate) mod util;
use self::{field::FieldElement, scalar::Scalar};
use crate::NistP256;
use elliptic_curve::{
AffineArithmetic, PrimeCurveArithmetic, ProjectiveArithmetic, ScalarArithmetic,
};
use primeorder::PrimeCurveParams;
pub type AffinePoint = primeorder::AffinePoint<NistP256>;
pub type ProjectivePoint = primeorder::ProjectivePoint<NistP256>;
impl PrimeCurveParams for NistP256 {
type FieldElement = FieldElement;
const ZERO: FieldElement = FieldElement::ZERO;
const ONE: FieldElement = FieldElement::ONE;
const EQUATION_A: FieldElement = FieldElement::ZERO
.sub(&FieldElement::ONE)
.sub(&FieldElement::ONE)
.sub(&FieldElement::ONE);
const EQUATION_B: FieldElement = FieldElement::from_be_hex(
"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
);
const GENERATOR: (FieldElement, FieldElement) = (
FieldElement::from_be_hex(
"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
),
FieldElement::from_be_hex(
"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5",
),
);
}
impl AffineArithmetic for NistP256 {
type AffinePoint = AffinePoint;
}
impl ProjectiveArithmetic for NistP256 {
type ProjectivePoint = ProjectivePoint;
}
impl PrimeCurveArithmetic for NistP256 {
type CurveGroup = ProjectivePoint;
}
impl ScalarArithmetic for NistP256 {
type Scalar = Scalar;
}