Skip to main content

Decryptor

Struct Decryptor 

Source
pub struct Decryptor<C: Config<F, T>, F: PrimeField256, const T: usize, const R: usize> { /* private fields */ }
Expand description

Decrypts an arbitrary number of field elements in batches of R using the Poseidon permutation with state size T.

R must be T - 1 (the last element is reserved for capacity).

This symmetric cipher is implemented using the Poseidon PRP as a block cipher in duplex sponge mode, which is similar to CFB. The key lives in the capacity element.

Implementations§

Source§

impl<C: Config<F, T>, F: PrimeField256, const T: usize, const R: usize> Decryptor<C, F, T, R>

Source

pub fn new(key: F, nonce: F) -> Self

Constructs a Decryptor with the specified key and nonce.

Source

pub fn decrypt(&mut self, block: [F; R]) -> [F; R]

Decrypts a block of R field elements.

Source

pub fn finalize(self, checksum: F) -> Result<()>

Performs the final authentication.

Trait Implementations§

Source§

impl<C: Debug + Config<F, T>, F: Debug + PrimeField256, const T: usize, const R: usize> Debug for Decryptor<C, F, T, R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C, F, const T: usize, const R: usize> Freeze for Decryptor<C, F, T, R>

§

impl<C, F, const T: usize, const R: usize> RefUnwindSafe for Decryptor<C, F, T, R>

§

impl<C, F, const T: usize, const R: usize> Send for Decryptor<C, F, T, R>

§

impl<C, F, const T: usize, const R: usize> Sync for Decryptor<C, F, T, R>

§

impl<C, F, const T: usize, const R: usize> Unpin for Decryptor<C, F, T, R>

§

impl<C, F, const T: usize, const R: usize> UnsafeUnpin for Decryptor<C, F, T, R>

§

impl<C, F, const T: usize, const R: usize> UnwindSafe for Decryptor<C, F, T, R>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V