pub struct Message { /* private fields */ }
Expand description

Message structure with value commitment

Implementations§

source§

impl Message

source

pub fn new<R: RngCore + CryptoRng>( rng: &mut R, r: &JubJubScalar, psk: &PublicSpendKey, value: u64 ) -> Self

Create a new message

r will be later used to decrypt the value and blinding factor

source

pub fn to_hash_inputs(&self) -> [BlsScalar; 6]

Represent the message as a sequence of scalars to be used as input for sponge hash functions

It is composed by 3 scalars, in order:

  • Value commitment X
  • Value commitment Y
  • Nonce

And also appends the scalars that composes the PoseidonCipher

source

pub fn hash(&self) -> BlsScalar

Sponge hash of the message hash inputs representation

source

pub const fn value_commitment(&self) -> &JubJubExtended

Value commitment representation of the message

source

pub const fn nonce(&self) -> &BlsScalar

Nonce used for the encryption of the value and blinding factor

source

pub const fn cipher(&self) -> &[BlsScalar; 3]

Returns the cipher of the encrypted data

source

pub fn decrypt( &self, r: &JubJubScalar, psk: &PublicSpendKey ) -> Result<(u64, JubJubScalar), Error>

Decrypt the value and blinding factor provided the r used in the creation of the message

Trait Implementations§

source§

impl Clone for Message

source§

fn clone(&self) -> Message

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Message

source§

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

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

impl Default for Message

source§

fn default() -> Message

Returns the “default value” for a type. Read more
source§

impl PartialEq<Message> for Message

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serializable<{ JubJubAffine::SIZE + JubJubScalar::SIZE + PoseidonCipher::SIZE }> for Message

§

type Error = Error

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

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

Serialize Self into a [[u8; N]].
source§

fn from_bytes(bytes: &[u8; 160]) -> Result<Self, Self::Error>

Deserialize a [&[u8; N]] into Self, it might be fail.
source§

const SIZE: usize = N

The size of
source§

impl Copy for Message

source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T, const N: usize> DeserializableSlice<N> for Twhere T: Serializable<N>,

source§

fn from_slice(buf: &[u8]) -> Result<Self, Self::Error>where Self: Sized, Self::Error: BadLength,

Deserialize a slice of u8 into Self
source§

fn from_reader<R>(buf: &mut R) -> Result<Self, Self::Error>where R: Read, Self: Sized, Self::Error: BadLength,

Deserialize the type reading the bytes from a reader. The bytes read are removed from the reader.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, const N: usize> ParseHexStr<N> for Twhere T: Serializable<N>,

source§

fn from_hex_str(s: &str) -> Result<Self, Self::Error>where Self: Sized, Self::Error: BadLength + InvalidChar,

Parse a string slice as bytes hex representation and returns `
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.