Struct curve25519_dalek::ristretto::RistrettoPoint [−][src]
pub struct 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]
impl RistrettoPoint
pub fn compress(&self) -> CompressedRistretto
[src]
pub fn compress(&self) -> CompressedRistretto
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]
pub fn double_and_compress_batch<'a, I>(points: I) -> Vec<CompressedRistretto> where
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; use rand::rngs::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: Rng + CryptoRng>(rng: &mut T) -> Self
[src]
pub fn random<T: Rng + CryptoRng>(rng: &mut T) -> Self
Return a RistrettoPoint
chosen uniformly at random using a user-provided RNG.
Inputs
rng
: any RNG which implements therand::Rng
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]
pub fn hash_from_bytes<D>(input: &[u8]) -> RistrettoPoint where
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]
pub fn from_hash<D>(hash: D) -> RistrettoPoint where
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]
pub fn from_uniform_bytes(bytes: &[u8; 64]) -> RistrettoPoint
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]
impl RistrettoPoint
pub fn vartime_double_scalar_mul_basepoint(
a: &Scalar,
A: &RistrettoPoint,
b: &Scalar
) -> RistrettoPoint
[src]
pub fn vartime_double_scalar_mul_basepoint(
a: &Scalar,
A: &RistrettoPoint,
b: &Scalar
) -> RistrettoPoint
Compute \(aA + bB\) in variable time, where \(B\) is the Ristretto basepoint.
Trait Implementations
impl Copy for RistrettoPoint
[src]
impl Copy for RistrettoPoint
impl Clone for RistrettoPoint
[src]
impl Clone for RistrettoPoint
fn clone(&self) -> RistrettoPoint
[src]
fn clone(&self) -> RistrettoPoint
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Identity for RistrettoPoint
[src]
impl Identity for RistrettoPoint
fn identity() -> RistrettoPoint
[src]
fn identity() -> RistrettoPoint
Returns the identity element of the curve. Can be used as a constructor. Read more
impl Default for RistrettoPoint
[src]
impl Default for RistrettoPoint
fn default() -> RistrettoPoint
[src]
fn default() -> RistrettoPoint
Returns the "default value" for a type. Read more
impl PartialEq for RistrettoPoint
[src]
impl PartialEq for RistrettoPoint
fn eq(&self, other: &RistrettoPoint) -> bool
[src]
fn eq(&self, other: &RistrettoPoint) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl ConstantTimeEq for RistrettoPoint
[src]
impl ConstantTimeEq for RistrettoPoint
fn ct_eq(&self, other: &RistrettoPoint) -> Choice
[src]
fn ct_eq(&self, other: &RistrettoPoint) -> Choice
Test equality between two RistrettoPoint
s.
Returns
Choice(1)
if the twoRistrettoPoint
s are equal;Choice(0)
otherwise.
impl Eq for RistrettoPoint
[src]
impl Eq for RistrettoPoint
impl<'a, 'b> Add<&'b RistrettoPoint> for &'a RistrettoPoint
[src]
impl<'a, 'b> Add<&'b RistrettoPoint> for &'a RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the +
operator.
fn add(self, other: &'b RistrettoPoint) -> RistrettoPoint
[src]
fn add(self, other: &'b RistrettoPoint) -> RistrettoPoint
Performs the +
operation.
impl<'b> Add<&'b RistrettoPoint> for RistrettoPoint
[src]
impl<'b> Add<&'b RistrettoPoint> for RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the +
operator.
fn add(self, rhs: &'b RistrettoPoint) -> RistrettoPoint
[src]
fn add(self, rhs: &'b RistrettoPoint) -> RistrettoPoint
Performs the +
operation.
impl<'a> Add<RistrettoPoint> for &'a RistrettoPoint
[src]
impl<'a> Add<RistrettoPoint> for &'a RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the +
operator.
fn add(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
fn add(self, rhs: RistrettoPoint) -> RistrettoPoint
Performs the +
operation.
impl Add<RistrettoPoint> for RistrettoPoint
[src]
impl Add<RistrettoPoint> for RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the +
operator.
fn add(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
fn add(self, rhs: RistrettoPoint) -> RistrettoPoint
Performs the +
operation.
impl<'b> AddAssign<&'b RistrettoPoint> for RistrettoPoint
[src]
impl<'b> AddAssign<&'b RistrettoPoint> for RistrettoPoint
fn add_assign(&mut self, _rhs: &RistrettoPoint)
[src]
fn add_assign(&mut self, _rhs: &RistrettoPoint)
Performs the +=
operation.
impl AddAssign<RistrettoPoint> for RistrettoPoint
[src]
impl AddAssign<RistrettoPoint> for RistrettoPoint
fn add_assign(&mut self, rhs: RistrettoPoint)
[src]
fn add_assign(&mut self, rhs: RistrettoPoint)
Performs the +=
operation.
impl<'a, 'b> Sub<&'b RistrettoPoint> for &'a RistrettoPoint
[src]
impl<'a, 'b> Sub<&'b RistrettoPoint> for &'a RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn sub(self, other: &'b RistrettoPoint) -> RistrettoPoint
[src]
fn sub(self, other: &'b RistrettoPoint) -> RistrettoPoint
Performs the -
operation.
impl<'b> Sub<&'b RistrettoPoint> for RistrettoPoint
[src]
impl<'b> Sub<&'b RistrettoPoint> for RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn sub(self, rhs: &'b RistrettoPoint) -> RistrettoPoint
[src]
fn sub(self, rhs: &'b RistrettoPoint) -> RistrettoPoint
Performs the -
operation.
impl<'a> Sub<RistrettoPoint> for &'a RistrettoPoint
[src]
impl<'a> Sub<RistrettoPoint> for &'a RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn sub(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
fn sub(self, rhs: RistrettoPoint) -> RistrettoPoint
Performs the -
operation.
impl Sub<RistrettoPoint> for RistrettoPoint
[src]
impl Sub<RistrettoPoint> for RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn sub(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
fn sub(self, rhs: RistrettoPoint) -> RistrettoPoint
Performs the -
operation.
impl<'b> SubAssign<&'b RistrettoPoint> for RistrettoPoint
[src]
impl<'b> SubAssign<&'b RistrettoPoint> for RistrettoPoint
fn sub_assign(&mut self, _rhs: &RistrettoPoint)
[src]
fn sub_assign(&mut self, _rhs: &RistrettoPoint)
Performs the -=
operation.
impl SubAssign<RistrettoPoint> for RistrettoPoint
[src]
impl SubAssign<RistrettoPoint> for RistrettoPoint
fn sub_assign(&mut self, rhs: RistrettoPoint)
[src]
fn sub_assign(&mut self, rhs: RistrettoPoint)
Performs the -=
operation.
impl<T> Sum<T> for RistrettoPoint where
T: Borrow<RistrettoPoint>,
[src]
impl<T> Sum<T> for RistrettoPoint where
T: Borrow<RistrettoPoint>,
fn sum<I>(iter: I) -> Self where
I: Iterator<Item = T>,
[src]
fn sum<I>(iter: I) -> Self where
I: Iterator<Item = T>,
Method which takes an iterator and generates Self
from the elements by "summing up" the items. Read more
impl<'a> Neg for &'a RistrettoPoint
[src]
impl<'a> Neg for &'a RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn neg(self) -> RistrettoPoint
[src]
fn neg(self) -> RistrettoPoint
Performs the unary -
operation.
impl Neg for RistrettoPoint
[src]
impl Neg for RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn neg(self) -> RistrettoPoint
[src]
fn neg(self) -> RistrettoPoint
Performs the unary -
operation.
impl<'b> MulAssign<&'b Scalar> for RistrettoPoint
[src]
impl<'b> MulAssign<&'b Scalar> for RistrettoPoint
fn mul_assign(&mut self, scalar: &'b Scalar)
[src]
fn mul_assign(&mut self, scalar: &'b Scalar)
Performs the *=
operation.
impl<'a, 'b> Mul<&'b Scalar> for &'a RistrettoPoint
[src]
impl<'a, 'b> Mul<&'b Scalar> for &'a RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, scalar: &'b Scalar) -> RistrettoPoint
[src]
fn mul(self, scalar: &'b Scalar) -> RistrettoPoint
Scalar multiplication: compute scalar * self
.
impl<'a, 'b> Mul<&'b RistrettoPoint> for &'a Scalar
[src]
impl<'a, 'b> Mul<&'b RistrettoPoint> for &'a Scalar
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, point: &'b RistrettoPoint) -> RistrettoPoint
[src]
fn mul(self, point: &'b RistrettoPoint) -> RistrettoPoint
Scalar multiplication: compute self * scalar
.
impl MulAssign<Scalar> for RistrettoPoint
[src]
impl MulAssign<Scalar> for RistrettoPoint
fn mul_assign(&mut self, rhs: Scalar)
[src]
fn mul_assign(&mut self, rhs: Scalar)
Performs the *=
operation.
impl<'b> Mul<&'b Scalar> for RistrettoPoint
[src]
impl<'b> Mul<&'b Scalar> for RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b Scalar) -> RistrettoPoint
[src]
fn mul(self, rhs: &'b Scalar) -> RistrettoPoint
Performs the *
operation.
impl<'a> Mul<Scalar> for &'a RistrettoPoint
[src]
impl<'a> Mul<Scalar> for &'a RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: Scalar) -> RistrettoPoint
[src]
fn mul(self, rhs: Scalar) -> RistrettoPoint
Performs the *
operation.
impl Mul<Scalar> for RistrettoPoint
[src]
impl Mul<Scalar> for RistrettoPoint
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: Scalar) -> RistrettoPoint
[src]
fn mul(self, rhs: Scalar) -> RistrettoPoint
Performs the *
operation.
impl<'b> Mul<&'b RistrettoPoint> for Scalar
[src]
impl<'b> Mul<&'b RistrettoPoint> for Scalar
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b RistrettoPoint) -> RistrettoPoint
[src]
fn mul(self, rhs: &'b RistrettoPoint) -> RistrettoPoint
Performs the *
operation.
impl<'a> Mul<RistrettoPoint> for &'a Scalar
[src]
impl<'a> Mul<RistrettoPoint> for &'a Scalar
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
fn mul(self, rhs: RistrettoPoint) -> RistrettoPoint
Performs the *
operation.
impl Mul<RistrettoPoint> for Scalar
[src]
impl Mul<RistrettoPoint> for Scalar
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
fn mul(self, rhs: RistrettoPoint) -> RistrettoPoint
Performs the *
operation.
impl MultiscalarMul for RistrettoPoint
[src]
impl MultiscalarMul for RistrettoPoint
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]
fn multiscalar_mul<I, J>(scalars: I, points: J) -> RistrettoPoint where
I: IntoIterator,
I::Item: Borrow<Scalar>,
J: IntoIterator,
J::Item: Borrow<RistrettoPoint>,
Given an iterator of (possibly secret) scalars and an iterator of public points, compute $$ Q = c_1 P_1 + \cdots + c_n P_n. $$ Read more
impl VartimeMultiscalarMul for RistrettoPoint
[src]
impl VartimeMultiscalarMul for RistrettoPoint
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]
fn optional_multiscalar_mul<I, J>(
scalars: I,
points: J
) -> Option<RistrettoPoint> where
I: IntoIterator,
I::Item: Borrow<Scalar>,
J: IntoIterator<Item = Option<RistrettoPoint>>,
Given an iterator of public scalars and an iterator of 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
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]
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,
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 ConditionallyAssignable for RistrettoPoint
[src]
impl ConditionallyAssignable for RistrettoPoint
fn conditional_assign(&mut self, other: &RistrettoPoint, choice: Choice)
[src]
fn conditional_assign(&mut self, other: &RistrettoPoint, choice: Choice)
Conditionally assign other
to self
, if choice == Choice(1)
.
Example
use subtle::ConditionallyAssignable; use subtle::Choice; let A = RistrettoPoint::identity(); let B = constants::RISTRETTO_BASEPOINT_POINT; let mut P = A; P.conditional_assign(&B, Choice::from(0)); assert_eq!(P, A); P.conditional_assign(&B, Choice::from(1)); assert_eq!(P, B);
impl Debug for RistrettoPoint
[src]
impl Debug for RistrettoPoint
Auto Trait Implementations
impl Send for RistrettoPoint
impl Send for RistrettoPoint
impl Sync for RistrettoPoint
impl Sync for RistrettoPoint