Trait NonceGen

Source
pub trait NonceGen {
    type Hash: Hash32;

    // Required method
    fn begin_derivation(
        &self,
        secret: &Scalar<Secret, impl ZeroChoice>,
    ) -> Self::Hash;
}
Expand description

A trait for hash based nonce gneration.

A NonceGen is a type that can repeatadly be asked to inititalize a hash state with begin_derivation that appear random for anyone who doesn’t know the secret.

There are two main implementations of this trait:

  • Deterministic: just adds the secret to the hash and returns it.
  • Synthetic: adds randomness into the secret before hashing it.

In general it’s better to use the derive_nonce macro than to call begin_derivation directly.

Required Associated Types§

Source

type Hash: Hash32

The type of hash that begin_derivation will return.

Required Methods§

Source

fn begin_derivation( &self, secret: &Scalar<Secret, impl ZeroChoice>, ) -> Self::Hash

Takes a secret Scalar and outputs a hash. Before turining this hash into the nonce, you must add a secret input and all the public inputs from the scheme into the hash. So for a signature scheme for example you would add your secret key, the message and the public key.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<H> NonceGen for Deterministic<H>
where H: Hash32,

Source§

type Hash = H

Source§

impl<H, R> NonceGen for Synthetic<H, R>
where H: Hash32, R: NonceRng,

Source§

type Hash = H