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]
fn compress(&self) -> CompressedRistretto
[src]
Compress this point using the Ristretto encoding.
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.
This function has optimal performance when the batch size is a power of two, but this is not a requirement.
extern crate rand; use rand::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()); }
fn random<T: Rng>(rng: &mut T) -> Self
[src]
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.
fn hash_from_bytes<D>(input: &[u8]) -> RistrettoPoint where
D: Digest<OutputSize = U32> + Default,
[src]
D: Digest<OutputSize = U32> + Default,
Hash a slice of bytes into a RistrettoPoint
.
Takes a type parameter D
, which is any Digest
producing 32
bytes (256 bits) 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.
Example
extern crate sha2; use sha2::Sha256; let msg = "To really appreciate architecture, you may even need to commit a murder"; let P = RistrettoPoint::hash_from_bytes::<Sha256>(msg.as_bytes());
fn from_hash<D>(hash: D) -> RistrettoPoint where
D: Digest<OutputSize = U32> + Default,
[src]
D: Digest<OutputSize = U32> + 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.
Trait Implementations
impl Copy for RistrettoPoint
[src]
impl Clone for RistrettoPoint
[src]
fn clone(&self) -> RistrettoPoint
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Identity for RistrettoPoint
[src]
fn identity() -> RistrettoPoint
[src]
Returns the identity element of the curve. Can be used as a constructor. Read more
impl PartialEq for RistrettoPoint
[src]
fn eq(&self, other: &RistrettoPoint) -> bool
[src]
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]
This method tests for !=
.
impl Equal for RistrettoPoint
[src]
fn ct_eq(&self, other: &RistrettoPoint) -> u8
[src]
Test equality between two RistrettoPoint
s.
Returns
1u8
if the two RistrettoPoint
s are equal, and 0u8
otherwise.
impl Eq 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]
Performs the +
operation.
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]
Performs the +
operation.
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]
Performs the +
operation.
impl Add<RistrettoPoint> for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the +
operator.
fn add(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
Performs the +
operation.
impl<'b> AddAssign<&'b RistrettoPoint> for RistrettoPoint
[src]
fn add_assign(&mut self, _rhs: &RistrettoPoint)
[src]
Performs the +=
operation.
impl AddAssign<RistrettoPoint> for RistrettoPoint
[src]
fn add_assign(&mut self, rhs: RistrettoPoint)
[src]
Performs the +=
operation.
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]
Performs the -
operation.
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]
Performs the -
operation.
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]
Performs the -
operation.
impl Sub<RistrettoPoint> for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn sub(self, rhs: RistrettoPoint) -> RistrettoPoint
[src]
Performs the -
operation.
impl<'b> SubAssign<&'b RistrettoPoint> for RistrettoPoint
[src]
fn sub_assign(&mut self, _rhs: &RistrettoPoint)
[src]
Performs the -=
operation.
impl SubAssign<RistrettoPoint> for RistrettoPoint
[src]
fn sub_assign(&mut self, rhs: RistrettoPoint)
[src]
Performs the -=
operation.
impl<'a> Neg for &'a RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn neg(self) -> RistrettoPoint
[src]
Performs the unary -
operation.
impl Neg for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the -
operator.
fn neg(self) -> RistrettoPoint
[src]
Performs the unary -
operation.
impl<'b> MulAssign<&'b Scalar> for RistrettoPoint
[src]
fn mul_assign(&mut self, scalar: &'b Scalar)
[src]
Performs the *=
operation.
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 MulAssign<Scalar> for RistrettoPoint
[src]
fn mul_assign(&mut self, rhs: Scalar)
[src]
Performs the *=
operation.
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]
Performs the *
operation.
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]
Performs the *
operation.
impl Mul<Scalar> for RistrettoPoint
[src]
type Output = RistrettoPoint
The resulting type after applying the *
operator.
fn mul(self, rhs: Scalar) -> RistrettoPoint
[src]
Performs the *
operation.
impl ConditionallyAssignable for RistrettoPoint
[src]
fn conditional_assign(&mut self, other: &RistrettoPoint, choice: u8)
[src]
Conditionally assign other
to self
, if choice == 1u8
.
Example
let A = RistrettoPoint::identity(); let B = constants::RISTRETTO_BASEPOINT_POINT; let mut P = A; P.conditional_assign(&B, 0u8); assert!(P == A); P.conditional_assign(&B, 1u8); assert!(P == B);