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
impl GroupElement
Sourcepub fn random<R: Rng + CryptoRng>(rng: &mut R) -> Self
pub fn random<R: Rng + CryptoRng>(rng: &mut R) -> Self
Generate a random GroupElement. This is the preferred way of generating pseudonyms.
Sourcepub fn from_bytes(v: &[u8; 32]) -> Option<Self>
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).
Sourcepub fn from_slice(v: &[u8]) -> Option<Self>
pub fn from_slice(v: &[u8]) -> Option<Self>
Create from a byte slice.
Sourcepub fn to_bytes(&self) -> [u8; 32]
pub fn to_bytes(&self) -> [u8; 32]
Convert to a 32-byte array.
Any GroupElement can be converted this way.
Sourcepub fn from_hash(v: &[u8; 64]) -> Self
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.
Sourcepub fn from_lizard(v: &[u8; 16]) -> Self
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.
Sourcepub fn to_lizard(&self) -> Option<[u8; 16]>
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.
Trait Implementations§
Source§impl Add for GroupElement
impl Add for GroupElement
Source§impl<'b> Add<&'b GroupElement> for &GroupElement
impl<'b> Add<&'b GroupElement> for &GroupElement
Source§type Output = GroupElement
type Output = GroupElement
+ operator.Source§impl<'b> Add<&'b GroupElement> for GroupElement
impl<'b> Add<&'b GroupElement> for GroupElement
Source§type Output = GroupElement
type Output = GroupElement
+ operator.Source§impl Add<GroupElement> for &GroupElement
impl Add<GroupElement> for &GroupElement
Source§type Output = GroupElement
type Output = GroupElement
+ operator.Source§impl Clone for GroupElement
impl Clone for GroupElement
Source§fn clone(&self) -> GroupElement
fn clone(&self) -> GroupElement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for GroupElement
Source§impl Debug for GroupElement
impl Debug for GroupElement
Source§impl<'de> Deserialize<'de> for GroupElement
Available on crate feature serde only.
impl<'de> Deserialize<'de> for GroupElement
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl Eq for GroupElement
Source§impl From<GroupElement> for Pseudonym
impl From<GroupElement> for Pseudonym
Source§fn from(value: GroupElement) -> Self
fn from(value: GroupElement) -> Self
Source§impl From<GroupElement> for Attribute
impl From<GroupElement> for Attribute
Source§fn from(value: GroupElement) -> Self
fn from(value: GroupElement) -> Self
Source§impl From<GroupElement> for PseudonymGlobalPublicKey
impl From<GroupElement> for PseudonymGlobalPublicKey
Source§fn from(value: GroupElement) -> Self
fn from(value: GroupElement) -> Self
Source§impl From<GroupElement> for AttributeGlobalPublicKey
impl From<GroupElement> for AttributeGlobalPublicKey
Source§fn from(value: GroupElement) -> Self
fn from(value: GroupElement) -> Self
Source§impl From<GroupElement> for PseudonymSessionPublicKey
impl From<GroupElement> for PseudonymSessionPublicKey
Source§fn from(value: GroupElement) -> Self
fn from(value: GroupElement) -> Self
Source§impl From<GroupElement> for AttributeSessionPublicKey
impl From<GroupElement> for AttributeSessionPublicKey
Source§fn from(value: GroupElement) -> Self
fn from(value: GroupElement) -> Self
Source§impl Hash for GroupElement
impl Hash for GroupElement
Source§impl<'b> Mul<&'b GroupElement> for &ScalarNonZero
impl<'b> Mul<&'b GroupElement> for &ScalarNonZero
Source§type Output = GroupElement
type Output = GroupElement
* operator.Source§impl<'b> Mul<&'b GroupElement> for ScalarNonZero
impl<'b> Mul<&'b GroupElement> for ScalarNonZero
Source§type Output = GroupElement
type Output = GroupElement
* operator.Source§impl<'b> Mul<&'b GroupElement> for &ScalarCanBeZero
impl<'b> Mul<&'b GroupElement> for &ScalarCanBeZero
Source§type Output = GroupElement
type Output = GroupElement
* operator.Source§impl<'b> Mul<&'b GroupElement> for ScalarCanBeZero
impl<'b> Mul<&'b GroupElement> for ScalarCanBeZero
Source§type Output = GroupElement
type Output = GroupElement
* operator.Source§impl Mul<GroupElement> for &ScalarNonZero
impl Mul<GroupElement> for &ScalarNonZero
Source§type Output = GroupElement
type Output = GroupElement
* operator.Source§impl Mul<GroupElement> for ScalarNonZero
impl Mul<GroupElement> for ScalarNonZero
Source§type Output = GroupElement
type Output = GroupElement
* operator.Source§impl Mul<GroupElement> for &ScalarCanBeZero
impl Mul<GroupElement> for &ScalarCanBeZero
Source§type Output = GroupElement
type Output = GroupElement
* operator.Source§impl Mul<GroupElement> for ScalarCanBeZero
impl Mul<GroupElement> for ScalarCanBeZero
Source§type Output = GroupElement
type Output = GroupElement
* operator.Source§impl PartialEq for GroupElement
impl PartialEq for GroupElement
Source§fn eq(&self, other: &GroupElement) -> bool
fn eq(&self, other: &GroupElement) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for GroupElement
Available on crate feature serde only.
impl Serialize for GroupElement
serde only.impl StructuralPartialEq for GroupElement
Source§impl Sub for GroupElement
impl Sub for GroupElement
Source§impl<'b> Sub<&'b GroupElement> for &GroupElement
impl<'b> Sub<&'b GroupElement> for &GroupElement
Source§type Output = GroupElement
type Output = GroupElement
- operator.Source§impl<'b> Sub<&'b GroupElement> for GroupElement
impl<'b> Sub<&'b GroupElement> for GroupElement
Source§type Output = GroupElement
type Output = GroupElement
- operator.Source§impl Sub<GroupElement> for &GroupElement
impl Sub<GroupElement> for &GroupElement
Source§type Output = GroupElement
type Output = GroupElement
- operator.