pub struct Encryptor<C: Config<F, T>, F: PrimeField256, const T: usize, const R: usize> { /* private fields */ }Expand description
Encrypts 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> Encryptor<C, F, T, R>
impl<C: Config<F, T>, F: PrimeField256, const T: usize, const R: usize> Encryptor<C, F, T, R>
Sourcepub fn with_nonce(key: F, nonce: F) -> Self
pub fn with_nonce(key: F, nonce: F) -> Self
Constructs an Encryptor with the specified key and nonce.
WARNING: NEVER reuse the same (key, nonce) pair to encrypt two or more different messages, as doing so would leak information about the plaintexts!
Sourcepub fn new(key: F) -> Self
pub fn new(key: F) -> Self
Constructs an Encryptor with the specified key and a securely generated fresh nonce.
You can retrieve the nonce by calling Self::nonce.
Trait Implementations§
Auto Trait Implementations§
impl<C, F, const T: usize, const R: usize> Freeze for Encryptor<C, F, T, R>
impl<C, F, const T: usize, const R: usize> RefUnwindSafe for Encryptor<C, F, T, R>
impl<C, F, const T: usize, const R: usize> Send for Encryptor<C, F, T, R>
impl<C, F, const T: usize, const R: usize> Sync for Encryptor<C, F, T, R>
impl<C, F, const T: usize, const R: usize> Unpin for Encryptor<C, F, T, R>
impl<C, F, const T: usize, const R: usize> UnsafeUnpin for Encryptor<C, F, T, R>
impl<C, F, const T: usize, const R: usize> UnwindSafe for Encryptor<C, F, T, R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more