pub struct MontgomeryPoint(pub [u8; 32]);
Expand description
Holds the \(u\)-coordinate of a point on the Montgomery form of Curve25519 or its twist.
Tuple Fields§
§0: [u8; 32]
Implementations§
Source§impl MontgomeryPoint
impl MontgomeryPoint
Sourcepub fn mul_base(scalar: &Scalar) -> Self
pub fn mul_base(scalar: &Scalar) -> Self
Fixed-base scalar multiplication (i.e. multiplication by the base point).
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
.
Sourcepub fn mul_bits_be(&self, bits: impl Iterator<Item = bool>) -> MontgomeryPoint
pub fn mul_bits_be(&self, bits: impl Iterator<Item = bool>) -> MontgomeryPoint
Given self
\( = u_0(P) \), and a big-endian bit representation of an integer
\(n\), return \( u_0([n]P) \). This is constant time in the length of bits
.
NOTE: You probably do not want to use this function. Almost every protocol built on
Curve25519 uses clamped multiplication, explained
here.
When in doubt, use Self::mul_clamped
.
Sourcepub fn to_edwards(&self, sign: u8) -> Option<EdwardsPoint>
pub fn to_edwards(&self, sign: u8) -> Option<EdwardsPoint>
Attempt to convert to an EdwardsPoint
, using the supplied
choice of sign for the EdwardsPoint
.
§Inputs
sign
: au8
donating the desired sign of the resultingEdwardsPoint
.0
denotes positive and1
negative.
§Return
-
Some(EdwardsPoint)
ifself
is the \(u\)-coordinate of a point on (the Montgomery form of) Curve25519; -
None
ifself
is the \(u\)-coordinate of a point on the twist of (the Montgomery form of) Curve25519;
Trait Implementations§
Source§impl Clone for MontgomeryPoint
impl Clone for MontgomeryPoint
Source§fn clone(&self) -> MontgomeryPoint
fn clone(&self) -> MontgomeryPoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl ConstantTimeEq for MontgomeryPoint
Equality of MontgomeryPoint
s is defined mod p.
impl ConstantTimeEq for MontgomeryPoint
Equality of MontgomeryPoint
s is defined mod p.
Source§impl Debug for MontgomeryPoint
impl Debug for MontgomeryPoint
Source§impl Default for MontgomeryPoint
impl Default for MontgomeryPoint
Source§fn default() -> MontgomeryPoint
fn default() -> MontgomeryPoint
Source§impl<'de> Deserialize<'de> for MontgomeryPoint
impl<'de> Deserialize<'de> for MontgomeryPoint
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 Hash for MontgomeryPoint
impl Hash for MontgomeryPoint
Source§impl Identity for MontgomeryPoint
impl Identity for MontgomeryPoint
Source§fn identity() -> MontgomeryPoint
fn identity() -> MontgomeryPoint
Return the group identity element, which has order 4.
Source§impl Mul<&MontgomeryPoint> for &Scalar
impl Mul<&MontgomeryPoint> for &Scalar
Source§type Output = MontgomeryPoint
type Output = MontgomeryPoint
*
operator.Source§fn mul(self, point: &MontgomeryPoint) -> MontgomeryPoint
fn mul(self, point: &MontgomeryPoint) -> MontgomeryPoint
*
operation. Read moreSource§impl<'b> Mul<&'b MontgomeryPoint> for Scalar
impl<'b> Mul<&'b MontgomeryPoint> for Scalar
Source§type Output = MontgomeryPoint
type Output = MontgomeryPoint
*
operator.Source§fn mul(self, rhs: &'b MontgomeryPoint) -> MontgomeryPoint
fn mul(self, rhs: &'b MontgomeryPoint) -> MontgomeryPoint
*
operation. Read moreSource§impl Mul<&Scalar> for &MontgomeryPoint
Multiply this MontgomeryPoint
by a Scalar
.
impl Mul<&Scalar> for &MontgomeryPoint
Multiply this MontgomeryPoint
by a Scalar
.
Source§fn mul(self, scalar: &Scalar) -> MontgomeryPoint
fn mul(self, scalar: &Scalar) -> MontgomeryPoint
Given self
\( = u_0(P) \), and a Scalar
\(n\), return \( u_0([n]P) \)
Source§type Output = MontgomeryPoint
type Output = MontgomeryPoint
*
operator.Source§impl<'b> Mul<&'b Scalar> for MontgomeryPoint
impl<'b> Mul<&'b Scalar> for MontgomeryPoint
Source§type Output = MontgomeryPoint
type Output = MontgomeryPoint
*
operator.Source§impl<'a> Mul<MontgomeryPoint> for &'a Scalar
impl<'a> Mul<MontgomeryPoint> for &'a Scalar
Source§type Output = MontgomeryPoint
type Output = MontgomeryPoint
*
operator.Source§fn mul(self, rhs: MontgomeryPoint) -> MontgomeryPoint
fn mul(self, rhs: MontgomeryPoint) -> MontgomeryPoint
*
operation. Read moreSource§impl Mul<MontgomeryPoint> for Scalar
impl Mul<MontgomeryPoint> for Scalar
Source§type Output = MontgomeryPoint
type Output = MontgomeryPoint
*
operator.Source§fn mul(self, rhs: MontgomeryPoint) -> MontgomeryPoint
fn mul(self, rhs: MontgomeryPoint) -> MontgomeryPoint
*
operation. Read moreSource§impl<'a> Mul<Scalar> for &'a MontgomeryPoint
impl<'a> Mul<Scalar> for &'a MontgomeryPoint
Source§type Output = MontgomeryPoint
type Output = MontgomeryPoint
*
operator.Source§impl Mul<Scalar> for MontgomeryPoint
impl Mul<Scalar> for MontgomeryPoint
Source§type Output = MontgomeryPoint
type Output = MontgomeryPoint
*
operator.Source§impl MulAssign<&Scalar> for MontgomeryPoint
impl MulAssign<&Scalar> for MontgomeryPoint
Source§fn mul_assign(&mut self, scalar: &Scalar)
fn mul_assign(&mut self, scalar: &Scalar)
*=
operation. Read moreSource§impl MulAssign<Scalar> for MontgomeryPoint
impl MulAssign<Scalar> for MontgomeryPoint
Source§fn mul_assign(&mut self, rhs: Scalar)
fn mul_assign(&mut self, rhs: Scalar)
*=
operation. Read more