Struct recrypt::api::Recrypt [−]
pub struct Recrypt<H, S, R> { /* fields omitted */ }
Expand description
Recrypt public API - 256-bit
Implementations
impl Recrypt<Sha256, Ed25519, RandomBytes<DefaultRng>>
impl Recrypt<Sha256, Ed25519, RandomBytes<DefaultRng>>
pub fn new() -> Recrypt<Sha256, Ed25519, RandomBytes<DefaultRng>>
pub fn new() -> Recrypt<Sha256, Ed25519, RandomBytes<DefaultRng>>
Construct a new Recrypt with pre-selected CSPRNG implementation.
The RNG will periodically reseed itself from the system’s best entropy source.
pub fn new_with_rand(r: CR) -> Recrypt<Sha256, Ed25519, RandomBytes<CR>>
pub fn new_with_rand(r: CR) -> Recrypt<Sha256, Ed25519, RandomBytes<CR>>
Construct a Recrypt with the given RNG. Unless you have specific needs using new()
is recommended.
Trait Implementations
impl<R: RandomBytesGen, H: Sha256Hashing, S: Ed25519Signing> CryptoOps for Recrypt<H, S, R>
impl<R: RandomBytesGen, H: Sha256Hashing, S: Ed25519Signing> CryptoOps for Recrypt<H, S, R>
fn gen_plaintext(&self) -> Plaintext
fn gen_plaintext(&self) -> Plaintext
Using the random_bytes, generate a random element of G_T, which is one of the rth roots of unity in FP12. Read more
fn derive_symmetric_key(
&self,
decrypted_value: &Plaintext
) -> DerivedSymmetricKey
fn derive_symmetric_key(
&self,
decrypted_value: &Plaintext
) -> DerivedSymmetricKey
Convert our plaintext into a DecryptedSymmetricKey by hashing it.
Typically you either use derive_private_key
or derive_symmetric_key
but not both. Read more
fn derive_private_key(&self, plaintext: &Plaintext) -> PrivateKey
fn derive_private_key(&self, plaintext: &Plaintext) -> PrivateKey
Derive a private key for a plaintext by hashing it and modding it by the prime.
Typically you either use derive_private_key
or derive_symmetric_key
but not both. Read more
fn encrypt(
&self,
plaintext: &Plaintext,
to_public_key: &PublicKey,
signing_keypair: &SigningKeypair
) -> Result<EncryptedValue, RecryptErr>
fn encrypt(
&self,
plaintext: &Plaintext,
to_public_key: &PublicKey,
signing_keypair: &SigningKeypair
) -> Result<EncryptedValue, RecryptErr>
Encrypt the plaintext to the to_public_key
. Read more
fn decrypt(
&self,
encrypted_value: EncryptedValue,
private_key: &PrivateKey
) -> Result<Plaintext, RecryptErr>
fn decrypt(
&self,
encrypted_value: EncryptedValue,
private_key: &PrivateKey
) -> Result<Plaintext, RecryptErr>
Decrypt the value using private_key
. Read more
fn transform(
&self,
encrypted_value: EncryptedValue,
transform_key: TransformKey,
signing_keypair: &SigningKeypair
) -> Result<EncryptedValue, RecryptErr>
fn transform(
&self,
encrypted_value: EncryptedValue,
transform_key: TransformKey,
signing_keypair: &SigningKeypair
) -> Result<EncryptedValue, RecryptErr>
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
. Read more
impl Default for Recrypt<Sha256, Ed25519, RandomBytes<DefaultRng>>
impl Default for Recrypt<Sha256, Ed25519, RandomBytes<DefaultRng>>
impl<H, S, CR: RngCore + CryptoRng> Ed25519Ops for Recrypt<H, S, RandomBytes<CR>>
impl<H, S, CR: RngCore + CryptoRng> Ed25519Ops for Recrypt<H, S, RandomBytes<CR>>
fn generate_ed25519_key_pair(&self) -> SigningKeypair
fn generate_ed25519_key_pair(&self) -> SigningKeypair
Generate a signing key pair for use with the Ed25519Signing
trait using the random number generator
used to back the RandomBytes
struct.
impl<R: RandomBytesGen, H: Sha256Hashing, S: Ed25519Signing> KeyGenOps for Recrypt<H, S, R>
impl<R: RandomBytesGen, H: Sha256Hashing, S: Ed25519Signing> KeyGenOps for Recrypt<H, S, R>
fn compute_public_key(
&self,
private_key: &PrivateKey
) -> Result<PublicKey, RecryptErr>
fn compute_public_key(
&self,
private_key: &PrivateKey
) -> Result<PublicKey, RecryptErr>
Compute a PublicKey
given a PrivateKey
fn random_private_key(&self) -> PrivateKey
fn random_private_key(&self) -> PrivateKey
Generate a random private key. Read more
fn generate_key_pair(&self) -> Result<(PrivateKey, PublicKey), RecryptErr>
fn generate_key_pair(&self) -> Result<(PrivateKey, PublicKey), RecryptErr>
Generate a public/private keypair. Read more
fn generate_transform_key(
&self,
from_private_key: &PrivateKey,
to_public_key: &PublicKey,
signing_keypair: &SigningKeypair
) -> Result<TransformKey, RecryptErr>
fn generate_transform_key(
&self,
from_private_key: &PrivateKey,
to_public_key: &PublicKey,
signing_keypair: &SigningKeypair
) -> Result<TransformKey, RecryptErr>
Generate a transform key which is used to delegate to the to_public_key
from the from_private_key
. Read more
impl<H: Sha256Hashing, S, CR: RngCore + CryptoRng> SchnorrOps for Recrypt<H, S, RandomBytes<CR>>
impl<H: Sha256Hashing, S, CR: RngCore + CryptoRng> SchnorrOps for Recrypt<H, S, RandomBytes<CR>>
fn schnorr_sign<A: Hashable>(
&self,
priv_key: &PrivateKey,
pub_key: &PublicKey,
message: &A
) -> SchnorrSignature
fn schnorr_sign<A: Hashable>(
&self,
priv_key: &PrivateKey,
pub_key: &PublicKey,
message: &A
) -> SchnorrSignature
Create a signature for the message using priv_key
. Read more
fn schnorr_verify<A: Hashable>(
&self,
pub_key: &PublicKey,
augmenting_priv_key: Option<&PrivateKey>,
message: &A,
signature: SchnorrSignature
) -> bool
fn schnorr_verify<A: Hashable>(
&self,
pub_key: &PublicKey,
augmenting_priv_key: Option<&PrivateKey>,
message: &A,
signature: SchnorrSignature
) -> bool
Verify that the message was signed by the matching private key to pub_key
. Note that if pub_key
was augmented
the private key used in the augmentation should be passed in as augmenting_priv_key
. Read more