pub struct EdwardsPoint { /* private fields */ }
Expand description
An EdwardsPoint
represents a point on the Edwards form of Curve25519.
Implementations§
Source§impl EdwardsPoint
impl EdwardsPoint
Sourcepub fn to_montgomery(&self) -> MontgomeryPoint
pub fn to_montgomery(&self) -> MontgomeryPoint
Convert this EdwardsPoint
on the Edwards model to the
corresponding MontgomeryPoint
on the Montgomery model.
This function has one exceptional case; the identity point of the Edwards curve is sent to the 2-torsion point \((0,0)\) on the Montgomery curve.
Note that this is a one-way conversion, since the Montgomery model does not retain sign information.
Sourcepub fn compress(&self) -> CompressedEdwardsY
pub fn compress(&self) -> CompressedEdwardsY
Compress this point to CompressedEdwardsY
format.
Sourcepub fn nonspec_map_to_curve<D>(bytes: &[u8]) -> EdwardsPoint
👎Deprecated since 4.0.0: previously named hash_from_bytes
, this is not a secure hash function
pub fn nonspec_map_to_curve<D>(bytes: &[u8]) -> EdwardsPoint
hash_from_bytes
, this is not a secure hash functionMaps the digest of the input bytes to the curve. This is NOT a hash-to-curve function, as
it produces points with a non-uniform distribution. Rather, it performs something that
resembles (but is not) half of the
hash_to_curve
function from the Elligator2 spec.
Source§impl EdwardsPoint
impl EdwardsPoint
Sourcepub fn mul_base(scalar: &Scalar) -> Self
pub fn mul_base(scalar: &Scalar) -> Self
Fixed-base scalar multiplication by the Ed25519 base point.
Uses precomputed basepoint tables when the precomputed-tables
feature
is enabled, trading off increased code size for ~4x better performance.
Sourcepub fn mul_clamped(self, bytes: [u8; 32]) -> Self
pub fn mul_clamped(self, bytes: [u8; 32]) -> Self
Multiply this point by clamp_integer(bytes)
. For a description of clamping, see
clamp_integer
.
Sourcepub fn mul_base_clamped(bytes: [u8; 32]) -> Self
pub fn mul_base_clamped(bytes: [u8; 32]) -> Self
Multiply the basepoint by clamp_integer(bytes)
. For a description of clamping, see
clamp_integer
.
Source§impl EdwardsPoint
impl EdwardsPoint
Sourcepub fn vartime_double_scalar_mul_basepoint(
a: &Scalar,
A: &EdwardsPoint,
b: &Scalar,
) -> EdwardsPoint
pub fn vartime_double_scalar_mul_basepoint( a: &Scalar, A: &EdwardsPoint, b: &Scalar, ) -> EdwardsPoint
Compute \(aA + bB\) in variable time, where \(B\) is the Ed25519 basepoint.
Source§impl EdwardsPoint
impl EdwardsPoint
Sourcepub fn mul_by_cofactor(&self) -> EdwardsPoint
pub fn mul_by_cofactor(&self) -> EdwardsPoint
Multiply by the cofactor: return \([8]P\).
Sourcepub fn is_small_order(&self) -> bool
pub fn is_small_order(&self) -> bool
Determine if this point is of small order.
§Return
true
ifself
is in the torsion subgroup \( \mathcal E[8] \);false
ifself
is not in the torsion subgroup \( \mathcal E[8] \).
§Example
use curve25519_dalek::constants;
// Generator of the prime-order subgroup
let P = constants::ED25519_BASEPOINT_POINT;
// Generator of the torsion subgroup
let Q = constants::EIGHT_TORSION[1];
// P has large order
assert_eq!(P.is_small_order(), false);
// Q has small order
assert_eq!(Q.is_small_order(), true);
Sourcepub fn is_torsion_free(&self) -> bool
pub fn is_torsion_free(&self) -> bool
Determine if this point is “torsion-free”, i.e., is contained in the prime-order subgroup.
§Return
true
ifself
has zero torsion component and is in the prime-order subgroup;false
ifself
has a nonzero torsion component and is not in the prime-order subgroup.
§Example
use curve25519_dalek::constants;
// Generator of the prime-order subgroup
let P = constants::ED25519_BASEPOINT_POINT;
// Generator of the torsion subgroup
let Q = constants::EIGHT_TORSION[1];
// P is torsion-free
assert_eq!(P.is_torsion_free(), true);
// P + Q is not torsion-free
assert_eq!((P+Q).is_torsion_free(), false);
Trait Implementations§
Source§impl<'a, 'b> Add<&'b EdwardsPoint> for &'a EdwardsPoint
impl<'a, 'b> Add<&'b EdwardsPoint> for &'a EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
+
operator.Source§fn add(self, other: &'b EdwardsPoint) -> EdwardsPoint
fn add(self, other: &'b EdwardsPoint) -> EdwardsPoint
+
operation. Read moreSource§impl<'b> Add<&'b EdwardsPoint> for EdwardsPoint
impl<'b> Add<&'b EdwardsPoint> for EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
+
operator.Source§fn add(self, rhs: &'b EdwardsPoint) -> EdwardsPoint
fn add(self, rhs: &'b EdwardsPoint) -> EdwardsPoint
+
operation. Read moreSource§impl<'a> Add<EdwardsPoint> for &'a EdwardsPoint
impl<'a> Add<EdwardsPoint> for &'a EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
+
operator.Source§fn add(self, rhs: EdwardsPoint) -> EdwardsPoint
fn add(self, rhs: EdwardsPoint) -> EdwardsPoint
+
operation. Read moreSource§impl Add for EdwardsPoint
impl Add for EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
+
operator.Source§fn add(self, rhs: EdwardsPoint) -> EdwardsPoint
fn add(self, rhs: EdwardsPoint) -> EdwardsPoint
+
operation. Read moreSource§impl<'b> AddAssign<&'b EdwardsPoint> for EdwardsPoint
impl<'b> AddAssign<&'b EdwardsPoint> for EdwardsPoint
Source§fn add_assign(&mut self, _rhs: &'b EdwardsPoint)
fn add_assign(&mut self, _rhs: &'b EdwardsPoint)
+=
operation. Read moreSource§impl AddAssign for EdwardsPoint
impl AddAssign for EdwardsPoint
Source§fn add_assign(&mut self, rhs: EdwardsPoint)
fn add_assign(&mut self, rhs: EdwardsPoint)
+=
operation. Read moreSource§impl Clone for EdwardsPoint
impl Clone for EdwardsPoint
Source§fn clone(&self) -> EdwardsPoint
fn clone(&self) -> EdwardsPoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl ConditionallySelectable for EdwardsPoint
impl ConditionallySelectable for EdwardsPoint
Source§fn conditional_select(
a: &EdwardsPoint,
b: &EdwardsPoint,
choice: Choice,
) -> EdwardsPoint
fn conditional_select( a: &EdwardsPoint, b: &EdwardsPoint, choice: Choice, ) -> EdwardsPoint
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
self
and other
if choice == 1
; otherwise,
reassign both unto themselves. Read moreSource§impl ConstantTimeEq for EdwardsPoint
impl ConstantTimeEq for EdwardsPoint
Source§impl Debug for EdwardsPoint
impl Debug for EdwardsPoint
Source§impl Default for EdwardsPoint
impl Default for EdwardsPoint
Source§fn default() -> EdwardsPoint
fn default() -> EdwardsPoint
Source§impl<'de> Deserialize<'de> for EdwardsPoint
impl<'de> Deserialize<'de> for EdwardsPoint
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Identity for EdwardsPoint
impl Identity for EdwardsPoint
Source§fn identity() -> EdwardsPoint
fn identity() -> EdwardsPoint
Source§impl<'a, 'b> Mul<&'b EdwardsPoint> for &'a Scalar
impl<'a, 'b> Mul<&'b EdwardsPoint> for &'a Scalar
Source§fn mul(self, point: &'b EdwardsPoint) -> EdwardsPoint
fn mul(self, point: &'b EdwardsPoint) -> EdwardsPoint
Scalar multiplication: compute scalar * self
.
For scalar multiplication of a basepoint,
EdwardsBasepointTable
is approximately 4x faster.
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
*
operator.Source§impl<'b> Mul<&'b EdwardsPoint> for Scalar
impl<'b> Mul<&'b EdwardsPoint> for Scalar
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
*
operator.Source§fn mul(self, rhs: &'b EdwardsPoint) -> EdwardsPoint
fn mul(self, rhs: &'b EdwardsPoint) -> EdwardsPoint
*
operation. Read moreSource§impl<'a, 'b> Mul<&'b Scalar> for &'a EdwardsPoint
impl<'a, 'b> Mul<&'b Scalar> for &'a EdwardsPoint
Source§fn mul(self, scalar: &'b Scalar) -> EdwardsPoint
fn mul(self, scalar: &'b Scalar) -> EdwardsPoint
Scalar multiplication: compute scalar * self
.
For scalar multiplication of a basepoint,
EdwardsBasepointTable
is approximately 4x faster.
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
*
operator.Source§impl<'b> Mul<&'b Scalar> for EdwardsPoint
impl<'b> Mul<&'b Scalar> for EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
*
operator.Source§impl<'a> Mul<EdwardsPoint> for &'a Scalar
impl<'a> Mul<EdwardsPoint> for &'a Scalar
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
*
operator.Source§fn mul(self, rhs: EdwardsPoint) -> EdwardsPoint
fn mul(self, rhs: EdwardsPoint) -> EdwardsPoint
*
operation. Read moreSource§impl Mul<EdwardsPoint> for Scalar
impl Mul<EdwardsPoint> for Scalar
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
*
operator.Source§fn mul(self, rhs: EdwardsPoint) -> EdwardsPoint
fn mul(self, rhs: EdwardsPoint) -> EdwardsPoint
*
operation. Read moreSource§impl<'a> Mul<Scalar> for &'a EdwardsPoint
impl<'a> Mul<Scalar> for &'a EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
*
operator.Source§impl Mul<Scalar> for EdwardsPoint
impl Mul<Scalar> for EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
*
operator.Source§impl<'b> MulAssign<&'b Scalar> for EdwardsPoint
impl<'b> MulAssign<&'b Scalar> for EdwardsPoint
Source§fn mul_assign(&mut self, scalar: &'b Scalar)
fn mul_assign(&mut self, scalar: &'b Scalar)
*=
operation. Read moreSource§impl MulAssign<Scalar> for EdwardsPoint
impl MulAssign<Scalar> for EdwardsPoint
Source§fn mul_assign(&mut self, rhs: Scalar)
fn mul_assign(&mut self, rhs: Scalar)
*=
operation. Read moreSource§impl MultiscalarMul for EdwardsPoint
impl MultiscalarMul for EdwardsPoint
Source§type Point = EdwardsPoint
type Point = EdwardsPoint
RistrettoPoint
.Source§fn multiscalar_mul<I, J>(scalars: I, points: J) -> EdwardsPoint
fn multiscalar_mul<I, J>(scalars: I, points: J) -> EdwardsPoint
Source§impl<'a> Neg for &'a EdwardsPoint
impl<'a> Neg for &'a EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
-
operator.Source§fn neg(self) -> EdwardsPoint
fn neg(self) -> EdwardsPoint
-
operation. Read moreSource§impl Neg for EdwardsPoint
impl Neg for EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
-
operator.Source§fn neg(self) -> EdwardsPoint
fn neg(self) -> EdwardsPoint
-
operation. Read moreSource§impl PartialEq for EdwardsPoint
impl PartialEq for EdwardsPoint
Source§impl Serialize for EdwardsPoint
impl Serialize for EdwardsPoint
Source§impl<'a, 'b> Sub<&'b EdwardsPoint> for &'a EdwardsPoint
impl<'a, 'b> Sub<&'b EdwardsPoint> for &'a EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
-
operator.Source§fn sub(self, other: &'b EdwardsPoint) -> EdwardsPoint
fn sub(self, other: &'b EdwardsPoint) -> EdwardsPoint
-
operation. Read moreSource§impl<'b> Sub<&'b EdwardsPoint> for EdwardsPoint
impl<'b> Sub<&'b EdwardsPoint> for EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
-
operator.Source§fn sub(self, rhs: &'b EdwardsPoint) -> EdwardsPoint
fn sub(self, rhs: &'b EdwardsPoint) -> EdwardsPoint
-
operation. Read moreSource§impl<'a> Sub<EdwardsPoint> for &'a EdwardsPoint
impl<'a> Sub<EdwardsPoint> for &'a EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
-
operator.Source§fn sub(self, rhs: EdwardsPoint) -> EdwardsPoint
fn sub(self, rhs: EdwardsPoint) -> EdwardsPoint
-
operation. Read moreSource§impl Sub for EdwardsPoint
impl Sub for EdwardsPoint
Source§type Output = EdwardsPoint
type Output = EdwardsPoint
-
operator.Source§fn sub(self, rhs: EdwardsPoint) -> EdwardsPoint
fn sub(self, rhs: EdwardsPoint) -> EdwardsPoint
-
operation. Read moreSource§impl<'b> SubAssign<&'b EdwardsPoint> for EdwardsPoint
impl<'b> SubAssign<&'b EdwardsPoint> for EdwardsPoint
Source§fn sub_assign(&mut self, _rhs: &'b EdwardsPoint)
fn sub_assign(&mut self, _rhs: &'b EdwardsPoint)
-=
operation. Read moreSource§impl SubAssign for EdwardsPoint
impl SubAssign for EdwardsPoint
Source§fn sub_assign(&mut self, rhs: EdwardsPoint)
fn sub_assign(&mut self, rhs: EdwardsPoint)
-=
operation. Read moreSource§impl<T> Sum<T> for EdwardsPointwhere
T: Borrow<EdwardsPoint>,
impl<T> Sum<T> for EdwardsPointwhere
T: Borrow<EdwardsPoint>,
Source§impl VartimeMultiscalarMul for EdwardsPoint
impl VartimeMultiscalarMul for EdwardsPoint
Source§type Point = EdwardsPoint
type Point = EdwardsPoint
RistrettoPoint
.Source§fn optional_multiscalar_mul<I, J>(scalars: I, points: J) -> Option<EdwardsPoint>
fn optional_multiscalar_mul<I, J>(scalars: I, points: J) -> Option<EdwardsPoint>
Option
s of points, compute either Some(Q)
, where
$$
Q = c_1 P_1 + \cdots + c_n P_n,
$$
if all points were Some(P_i)
, or else return None
. Read more