pub trait Signer:
Clone
+ Debug
+ PartialEq {
Show 17 methods
// Required methods
fn new<RNG: RngCore + CryptoRng>(
party_id: u32,
key_ids: &[u32],
num_signers: u32,
num_keys: u32,
threshold: u32,
rng: &mut RNG,
) -> Self;
fn load(state: &SignerState) -> Self;
fn save(&self) -> SignerState;
fn get_id(&self) -> u32;
fn get_key_ids(&self) -> Vec<u32>;
fn get_num_parties(&self) -> u32;
fn get_poly_commitments<RNG: RngCore + CryptoRng>(
&self,
ctx: &[u8],
rng: &mut RNG,
) -> Vec<PolyCommitment>;
fn reset_polys<RNG: RngCore + CryptoRng>(&mut self, rng: &mut RNG);
fn clear_polys(&mut self);
fn get_shares(&self) -> HashMap<u32, HashMap<u32, Scalar>>;
fn compute_secrets(
&mut self,
shares: &HashMap<u32, HashMap<u32, Scalar>>,
polys: &HashMap<u32, PolyCommitment>,
ctx: &[u8],
) -> Result<(), HashMap<u32, DkgError>>;
fn gen_nonces<RNG: RngCore + CryptoRng>(
&mut self,
secret_key: &Scalar,
rng: &mut RNG,
) -> Vec<PublicNonce>;
fn compute_intermediate(
msg: &[u8],
signer_ids: &[u32],
key_ids: &[u32],
nonces: &[PublicNonce],
) -> (Vec<Point>, Point);
fn validate_party_id(
signer_id: u32,
party_id: u32,
signer_key_ids: &HashMap<u32, HashSet<u32>>,
) -> bool;
fn sign(
&self,
msg: &[u8],
signer_ids: &[u32],
key_ids: &[u32],
nonces: &[PublicNonce],
) -> Vec<SignatureShare>;
fn sign_schnorr(
&self,
msg: &[u8],
signer_ids: &[u32],
key_ids: &[u32],
nonces: &[PublicNonce],
) -> Vec<SignatureShare>;
fn sign_taproot(
&self,
msg: &[u8],
signer_ids: &[u32],
key_ids: &[u32],
nonces: &[PublicNonce],
merkle_root: Option<MerkleRoot>,
) -> Vec<SignatureShare>;
}Expand description
A trait which provides a common Signer interface for v1 and v2
Required Methods§
Sourcefn new<RNG: RngCore + CryptoRng>(
party_id: u32,
key_ids: &[u32],
num_signers: u32,
num_keys: u32,
threshold: u32,
rng: &mut RNG,
) -> Self
fn new<RNG: RngCore + CryptoRng>( party_id: u32, key_ids: &[u32], num_signers: u32, num_keys: u32, threshold: u32, rng: &mut RNG, ) -> Self
Create a new Signer
Sourcefn load(state: &SignerState) -> Self
fn load(state: &SignerState) -> Self
Load a signer from the previously saved state
Sourcefn save(&self) -> SignerState
fn save(&self) -> SignerState
Save the state required to reconstruct the party
Sourcefn get_key_ids(&self) -> Vec<u32>
fn get_key_ids(&self) -> Vec<u32>
Get all key IDs for this signer
Sourcefn get_num_parties(&self) -> u32
fn get_num_parties(&self) -> u32
Get the total number of parties
Sourcefn get_poly_commitments<RNG: RngCore + CryptoRng>(
&self,
ctx: &[u8],
rng: &mut RNG,
) -> Vec<PolyCommitment>
fn get_poly_commitments<RNG: RngCore + CryptoRng>( &self, ctx: &[u8], rng: &mut RNG, ) -> Vec<PolyCommitment>
Get all poly commitments for this signer and the passed context
Sourcefn reset_polys<RNG: RngCore + CryptoRng>(&mut self, rng: &mut RNG)
fn reset_polys<RNG: RngCore + CryptoRng>(&mut self, rng: &mut RNG)
Reset all polynomials for this signer
Sourcefn clear_polys(&mut self)
fn clear_polys(&mut self)
Clear all polynomials for this signer
Get all private shares for this signer
Sourcefn compute_secrets(
&mut self,
shares: &HashMap<u32, HashMap<u32, Scalar>>,
polys: &HashMap<u32, PolyCommitment>,
ctx: &[u8],
) -> Result<(), HashMap<u32, DkgError>>
fn compute_secrets( &mut self, shares: &HashMap<u32, HashMap<u32, Scalar>>, polys: &HashMap<u32, PolyCommitment>, ctx: &[u8], ) -> Result<(), HashMap<u32, DkgError>>
Compute all secrets for this signer
Sourcefn gen_nonces<RNG: RngCore + CryptoRng>(
&mut self,
secret_key: &Scalar,
rng: &mut RNG,
) -> Vec<PublicNonce>
fn gen_nonces<RNG: RngCore + CryptoRng>( &mut self, secret_key: &Scalar, rng: &mut RNG, ) -> Vec<PublicNonce>
Generate all nonces for this signer
Sourcefn compute_intermediate(
msg: &[u8],
signer_ids: &[u32],
key_ids: &[u32],
nonces: &[PublicNonce],
) -> (Vec<Point>, Point)
fn compute_intermediate( msg: &[u8], signer_ids: &[u32], key_ids: &[u32], nonces: &[PublicNonce], ) -> (Vec<Point>, Point)
Compute intermediate values
Sourcefn validate_party_id(
signer_id: u32,
party_id: u32,
signer_key_ids: &HashMap<u32, HashSet<u32>>,
) -> bool
fn validate_party_id( signer_id: u32, party_id: u32, signer_key_ids: &HashMap<u32, HashSet<u32>>, ) -> bool
Validate that signer_id owns party_id
Sourcefn sign(
&self,
msg: &[u8],
signer_ids: &[u32],
key_ids: &[u32],
nonces: &[PublicNonce],
) -> Vec<SignatureShare>
fn sign( &self, msg: &[u8], signer_ids: &[u32], key_ids: &[u32], nonces: &[PublicNonce], ) -> Vec<SignatureShare>
Sign msg using all this signer’s keys
Sourcefn sign_schnorr(
&self,
msg: &[u8],
signer_ids: &[u32],
key_ids: &[u32],
nonces: &[PublicNonce],
) -> Vec<SignatureShare>
fn sign_schnorr( &self, msg: &[u8], signer_ids: &[u32], key_ids: &[u32], nonces: &[PublicNonce], ) -> Vec<SignatureShare>
Sign msg using all this signer’s keys
Sourcefn sign_taproot(
&self,
msg: &[u8],
signer_ids: &[u32],
key_ids: &[u32],
nonces: &[PublicNonce],
merkle_root: Option<MerkleRoot>,
) -> Vec<SignatureShare>
fn sign_taproot( &self, msg: &[u8], signer_ids: &[u32], key_ids: &[u32], nonces: &[PublicNonce], merkle_root: Option<MerkleRoot>, ) -> Vec<SignatureShare>
Sign msg using all this signer’s keys and a tweaked 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.