Skip to main content

Attribute

Struct Attribute 

Source
pub struct Attribute {
    pub value: GroupElement,
}
Expand description

An attribute (in the background, this is a GroupElement), which should not be identifiable and can be encrypted and rekeyed, but not reshuffled.

Fields§

§value: GroupElement

Methods from Deref<Target = GroupElement>§

Source

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

Convert to a 32-byte array.

Any GroupElement can be converted this way.

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 to_hex(&self) -> String

Convert to a hexadecimal string.

Trait Implementations§

Source§

impl BatchEncryptable for Attribute

Available on crate feature batch only.
Source§

fn preprocess_batch(items: &[Self]) -> Result<Vec<Self>, BatchError>

Source§

impl Clone for Attribute

Source§

fn clone(&self) -> Attribute

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 Attribute

Source§

impl Debug for Attribute

Source§

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

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

impl Deref for Attribute

Source§

type Target = GroupElement

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'de> Deserialize<'de> for Attribute

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 ElGamalEncryptable for Attribute

Source§

fn value(&self) -> &GroupElement

Get the GroupElement plaintext value.
Source§

fn from_value(value: GroupElement) -> Self
where Self: Sized,

Create from a GroupElement.
Source§

fn from_point(value: GroupElement) -> Self
where Self: Sized,

Create from a GroupElement.
Source§

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

Create with a random value.
Source§

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

Encode as a byte array of length 32. See GroupElement::to_bytes.
Source§

fn to_hex(&self) -> String

Convert to a hexadecimal string of 64 characters.
Source§

fn from_bytes(bytes: &[u8; 32]) -> Option<Self>
where Self: Sized,

Create from a byte array of length 32. Returns None if the input is not a valid encoding of a GroupElement.
Source§

fn from_slice(slice: &[u8]) -> Option<Self>
where Self: Sized,

Create from a slice of bytes. Returns None if the input is not a valid encoding of a GroupElement.
Source§

fn from_hex(hex: &str) -> Option<Self>
where Self: Sized,

Create from a hexadecimal string. Returns None if the input is not a valid encoding of a GroupElement.
Source§

fn from_hash(hash: &[u8; 64]) -> Self
where Self: Sized,

Create from a hash value. See GroupElement::from_hash.
Source§

fn from_lizard(data: &[u8; 16]) -> Self
where Self: Sized,

Create from a byte array of length 16 using lizard encoding. This is useful for creating a pseudonym from an existing identifier or encoding attributes, as it accepts any 16-byte value. See GroupElement::from_lizard.
Source§

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

Encode as a byte array of length 16 using lizard encoding. Returns None if the point is not a valid lizard encoding of a 16-byte value. See GroupElement::to_lizard. If the value was created using ElGamalEncryptable::from_lizard, this will return a valid value, but otherwise it will most likely return None.
Source§

impl Encryptable for Attribute

Source§

type EncryptedType = EncryptedAttribute

The encrypted version of this type.
Source§

type PublicKeyType = AttributeSessionPublicKey

The session public key type required for encryption.
Source§

type GlobalPublicKeyType = AttributeGlobalPublicKey

The global public key type required for offline encryption.
Source§

fn encrypt<R>( &self, public_key: &Self::PublicKeyType, rng: &mut R, ) -> Self::EncryptedType
where R: Rng + CryptoRng,

Encrypt this value using a session key.
Source§

fn encrypt_global<R>( &self, public_key: &Self::GlobalPublicKeyType, rng: &mut R, ) -> Self::EncryptedType
where R: Rng + CryptoRng,

Encrypt this value using a global key (offline encryption).
Source§

impl Eq for Attribute

Source§

impl From<GroupElement> for Attribute

Source§

fn from(value: GroupElement) -> Self

Converts to this type from the input type.
Source§

impl Hash for Attribute

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 Padded for Attribute

Source§

fn from_bytes_padded(data: &[u8]) -> Result<Self, Error>
where Self: Sized,

Encodes an arbitrary byte array using PKCS#7 padding. Read more
Source§

fn from_string_padded(text: &str) -> Result<Self, Error>
where Self: Sized,

Encodes a string using PKCS#7 padding. Read more
Source§

fn to_string_padded(&self) -> Result<String, Error>

Decodes back to the original string. Read more
Source§

fn to_bytes_padded(&self) -> Result<Vec<u8>, Error>

Decodes back to the original byte array. Read more
Source§

impl PartialEq for Attribute

Source§

fn eq(&self, other: &Attribute) -> 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 Attribute

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 Attribute

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.