[−][src]Struct curve25519_dalek::ristretto::RistrettoPoint
A RistrettoPoint
represents a point in the Ristretto group for
Curve25519. Ristretto, a variant of Decaf, constructs a
prime-order group as a quotient group of a subgroup of (the
Edwards form of) Curve25519.
Internally, a RistrettoPoint
is implemented as a wrapper type
around EdwardsPoint
, with custom equality, compression, and
decompression routines to account for the quotient. This means that
operations on RistrettoPoint
s are exactly as fast as operations on
EdwardsPoint
s.
Methods
impl RistrettoPoint
[src]
pub fn compress(&self) -> CompressedRistretto
[src]
Compress this point using the Ristretto encoding.
pub fn double_and_compress_batch<'a, I>(points: I) -> Vec<CompressedRistretto> where
I: IntoIterator<Item = &'a RistrettoPoint>,
[src]
I: IntoIterator<Item = &'a RistrettoPoint>,
Double-and-compress a batch of points. The Ristretto encoding is not batchable, since it requires an inverse square root.
However, given input points \( P_1, \ldots, P_n, \) it is possible to compute the encodings of their doubles \( \mathrm{enc}( [2]P_1), \ldots, \mathrm{enc}( [2]P_n ) \) in a batch.
extern crate rand_os; use rand_os::OsRng; let mut rng = OsRng::new().unwrap(); let points: Vec<RistrettoPoint> = (0..32).map(|_| RistrettoPoint::random(&mut rng)).collect(); let compressed = RistrettoPoint::double_and_compress_batch(&points); for (P, P2_compressed) in points.iter().zip(compressed.iter()) { assert_eq!(*P2_compressed, (P + P).compress()); }
pub fn random<T: RngCore + CryptoRng>(rng: T) -> Self
[src]
Return a RistrettoPoint
chosen uniformly at random using a user-provided RNG.
Inputs
rng
: any RNG which implements theRngCore + CryptoRng
interface.
Returns
A random element of the Ristretto group.
Implementation
Uses the Ristretto-flavoured Elligator 2 map, so that the discrete log of the output point with respect to any other point should be unknown. The map is applied twice and the results are added, to ensure a uniform distribution.
pub fn hash_from_bytes<D>(input: &[u8]) -> RistrettoPoint where
D: Digest<OutputSize = U64> + Default,
[src]
D: Digest<OutputSize = U64> + Default,
Hash a slice of bytes into a RistrettoPoint
.
Takes a type parameter D
, which is any Digest
producing 64
bytes of output.
Convenience wrapper around from_hash
.
Implementation
Uses the Ristretto-flavoured Elligator 2 map, so that the discrete log of the output point with respect to any other point should be unknown. The map is applied twice and the results are added, to ensure a uniform distribution.
Example
extern crate sha2; use sha2::Sha512; let msg = "To really appreciate architecture, you may even need to commit a murder"; let P = RistrettoPoint::hash_from_bytes::<Sha512>(msg.as_bytes());
pub fn from_hash<D>(hash: D) -> RistrettoPoint where
D: Digest<OutputSize = U64> + Default,
[src]
D: Digest<OutputSize = U64> + Default,
Construct a RistrettoPoint
from an existing Digest
instance.
Use this instead of hash_from_bytes
if it is more convenient
to stream data into the Digest
than to pass a single byte
slice.
pub fn from_uniform_bytes(bytes: &[u8; 64]) -> RistrettoPoint
[src]
Construct a RistrettoPoint
from 64 bytes of data.
If the input bytes are uniformly distributed, the resulting point will be uniformly distributed over the group, and its discrete log with respect to other points should be unknown.
Implementation
This function splits the input array into two 32-byte halves, takes the low 255 bits of each half mod p, applies the Ristretto-flavored Elligator map to each, and adds the results.
impl RistrettoPoint
[src]
pub fn vartime_double_scalar_mul_basepoint(
a: &Scalar,
A: &RistrettoPoint,
b: &Scalar
) -> RistrettoPoint
[src]
a: &Scalar,
A: &RistrettoPoint,
b: &Scalar
) -> RistrettoPoint
Compute \(aA + bB\) in variable time, where \(B\) is the Ristretto basepoint.
Trait Implementations
impl Identity for RistrettoPoint
[src]
fn identity() -> RistrettoPoint
[src]
impl MultiscalarMul for RistrettoPoint
[src]
type Point = RistrettoPoint
The type of point being multiplied, e.g., RistrettoPoint
.
fn multiscalar_mul<I, J>(scalars: I, points: J) -> RistrettoPoint where
I: IntoIterator,
I::Item: Borrow<Scalar>,
J: IntoIterator,
J::Item: Borrow<RistrettoPoint>,
[src]
I: IntoIterator,
I::Item: Borrow<Scalar>,
J: IntoIterator,
J::Item: Borrow<RistrettoPoint>,
impl VartimeMultiscalarMul for RistrettoPoint
[src]
type Point = RistrettoPoint
The type of point being multiplied, e.g., RistrettoPoint
.
fn optional_multiscalar_mul<I, J>(
scalars: I,
points: J
) -> Option<RistrettoPoint> where
I: IntoIterator,
I::Item: Borrow<Scalar>,
J: IntoIterator<Item = Option<RistrettoPoint>>,
[src]
scalars: I,
points: J
) -> Option<RistrettoPoint> where
I: IntoIterator,
I::Item: Borrow<Scalar>,
J: IntoIterator<Item = Option<RistrettoPoint>>,
fn vartime_multiscalar_mul<I, J>(scalars: I, points: J) -> Self::Point where
I: IntoIterator,
I::Item: Borrow<Scalar>,
J: IntoIterator,
J::Item: Borrow<Self::Point>,
Self::Point: Clone,
[src]
I: IntoIterator,
I::Item: Borrow<Scalar>,
J: IntoIterator,
J::Item: Borrow<Self::Point>,
Self::Point: Clone,
Given an iterator of public scalars and an iterator of public points, compute $$ Q = c_1 P_1 + \cdots + c_n P_n, $$ using variable-time operations. Read more
impl Copy for RistrettoPoint
[src]
impl Clone for RistrettoPoint
[src]
fn clone(&self) -> RistrettoPoint
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq<RistrettoPoint> for RistrettoPoint
[src]
fn eq(&self, other: &RistrettoPoint) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Eq for RistrettoPoint
[src]
impl Debug for RistrettoPoint
[src]
impl<'a, 'b> Add<&'b RistrettoPoint> for &'a RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the +
operator.
fn add(self, other: &'b RistrettoPoint) -> RistrettoPoint
[src]
impl<'b> Add<&'b RistrettoPoint> for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the +
operator.
fn add(self, rhs: &'b RistrettoPoint) -> RistrettoPoint
[src]
impl<'a> Add<RistrettoPoint> for &'a RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the +
operator.
fn add(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
impl Add<RistrettoPoint> for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the +
operator.
fn add(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
impl<'a, 'b> Sub<&'b RistrettoPoint> for &'a RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn sub(self, other: &'b RistrettoPoint) -> RistrettoPoint
[src]
impl<'b> Sub<&'b RistrettoPoint> for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn sub(self, rhs: &'b RistrettoPoint) -> RistrettoPoint
[src]
impl<'a> Sub<RistrettoPoint> for &'a RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn sub(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
impl Sub<RistrettoPoint> for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn sub(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
impl<'a, 'b> Mul<&'b Scalar> for &'a RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, scalar: &'b Scalar) -> RistrettoPoint
[src]
Scalar multiplication: compute scalar * self
.
impl<'a, 'b> Mul<&'b RistrettoPoint> for &'a Scalar
[src]
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, point: &'b RistrettoPoint) -> RistrettoPoint
[src]
Scalar multiplication: compute self * scalar
.
impl<'b> Mul<&'b Scalar> for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b Scalar) -> RistrettoPoint
[src]
impl<'a> Mul<Scalar> for &'a RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: Scalar) -> RistrettoPoint
[src]
impl Mul<Scalar> for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: Scalar) -> RistrettoPoint
[src]
impl<'b> Mul<&'b RistrettoPoint> for Scalar
[src]
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b RistrettoPoint) -> RistrettoPoint
[src]
impl<'a> Mul<RistrettoPoint> for &'a Scalar
[src]
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
impl Mul<RistrettoPoint> for Scalar
[src]
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
impl<'a> Neg for &'a RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn neg(self) -> RistrettoPoint
[src]
impl Neg for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn neg(self) -> RistrettoPoint
[src]
impl<'b> AddAssign<&'b RistrettoPoint> for RistrettoPoint
[src]
fn add_assign(&mut self, _rhs: &RistrettoPoint)
[src]
impl AddAssign<RistrettoPoint> for RistrettoPoint
[src]
fn add_assign(&mut self, rhs: RistrettoPoint)
[src]
impl<'b> SubAssign<&'b RistrettoPoint> for RistrettoPoint
[src]
fn sub_assign(&mut self, _rhs: &RistrettoPoint)
[src]
impl SubAssign<RistrettoPoint> for RistrettoPoint
[src]
fn sub_assign(&mut self, rhs: RistrettoPoint)
[src]
impl<'b> MulAssign<&'b Scalar> for RistrettoPoint
[src]
fn mul_assign(&mut self, scalar: &'b Scalar)
[src]
impl MulAssign<Scalar> for RistrettoPoint
[src]
fn mul_assign(&mut self, rhs: Scalar)
[src]
impl<T> Sum<T> for RistrettoPoint where
T: Borrow<RistrettoPoint>,
[src]
T: Borrow<RistrettoPoint>,
impl Default for RistrettoPoint
[src]
fn default() -> RistrettoPoint
[src]
impl ConstantTimeEq for RistrettoPoint
[src]
fn ct_eq(&self, other: &RistrettoPoint) -> Choice
[src]
Test equality between two RistrettoPoint
s.
Returns
Choice(1)
if the twoRistrettoPoint
s are equal;Choice(0)
otherwise.
impl ConditionallySelectable for RistrettoPoint
[src]
fn conditional_select(
a: &RistrettoPoint,
b: &RistrettoPoint,
choice: Choice
) -> RistrettoPoint
[src]
a: &RistrettoPoint,
b: &RistrettoPoint,
choice: Choice
) -> RistrettoPoint
Conditionally select between self
and other
.
Example
use subtle::ConditionallySelectable; use subtle::Choice; let A = RistrettoPoint::identity(); let B = constants::RISTRETTO_BASEPOINT_POINT; let mut P = A; P = RistrettoPoint::conditional_select(&A, &B, Choice::from(0)); assert_eq!(P, A); P = RistrettoPoint::conditional_select(&A, &B, Choice::from(1)); assert_eq!(P, B);
fn conditional_assign(&mut self, other: &Self, choice: Choice)
[src]
Conditionally assign other
to self
, according to choice
. Read more
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
[src]
Conditionally swap self
and other
if choice == 1
; otherwise, reassign both unto themselves. Read more
Auto Trait Implementations
impl Send for RistrettoPoint
impl Sync for RistrettoPoint
Blanket Implementations
impl<T> IsIdentity for T where
T: ConstantTimeEq + Identity,
[src]
T: ConstantTimeEq + Identity,
fn is_identity(&Self) -> bool
[src]
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> FromCast for T
[src]
impl<T, U> Cast for T where
U: FromCast<T>,
[src]
U: FromCast<T>,
impl<T, U> IntoBits for T where
U: FromBits<T>,
[src]
U: FromBits<T>,
impl<T> FromBits for T
[src]
impl<T> Clear for T where
T: InitializableFromZeroed + ?Sized,
[src]
T: InitializableFromZeroed + ?Sized,
impl<T> InitializableFromZeroed for T where
T: Default,
[src]
T: Default,
unsafe fn initialize(place: *mut T)
[src]
impl<T> Same for T
type Output = T
Should always be Self
impl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: Neg,
<&'a T as Neg>::Output == T,
[src]
T: ConditionallySelectable,
&'a T: Neg,
<&'a T as Neg>::Output == T,