pub struct EdwardsCurve<F: FieldOps> {
pub d1: F,
pub d2: F,
}Expand description
An Edwards curve over a field F, covering both odd and even characteristic.
In odd characteristic only d2 is used (the parameter d).
In characteristic 2 both d1 and d2 are used.
Fields§
§d1: FThe invariant d1 in the equation
d2: FThe invariant d2 in the equation
Implementations§
Source§impl<F: FieldOps + FieldRandom> EdwardsCurve<F>
impl<F: FieldOps + FieldRandom> EdwardsCurve<F>
Sourcepub fn new(d: F) -> Self
pub fn new(d: F) -> Self
Construct an odd-characteristic Edwards curve x² + y² = 1 + d·x²·y².
Stores d as d2; d1 is set to zero (unused).
Examples found in repository?
examples/ec_demo.rs (line 54)
41fn main() {
42 let mut rng = rand::rng();
43 // 1. Short Weierstrass over F_19: y^2 = x^3 + 2x + 3
44 let w = WeierstrassCurve::new_short(fp(2), fp(3));
45 show_curve("Weierstrass", &w, &mut rng);
46
47 // 2. Montgomery over F_19: B y^2 = x(x^2 + A x + 1)
48 // Smooth if B != 0 and A != ±2 in odd characteristic.
49 let m = MontgomeryCurve::new(fp(3), fp(1));
50 show_curve("Montgomery", &m, &mut rng);
51
52 // 3. Edwards over F_19: x^2 + y^2 = 1 + d x^2 y^2
53 // Pick d = 2 (nonzero, not 1; also a nonsquare in F_19).
54 let e = EdwardsCurve::new(fp(2));
55 show_curve("Edwards", &e, &mut rng);
56
57 // 4. Jacobi quartic over F_19: y^2 = d x^4 + 2 a x^2 + 1
58 // Need d != 0 and a^2 != d.
59 let jq = JacobiQuarticCurve::new(fp(3), fp(5));
60 show_curve("Jacobi quartic", &jq, &mut rng);
61
62 // 5. Jacobi intersection over F_19:
63 // s^2 + c^2 = 1, a s^2 + d^2 = 1
64 // Need a != 0, 1.
65 let ji = JacobiIntersectionCurve::new(fp(2));
66 show_curve("Jacobi intersection", &ji, &mut rng);
67}Sourcepub fn new_binary(d1: F, d2: F) -> Self
pub fn new_binary(d1: F, d2: F) -> Self
Construct a binary Edwards curve
d₁(x+y) + d₂(x²+y²) = xy + xy(x+y) + x²y².
Sourcepub fn contains(&self, x: &F, y: &F) -> bool
pub fn contains(&self, x: &F, y: &F) -> bool
Check whether the affine point (x, y) lies on the curve.
Sourcepub fn random_point(&self, rng: &mut (impl CryptoRng + Rng)) -> EdwardsPoint<F>
pub fn random_point(&self, rng: &mut (impl CryptoRng + Rng)) -> EdwardsPoint<F>
Sample a random affine point on this Edwards curve using the provided RNG.
This currently uses a square-root-based construction and is implemented
only for odd characteristic. It returns a point P such that
self.is_on_curve(&P) holds.
Trait Implementations§
Source§impl<F: Clone + FieldOps> Clone for EdwardsCurve<F>
impl<F: Clone + FieldOps> Clone for EdwardsCurve<F>
Source§fn clone(&self) -> EdwardsCurve<F>
fn clone(&self) -> EdwardsCurve<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F: FieldOps + FieldRandom> Curve for EdwardsCurve<F>
impl<F: FieldOps + FieldRandom> Curve for EdwardsCurve<F>
Source§type Point = EdwardsPoint<F>
type Point = EdwardsPoint<F>
Native point representation for this curve model.
Source§fn is_on_curve(&self, point: &Self::Point) -> bool
fn is_on_curve(&self, point: &Self::Point) -> bool
Return
true if point is a valid point on this curve.Source§fn random_point(&self, rng: &mut (impl CryptoRng + Rng)) -> Self::Point
fn random_point(&self, rng: &mut (impl CryptoRng + Rng)) -> Self::Point
Return a random point that is on the curve.
Source§fn j_invariant(&self) -> F
fn j_invariant(&self) -> F
Return the j_invariant of the curve;
Source§impl<F> Display for EdwardsCurve<F>
impl<F> Display for EdwardsCurve<F>
impl<F: Eq + FieldOps> Eq for EdwardsCurve<F>
impl<F: FieldOps> StructuralPartialEq for EdwardsCurve<F>
Auto Trait Implementations§
impl<F> Freeze for EdwardsCurve<F>where
F: Freeze,
impl<F> RefUnwindSafe for EdwardsCurve<F>where
F: RefUnwindSafe,
impl<F> Send for EdwardsCurve<F>where
F: Send,
impl<F> Sync for EdwardsCurve<F>where
F: Sync,
impl<F> Unpin for EdwardsCurve<F>where
F: Unpin,
impl<F> UnsafeUnpin for EdwardsCurve<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for EdwardsCurve<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more