Skip to main content

GroupElement

Struct GroupElement 

Source
pub struct GroupElement(/* private fields */);
Expand description

Element on a group.

Cannot be converted to a scalar. Supports addition and subtraction. Multiplication by a scalar is supported. We use ristretto points to discard unsafe points and safely use the group operations in higher level protocols without any other cryptographic assumptions.

Implementations§

Source§

impl GroupElement

Source

pub fn random<R: Rng + CryptoRng>(rng: &mut R) -> Self

Generate a random GroupElement. This is the preferred way of generating pseudonyms.

Source

pub fn from_bytes(v: &[u8; 32]) -> Option<Self>

Create from a 32-byte compressed Ristretto point.

Returns None if the point is not valid (only ~6.25% of all 32-byte strings are valid encodings, use lizard technique to decode arbitrary data).

Curve25519 has exactly 2^255 - 19 points. Ristretto removes the cofactor 8 and maps the points to a subgroup of prime order 2^252 + 27742317777372353535851937790883648493 (the Elligator mapping takes 253 bits).

Source

pub fn from_slice(v: &[u8]) -> Option<Self>

Create from a byte slice.

Source

pub fn to_bytes(&self) -> [u8; 32]

Convert to a 32-byte array.

Any GroupElement can be converted this way.

Source

pub fn from_hash(v: &[u8; 64]) -> Self

Create from a 64-byte hash.

This is a one-way function. Multiple hashes can map to the same point.

Source

pub fn from_lizard(v: &[u8; 16]) -> Self

Create from any 16-byte string bijectively, using the lizard approach.

There are practically no invalid lizard encodings! This is useful to encode arbitrary data as group element.

Source

pub fn to_lizard(&self) -> Option<[u8; 16]>

Convert to a 16-byte string using the lizard approach.

Notice that a Ristretto point is represented as 32 bytes with ~2^252 valid points, so only a very small fraction of points (only those created from lizard) can be converted this way.

Source

pub fn from_hex(s: &str) -> Option<Self>

Create from a hexadecimal string (32 bytes or 64 characters).

Returns None if the string is not a valid hexadecimal encoding of a Ristretto point.

Source

pub fn to_hex(&self) -> String

Convert to a hexadecimal string.

Source

pub fn identity() -> Self

Return the identity element of the group.

Trait Implementations§

Source§

impl Add for GroupElement

Source§

type Output = GroupElement

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<'b> Add<&'b GroupElement> for &GroupElement

Source§

type Output = GroupElement

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b GroupElement) -> Self::Output

Performs the + operation. Read more
Source§

impl<'b> Add<&'b GroupElement> for GroupElement

Source§

type Output = GroupElement

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b GroupElement) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<GroupElement> for &GroupElement

Source§

type Output = GroupElement

The resulting type after applying the + operator.
Source§

fn add(self, rhs: GroupElement) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for GroupElement

Source§

fn clone(&self) -> GroupElement

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for GroupElement

Source§

impl Debug for GroupElement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for GroupElement

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for GroupElement

Source§

impl From<GroupElement> for Pseudonym

Source§

fn from(value: GroupElement) -> Self

Converts to this type from the input type.
Source§

impl From<GroupElement> for Attribute

Source§

fn from(value: GroupElement) -> Self

Converts to this type from the input type.
Source§

impl From<GroupElement> for PseudonymGlobalPublicKey

Source§

fn from(value: GroupElement) -> Self

Converts to this type from the input type.
Source§

impl From<GroupElement> for AttributeGlobalPublicKey

Source§

fn from(value: GroupElement) -> Self

Converts to this type from the input type.
Source§

impl From<GroupElement> for PseudonymSessionPublicKey

Source§

fn from(value: GroupElement) -> Self

Converts to this type from the input type.
Source§

impl From<GroupElement> for AttributeSessionPublicKey

Source§

fn from(value: GroupElement) -> Self

Converts to this type from the input type.
Source§

impl Hash for GroupElement

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'b> Mul<&'b GroupElement> for &ScalarNonZero

Source§

type Output = GroupElement

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b GroupElement) -> Self::Output

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b GroupElement> for ScalarNonZero

Source§

type Output = GroupElement

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b GroupElement) -> Self::Output

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b GroupElement> for &ScalarCanBeZero

Source§

type Output = GroupElement

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b GroupElement) -> Self::Output

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b GroupElement> for ScalarCanBeZero

Source§

type Output = GroupElement

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b GroupElement) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<GroupElement> for &ScalarNonZero

Source§

type Output = GroupElement

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: GroupElement) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<GroupElement> for ScalarNonZero

Source§

type Output = GroupElement

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: GroupElement) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<GroupElement> for &ScalarCanBeZero

Source§

type Output = GroupElement

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: GroupElement) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<GroupElement> for ScalarCanBeZero

Source§

type Output = GroupElement

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: GroupElement) -> Self::Output

Performs the * operation. Read more
Source§

impl PartialEq for GroupElement

Source§

fn eq(&self, other: &GroupElement) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for GroupElement

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for GroupElement

Source§

impl Sub for GroupElement

Source§

type Output = GroupElement

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<'b> Sub<&'b GroupElement> for &GroupElement

Source§

type Output = GroupElement

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b GroupElement) -> Self::Output

Performs the - operation. Read more
Source§

impl<'b> Sub<&'b GroupElement> for GroupElement

Source§

type Output = GroupElement

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b GroupElement) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<GroupElement> for &GroupElement

Source§

type Output = GroupElement

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: GroupElement) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.