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

Encapsulates an encrypted data

Implementations§

source§

impl PoseidonCipher

source

pub fn initial_state_circuit<C>( composer: &mut C, ks0: Witness, ks1: Witness, nonce: Witness ) -> [Witness; 5]where C: Composer,

Returns the initial state of the encryption within a composer circuit

source§

impl PoseidonCipher

source

pub const fn new(cipher: [BlsScalar; 3]) -> Self

PoseidonCipher constructor

source

pub const fn capacity() -> usize

Maximum number of scalars allowed per message

source

pub const fn cipher_size() -> usize

Number of scalars used in a cipher

source

pub const fn cipher_size_bytes() -> usize

Number of bytes used by from/to bytes PoseidonCipher function

source

pub fn initial_state(secret: &JubJubAffine, nonce: BlsScalar) -> [BlsScalar; 5]

Returns the initial state of the encryption

source

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

Getter for the cipher

source

pub fn encrypt( message: &[BlsScalar], secret: &JubJubAffine, nonce: &BlsScalar ) -> Self

Encrypt a slice of scalars into an internal cipher representation

The message size will be truncated to PoseidonCipher::capacity() bits

source

pub fn decrypt( &self, secret: &JubJubAffine, nonce: &BlsScalar ) -> Option<[BlsScalar; 2]>

Perform the decrypt of a previously encrypted message.

Will return None if the decryption fails.

Trait Implementations§

source§

impl Clone for PoseidonCipher

source§

fn clone(&self) -> PoseidonCipher

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 PoseidonCipher

source§

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

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

impl Default for PoseidonCipher

source§

fn default() -> PoseidonCipher

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

impl Ord for PoseidonCipher

source§

fn cmp(&self, other: &PoseidonCipher) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<PoseidonCipher> for PoseidonCipher

source§

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

source§

fn partial_cmp(&self, other: &PoseidonCipher) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serializable<CIPHER_BYTES_SIZE> for PoseidonCipher

source§

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

Create an instance from a previous PoseidonCipher::to_bytes function

source§

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

Convert the instance to a bytes representation

§

type Error = Error

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

const SIZE: usize = N

The size of
source§

impl Copy for PoseidonCipher

source§

impl Eq for PoseidonCipher

source§

impl StructuralEq for PoseidonCipher

source§

impl StructuralPartialEq for PoseidonCipher

Auto Trait Implementations§

Blanket Implementations§

source§

impl<'a, C, A> Annotation<&'a C> for Awhere A: Annotation<C>,

source§

fn from_child(t: &&'a C) -> A

Compute the annotation from the child.
source§

impl<'a, C, A> Annotation<&'a mut C> for Awhere A: Annotation<C>,

source§

fn from_child(t: &&'a mut C) -> A

Compute the annotation from the child.
source§

impl<C, A> Annotation<Arc<C>> for Awhere A: Annotation<C>,

source§

fn from_child(t: &Arc<C>) -> A

Compute the annotation from the child.
source§

impl<C, A> Annotation<Box<C, Global>> for Awhere A: Annotation<C>,

source§

fn from_child(t: &Box<C, Global>) -> A

Compute the annotation from the child.
source§

impl<C, A> Annotation<Rc<C>> for Awhere A: Annotation<C>,

source§

fn from_child(t: &Rc<C>) -> A

Compute the annotation from the child.
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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · 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

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<K> Keyed<K> for K

source§

fn key(&self) -> &K

Return a reference to the key of the leaf type
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 `
§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.