Struct elastic_elgamal::group::Curve25519Subgroup
source · [−]pub struct Curve25519Subgroup(_);
Expand description
Prime-order subgroup of Curve25519 without any transforms performed for EC points.
Since the curve has cofactor 8, ElementOps::deserialize_element()
implementation
explicitly checks on deserializing each EC point that the point is torsion-free
(belongs to the prime-order subgroup), which is moderately slow (takes ~0.1ms on
a laptop).
Prefer using Ristretto
if compatibility with other Curve25519 applications is not a concern.
(If it is a concern, beware of [cofactor pitfalls]!)
Trait Implementations
sourceimpl Clone for Curve25519Subgroup
impl Clone for Curve25519Subgroup
sourcefn clone(&self) -> Curve25519Subgroup
fn clone(&self) -> Curve25519Subgroup
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Curve25519Subgroup
impl Debug for Curve25519Subgroup
sourceimpl ElementOps for Curve25519Subgroup
impl ElementOps for Curve25519Subgroup
type Element = EdwardsPoint
type Element = EdwardsPoint
Element of the group. Arithmetic operations requested here (addition among
elements and multiplication by a Scalar
) must be constant-time. Read more
sourceconst ELEMENT_SIZE: usize = 32usize
const ELEMENT_SIZE: usize = 32usize
Byte size of a serialized Self::Element
.
sourcefn identity() -> Self::Element
fn identity() -> Self::Element
Returns the identity of the group (aka point at infinity for EC groups).
sourcefn is_identity(element: &Self::Element) -> bool
fn is_identity(element: &Self::Element) -> bool
Checks if the specified element is the identity.
sourcefn serialize_element(element: &Self::Element, buffer: &mut [u8])
fn serialize_element(element: &Self::Element, buffer: &mut [u8])
Serializes element
into the provided buffer
, which is guaranteed to have length
Self::ELEMENT_SIZE
. Read more
sourcefn deserialize_element(buffer: &[u8]) -> Option<Self::Element>
fn deserialize_element(buffer: &[u8]) -> Option<Self::Element>
Deserializes an element from buffer
, which is guaranteed to have length
Self::ELEMENT_SIZE
. This method returns None
if the buffer
does not correspond to a representation of a valid scalar. Read more
sourceimpl Group for Curve25519Subgroup
impl Group for Curve25519Subgroup
sourcefn mul_generator(k: &Scalar) -> Self::Element
fn mul_generator(k: &Scalar) -> Self::Element
Multiplies the provided scalar by ElementOps::generator()
. This operation must be
constant-time. Read more
sourcefn vartime_mul_generator(k: &Scalar) -> Self::Element
fn vartime_mul_generator(k: &Scalar) -> Self::Element
Multiplies the provided scalar by ElementOps::generator()
.
Unlike Self::mul_generator()
, this operation does not need to be constant-time;
thus, it may employ additional optimizations. Read more
sourcefn multi_mul<'a, I, J>(scalars: I, elements: J) -> Self::Element where
I: IntoIterator<Item = &'a Self::Scalar>,
J: IntoIterator<Item = Self::Element>,
fn multi_mul<'a, I, J>(scalars: I, elements: J) -> Self::Element where
I: IntoIterator<Item = &'a Self::Scalar>,
J: IntoIterator<Item = Self::Element>,
Multiplies provided scalars
by elements
. This operation must be constant-time
w.r.t. the given length of elements. Read more
sourcefn vartime_double_mul_generator(
k: &Scalar,
k_element: Self::Element,
r: &Scalar
) -> Self::Element
fn vartime_double_mul_generator(
k: &Scalar,
k_element: Self::Element,
r: &Scalar
) -> Self::Element
Calculates k * k_element + r * G
, where G
is the group generator. This operation
does not need to be constant-time. Read more
sourcefn vartime_multi_mul<'a, I, J>(scalars: I, elements: J) -> Self::Element where
I: IntoIterator<Item = &'a Self::Scalar>,
J: IntoIterator<Item = Self::Element>,
fn vartime_multi_mul<'a, I, J>(scalars: I, elements: J) -> Self::Element where
I: IntoIterator<Item = &'a Self::Scalar>,
J: IntoIterator<Item = Self::Element>,
Multiplies provided scalars
by elements
. Unlike Self::multi_mul()
,
this operation does not need to be constant-time; thus, it may employ
additional optimizations. Read more
sourceimpl Hash for Curve25519Subgroup
impl Hash for Curve25519Subgroup
sourceimpl PartialEq<Curve25519Subgroup> for Curve25519Subgroup
impl PartialEq<Curve25519Subgroup> for Curve25519Subgroup
sourcefn eq(&self, other: &Curve25519Subgroup) -> bool
fn eq(&self, other: &Curve25519Subgroup) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Curve25519Subgroup) -> bool
fn ne(&self, other: &Curve25519Subgroup) -> bool
This method tests for !=
.
sourceimpl ScalarOps for Curve25519Subgroup
impl ScalarOps for Curve25519Subgroup
sourceconst SCALAR_SIZE: usize = 32usize
const SCALAR_SIZE: usize = 32usize
Byte size of a serialized Self::Scalar
.
sourcefn generate_scalar<R: CryptoRng + RngCore>(rng: &mut R) -> Self::Scalar
fn generate_scalar<R: CryptoRng + RngCore>(rng: &mut R) -> Self::Scalar
Generates a random scalar based on the provided CSPRNG. This operation must be constant-time. Read more
sourcefn scalar_from_random_bytes(source: RandomBytesProvider<'_>) -> Self::Scalar
fn scalar_from_random_bytes(source: RandomBytesProvider<'_>) -> Self::Scalar
Generates a scalar from a source
of random bytes. This operation must be constant-time.
The source
is guaranteed to return any necessary number of bytes. Read more
sourcefn invert_scalar(scalar: Self::Scalar) -> Self::Scalar
fn invert_scalar(scalar: Self::Scalar) -> Self::Scalar
Inverts the scalar
, which is guaranteed to be non-zero. This operation does not
need to be constant-time. Read more
sourcefn invert_scalars(scalars: &mut [Self::Scalar])
fn invert_scalars(scalars: &mut [Self::Scalar])
Inverts scalars in a batch. This operation does not need to be constant-time. Read more
sourcefn serialize_scalar(scalar: &Self::Scalar, buffer: &mut [u8])
fn serialize_scalar(scalar: &Self::Scalar, buffer: &mut [u8])
Serializes the scalar into the provided buffer
, which is guaranteed to have length
Self::SCALAR_SIZE
. Read more
sourcefn deserialize_scalar(buffer: &[u8]) -> Option<Self::Scalar>
fn deserialize_scalar(buffer: &[u8]) -> Option<Self::Scalar>
Deserializes the scalar from buffer
, which is guaranteed to have length
Self::SCALAR_SIZE
. This method returns None
if the buffer
does not correspond to a representation of a valid scalar. Read more
impl Copy for Curve25519Subgroup
impl Eq for Curve25519Subgroup
impl StructuralEq for Curve25519Subgroup
impl StructuralPartialEq for Curve25519Subgroup
Auto Trait Implementations
impl RefUnwindSafe for Curve25519Subgroup
impl Send for Curve25519Subgroup
impl Sync for Curve25519Subgroup
impl Unpin for Curve25519Subgroup
impl UnwindSafe for Curve25519Subgroup
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more