pub struct AdcpeEncryptor { /* private fields */ }Expand description
ADCPE vector encryptor.
Holds a secret orthogonal matrix derived from the encryption key. The matrix is generated via Gram-Schmidt orthogonalization of a seeded pseudo-random matrix.
Implementations§
Source§impl AdcpeEncryptor
impl AdcpeEncryptor
Sourcepub fn new(key: &[u8; 32], config: &AdcpeConfig) -> Result<Self>
pub fn new(key: &[u8; 32], config: &AdcpeConfig) -> Result<Self>
Create a new ADCPE encryptor from a 32-byte key.
The key is used to seed a PRNG that generates the random matrix, which is then orthogonalized via Gram-Schmidt.
Sourcepub fn encrypt(&mut self, vector: &[f64]) -> Result<Vec<f64>>
pub fn encrypt(&mut self, vector: &[f64]) -> Result<Vec<f64>>
Encrypt a single embedding vector.
Returns the transformed vector with the same dimensionality.
Sourcepub fn decrypt(&self, encrypted: &[f64]) -> Result<Vec<f64>>
pub fn decrypt(&self, encrypted: &[f64]) -> Result<Vec<f64>>
Decrypt a single embedding vector (inverse transformation).
Note: if noise was added during encryption, decryption will not recover the exact original vector.
Sourcepub fn encrypt_batch(&mut self, vectors: &[Vec<f64>]) -> Result<Vec<Vec<f64>>>
pub fn encrypt_batch(&mut self, vectors: &[Vec<f64>]) -> Result<Vec<Vec<f64>>>
Encrypt a batch of vectors.
Sourcepub fn decrypt_batch(&self, encrypted: &[Vec<f64>]) -> Result<Vec<Vec<f64>>>
pub fn decrypt_batch(&self, encrypted: &[Vec<f64>]) -> Result<Vec<Vec<f64>>>
Decrypt a batch of vectors.
Sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
Get the dimensionality.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AdcpeEncryptor
impl RefUnwindSafe for AdcpeEncryptor
impl Send for AdcpeEncryptor
impl Sync for AdcpeEncryptor
impl Unpin for AdcpeEncryptor
impl UnsafeUnpin for AdcpeEncryptor
impl UnwindSafe for AdcpeEncryptor
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