Trait recrypt::api::CryptoOps [−]
pub trait CryptoOps { fn gen_plaintext(&mut self) -> Plaintext; fn derive_symmetric_key(
&self,
decrypted_value: &Plaintext
) -> DerivedSymmetricKey; fn encrypt(
&mut self,
plaintext: Plaintext,
to_public_key: PublicKey,
public_signing_key: PublicSigningKey,
private_signing_key: PrivateSigningKey
) -> Result<EncryptedValue, ApiErr>; fn decrypt(
&self,
encrypted_value: EncryptedValue,
private_key: PrivateKey
) -> Result<Plaintext, ApiErr>; fn transform(
&mut self,
encrypted_value: EncryptedValue,
transform_key: TransformKey,
public_signing_key: PublicSigningKey,
private_signing_key: PrivateSigningKey
) -> Result<EncryptedValue, ApiErr>; }
Encrypt, Decrypt, Transform, and supporting operations.
Required Methods
fn gen_plaintext(&mut self) -> Plaintext
Using the random_bytes, generate a random element of G_T, which is one of the rth roots of unity in FP12.
fn derive_symmetric_key(
&self,
decrypted_value: &Plaintext
) -> DerivedSymmetricKey
&self,
decrypted_value: &Plaintext
) -> DerivedSymmetricKey
Convert our plaintext into a DecryptedSymmetricKey by hashing it.
fn encrypt(
&mut self,
plaintext: Plaintext,
to_public_key: PublicKey,
public_signing_key: PublicSigningKey,
private_signing_key: PrivateSigningKey
) -> Result<EncryptedValue, ApiErr>
&mut self,
plaintext: Plaintext,
to_public_key: PublicKey,
public_signing_key: PublicSigningKey,
private_signing_key: PrivateSigningKey
) -> Result<EncryptedValue, ApiErr>
Encrypt the plaintext to the to_public_key
.
Arguments
plaintext
- value to encrypt.to_public_key
- identity to encrypt to.public_signing_key
- public signing key of the person (or device) who is encrypting this valueprivate_signing_key
- private signing key of the person (or device) who is encrypting this value
Return
EncryptedValue which can be decrypted by the matching private key of to_public_key
or ApiErr.
fn decrypt(
&self,
encrypted_value: EncryptedValue,
private_key: PrivateKey
) -> Result<Plaintext, ApiErr>
&self,
encrypted_value: EncryptedValue,
private_key: PrivateKey
) -> Result<Plaintext, ApiErr>
Decrypt the value using private_key
.
Arguments
encrypted_value
- value we want to decrypt.private_key
- PrivateKey which we want to use to decrypt the EncryptedValue.
Return
An error if the key didn't match or something was corrupted in the EncryptedValue, otherwise the recovered plaintext.
fn transform(
&mut self,
encrypted_value: EncryptedValue,
transform_key: TransformKey,
public_signing_key: PublicSigningKey,
private_signing_key: PrivateSigningKey
) -> Result<EncryptedValue, ApiErr>
&mut self,
encrypted_value: EncryptedValue,
transform_key: TransformKey,
public_signing_key: PublicSigningKey,
private_signing_key: PrivateSigningKey
) -> Result<EncryptedValue, ApiErr>
Transform the value encrypted_value
using the transform_key
.
The returned value can be decrypted by the private key associated to the to_public_key
in the transform_key
.
The transformed value will be signed using the private_signing_key
and will embed
the public_signing_key
into the returned value.
Implementors
impl<R: RandomBytesGen, H: Sha256Hashing, S: Ed25519Signing> CryptoOps for Api<H, S, R>