Trait schnorr_fun::adaptor::Adaptor
source · [−]pub trait Adaptor {
fn encryption_key_for(&self, decryption_key: &Scalar) -> Point;
fn verify_encrypted_signature(
&self,
verification_key: &Point<EvenY, impl Secrecy>,
encryption_key: &Point<impl Normalized, impl Secrecy>,
message: Message<'_, impl Secrecy>,
encrypted_signature: &EncryptedSignature<impl Secrecy>
) -> bool;
fn decrypt_signature(
&self,
decryption_key: Scalar<impl Secrecy>,
encrypted_signature: EncryptedSignature<impl Secrecy>
) -> Signature;
fn recover_decryption_key(
&self,
encryption_key: &Point<impl Normalized, impl Secrecy>,
encrypted_signature: &EncryptedSignature<impl Secrecy>,
signature: &Signature<impl Secrecy>
) -> Option<Scalar>;
}
Expand description
Extension trait adding the algorithms for the adaptor signature scheme to instances of Schnorr
.
Required Methods
fn encryption_key_for(&self, decryption_key: &Scalar) -> Point
fn encryption_key_for(&self, decryption_key: &Scalar) -> Point
Derives the public encryption key corresponding to a secret decryption key.
Example
let decryption_key = Scalar::random(&mut rand::thread_rng());
let encryption_key = schnorr.encryption_key_for(&decryption_key);
fn verify_encrypted_signature(
&self,
verification_key: &Point<EvenY, impl Secrecy>,
encryption_key: &Point<impl Normalized, impl Secrecy>,
message: Message<'_, impl Secrecy>,
encrypted_signature: &EncryptedSignature<impl Secrecy>
) -> bool
fn verify_encrypted_signature(
&self,
verification_key: &Point<EvenY, impl Secrecy>,
encryption_key: &Point<impl Normalized, impl Secrecy>,
message: Message<'_, impl Secrecy>,
encrypted_signature: &EncryptedSignature<impl Secrecy>
) -> bool
Verifies an encrypted signature is valid i.e. if it is decrypted it will yield a signature
on message
under verification_key
.
See synopsis for usage.
fn decrypt_signature(
&self,
decryption_key: Scalar<impl Secrecy>,
encrypted_signature: EncryptedSignature<impl Secrecy>
) -> Signature
fn decrypt_signature(
&self,
decryption_key: Scalar<impl Secrecy>,
encrypted_signature: EncryptedSignature<impl Secrecy>
) -> Signature
Decrypts an encrypted signature yielding the signature.
There are two crucial things to understand when calling this:
- You should be certain that the encrypted signature is what you think it is by calling
verify_encrypted_signature
on it first. - Once you give the decrypted signature to anyone who has seen
encrypted_signature
they will be able to learndecryption_key
by callingrecover_decryption_key
.
See synopsis for an example
fn recover_decryption_key(
&self,
encryption_key: &Point<impl Normalized, impl Secrecy>,
encrypted_signature: &EncryptedSignature<impl Secrecy>,
signature: &Signature<impl Secrecy>
) -> Option<Scalar>
fn recover_decryption_key(
&self,
encryption_key: &Point<impl Normalized, impl Secrecy>,
encrypted_signature: &EncryptedSignature<impl Secrecy>,
signature: &Signature<impl Secrecy>
) -> Option<Scalar>
Recovers the decryption key given an encrypted signature and the signature that was decrypted from it.
If the signature
was not the one decrypted from the encrypted_signature
then this function
returns None
. If it returns Some(decryption_key)
, then signature
is the unique
signature obtained by decrypting encrypted_signature
with the decryption_key
corresponding to
encryption_key
. In other words, if you already know that encrypted_signature
is valid you do not
have to call Schnorr::verify
on signature
before calling this function because this function returning
Some
implies it.
See synopsis for an example