### KeygenBuilder::start Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/type.KeygenBuilder.html?search= Starts the key generation protocol. ```APIDOC ## KeygenBuilder::start ### Description Starts the key generation protocol execution. ### Parameters - **rng** (&mut R) - A cryptographically secure random number generator. - **party** (M) - The party implementation for the protocol. ``` -------------------------------- ### KeygenBuilder::start Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/type.KeygenBuilder.html Starts the key generation protocol execution. ```APIDOC ## KeygenBuilder::start(rng, party) ### Description Starts the key generation protocol and returns the resulting key share. ### Parameters - **rng** (RngCore + CryptoRng) - Required - A cryptographically secure random number generator. - **party** (Mpc) - Required - The party implementation for the protocol. ``` -------------------------------- ### start Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.AuxInfoGenerationBuilder.html?search=u32+-%3E+bool Executes the auxiliary info generation procedure. ```APIDOC ## pub async fn start(self, rng: &mut R, party: M) -> Result, KeyRefreshError> ### Description Carries out the auxiliary info generation procedure. This operation is asynchronous and may take significant time to complete. ### Parameters - **rng** (R) - A cryptographically secure random number generator. - **party** (M) - The party implementation handling protocol messages. ``` -------------------------------- ### start Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.AuxInfoGenerationBuilder.html Executes the auxiliary info generation procedure asynchronously. ```APIDOC ## pub async fn start(self, rng: &mut R, party: M) -> Result, KeyRefreshError> ### Description Carries out the auxiliary info generation procedure. Note that this operation is computationally intensive and takes time to complete. ### Parameters - **rng** (&mut R) - Required - A cryptographically secure random number generator. - **party** (M) - Required - The party implementation for the MPC protocol. ``` -------------------------------- ### Configuration Methods Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.AuxInfoGenerationBuilder.html Methods to configure the builder before starting the generation process. ```APIDOC ## Configuration Methods ### set_digest(self) -> GenericKeyRefreshBuilder<'a, T, L, D2> Specifies a different hash function to use for the protocol. ### set_progress_tracer(self, tracer: &'a mut dyn Tracer) -> Self Sets a tracer to track the progress of the protocol execution. ### enforce_reliable_broadcast(self, v: bool) -> Self Configures whether to enforce a reliable broadcast channel by adding an extra communication round. Default is true. ### precompute_multiexp_tables(self, v: bool) -> Self Enables precomputation of multiexponentiation tables to optimize signing and presigning performance. ### precompute_crt(self, v: bool) -> Self Enables precomputation of CRT parameters to optimize modular exponentiation in Zero-Knowledge proofs. ``` -------------------------------- ### Start Key Generation Source: https://docs.rs/cggmp21/latest/cggmp21/index.html?search= Initiates the key generation protocol to produce an incomplete key share. ```rust let incomplete_key_share = cggmp21::keygen::(eid, i, n) .set_threshold(t) .start(&mut OsRng, party) .await?; ``` -------------------------------- ### KeygenBuilder Construction and Execution Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/type.KeygenBuilder.html Methods to initialize the builder and start the key generation protocol. ```rust pub fn new( eid: ExecutionId<'a>, i: u16, n: u16, ) -> GenericKeygenBuilder<'a, E, NonThreshold, L, D> ``` ```rust pub async fn start( self, rng: &mut R, party: M, ) -> Result>, KeygenError> where R: RngCore + CryptoRng, M: Mpc>, ``` ```rust pub fn into_state_machine( self, rng: &'a mut R, ) -> impl StateMachine>, KeygenError>, Msg = Msg> + 'a where R: RngCore + CryptoRng, ``` -------------------------------- ### Starting Key Generation Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/struct.GenericKeygenBuilder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods to execute the key generation protocol, either directly or via a state machine. ```rust pub async fn start( self, rng: &mut R, party: M, ) -> Result>, KeygenError> where R: RngCore + CryptoRng, M: Mpc>, ``` ```rust pub fn into_state_machine( self, rng: &'a mut R, ) -> impl StateMachine>, KeygenError>, Msg = Msg> + 'a where R: RngCore + CryptoRng, ``` -------------------------------- ### KeygenBuilder Execution Methods Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/type.KeygenBuilder.html?search=u32+-%3E+bool Methods to start the key generation protocol. ```APIDOC ## Execution Methods - **start(rng: &mut R, party: M) -> Result>, KeygenError>**: Starts the key generation protocol asynchronously. - **into_state_machine(rng: &'a mut R) -> impl StateMachine**: Returns a state machine for the key generation protocol (requires `state-machine` feature). ``` -------------------------------- ### SigningBuilder::sign Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.SigningBuilder.html?search=std%3A%3Avec Starts the signing protocol asynchronously. ```APIDOC ## pub async fn sign(self, rng: &mut R, party: M, message_to_sign: DataToSign) -> Result, SigningError> ### Description Starts the signing protocol to generate a signature for the provided data. ### Parameters - **rng** (&mut R) - Required - A cryptographically secure random number generator. - **party** (M) - Required - The MPC party implementation for communication. - **message_to_sign** (DataToSign) - Required - The data to be signed. ``` -------------------------------- ### SigningBuilder::generate_presignature Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.SigningBuilder.html?search=std%3A%3Avec Starts the presignature generation protocol asynchronously. ```APIDOC ## pub async fn generate_presignature(self, rng: &mut R, party: M) -> Result, SigningError> ### Description Starts the presignature generation protocol. ### Parameters - **rng** (&mut R) - Required - A cryptographically secure random number generator. - **party** (M) - Required - The MPC party implementation for communication. ``` -------------------------------- ### Execute key refresh Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.KeyRefreshBuilder.html?search= Starts the key refresh procedure, which is a time-intensive operation. ```rust pub async fn start( self, rng: &mut R, party: M, ) -> Result, KeyRefreshError> where R: RngCore + CryptoRng, M: Mpc>, E: Curve, L: SecurityLevel, D: Digest + Clone + 'static, ``` -------------------------------- ### Implement ValidateFromParts for a custom struct Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/trait.ValidateFromParts.html?search= An example demonstrating how to implement ValidateFromParts to perform optimized validation when components are already validated. ```rust use key_share::{Valid, Validate, ValidateFromParts}; use generic_ec::Curve; pub struct KeyShare { core: key_share::DirtyCoreKeyShare, aux: AuxData, } // Validation for the whole key share can be expensive impl Validate for KeyShare { type Error = InvalidKeyShare; fn is_valid(&self) -> Result<(), Self::Error> { self.core.is_valid()?; self.aux.is_valid()?; check_consistency(&self.core, &self.aux) } } fn check_consistency( core: &key_share::DirtyCoreKeyShare, aux: &AuxData, ) -> Result<(), InvalidKeyShare> { // check that `core` and `aux` seem to match each other } // Sometimes, we already validated that `core` and `aux` are valid, so we can perform cheaper validation: impl ValidateFromParts<(Valid>, Valid)> for KeyShare { fn validate_parts(parts: &(Valid>, Valid)) -> Result<(), Self::Error> { check_consistency(&parts.0, &parts.1) } fn from_parts(parts: (Valid>, Valid)) -> Self { Self { core: parts.0.into_inner(), aux: parts.1.into_inner() } } } ``` -------------------------------- ### Implement SecurityLevel128 Source: https://docs.rs/cggmp21/latest/cggmp21/security_level/trait.KeygenSecurityLevel.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Example implementation of the SecurityLevel trait for the SecurityLevel128 type. ```rust impl SecurityLevel for SecurityLevel128 ``` ```rust const SECURITY_BITS: u32 = 384 ``` ```rust const SECURITY_BYTES: usize ``` ```rust type Rid = Rid ``` -------------------------------- ### Defining a Custom Security Level Source: https://docs.rs/cggmp21/latest/cggmp21/macro.define_security_level.html?search= Example usage of the define_security_level macro to create a custom security level struct. ```rust use cggmp21::security_level::define_security_level; use cggmp21::rug::Integer; #[derive(Clone)] pub struct MyLevel; define_security_level!(MyLevel{ security_bits = 1024, epsilon = 128, ell = 1024, ell_prime = 1024, m = 128, q = (Integer::ONE.clone() << 48_u32) - 1, }); ``` -------------------------------- ### SigningBuilder::new Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.SigningBuilder.html?search=std%3A%3Avec Constructs a new SigningBuilder instance. ```APIDOC ## pub fn new(eid: ExecutionId<'r>, i: PartyIndex, parties_indexes_at_keygen: &'r [PartyIndex], secret_key_share: &'r KeyShare) -> Self ### Description Constructs a new signing builder to initiate the protocol. ### Parameters - **eid** (ExecutionId) - Required - The execution ID for the protocol session. - **i** (PartyIndex) - Required - The index of the current party. - **parties_indexes_at_keygen** (&[PartyIndex]) - Required - List of party indexes present at key generation. - **secret_key_share** (&KeyShare) - Required - The secret key share for the current party. ``` -------------------------------- ### Prepare Signing Operation Source: https://docs.rs/cggmp21/latest/cggmp21/index.html Sets up the execution ID, signer indices, and data digest required for the signing protocol. ```rust let eid = cggmp21::ExecutionId::new(b"execution id, unique per protocol execution"); let i = /* signer index (0 <= i < min_signers) */ let parties_indexes_at_keygen: [u16; MIN_SIGNERS] = /* parties_indexes_at_keygen[i] is the index the i-th party had at keygen */ let key_share = /* completed key share */ let data_to_sign = cggmp21::DataToSign::digest::(b"data to be signed"); ``` -------------------------------- ### KeygenBuilder::new Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/type.KeygenBuilder.html Constructs a new KeygenBuilder instance. ```APIDOC ## KeygenBuilder::new(eid, i, n) ### Description Constructs a new KeygenBuilder instance for the key generation protocol. ### Parameters - **eid** (ExecutionId) - Required - The execution identifier for the protocol. - **i** (u16) - Required - The local party index. - **n** (u16) - Required - The total number of parties. ``` -------------------------------- ### KeygenBuilder::new Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/type.KeygenBuilder.html?search= Constructs a new KeygenBuilder instance. ```APIDOC ## KeygenBuilder::new ### Description Constructs a new KeygenBuilder instance for the key generation protocol. ### Parameters - **eid** (ExecutionId) - The execution ID for the protocol. - **i** (u16) - The local party index. - **n** (u16) - The total number of parties. ``` -------------------------------- ### PerfReport struct definition Source: https://docs.rs/cggmp21/latest/cggmp21/progress/struct.PerfReport.html The primary structure for storing performance metrics including setup and round durations. ```rust pub struct PerfReport { pub setup: Duration, pub setup_stages: Vec, pub rounds: Vec, /* private fields */ } ``` -------------------------------- ### VssSetup Struct Definition Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.VssSetup.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E The core structure for secret sharing setup, requiring a curve implementation E. ```rust pub struct VssSetup where E: Curve, { pub min_signers: u16, pub I: Vec>>, } ``` -------------------------------- ### DirtyAuxInfo Implementation Methods Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.DirtyAuxInfo.html Methods for precomputing multiexponentiation tables, checking table sizes, and precomputing CRT parameters. ```rust pub fn precompute_multiexp_tables(&mut self) -> Result<(), InvalidKeyShare> ``` ```rust pub fn multiexp_tables_size(&self) -> usize ``` ```rust pub fn precompute_crt(&mut self, i: u16) -> Result<(), InvalidKeyShare> ``` -------------------------------- ### ThresholdKeygenBuilder Execution Methods Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/type.ThresholdKeygenBuilder.html?search=u32+-%3E+bool Methods to initiate the key generation protocol. ```APIDOC ## start(rng: &mut R, party: M) Starts the threshold key generation protocol. Returns a `Result>, KeygenError>`. ## into_state_machine(rng: &'a mut R) Returns a state machine that can be used to carry out the key generation protocol (requires `state-machine` feature). ``` -------------------------------- ### KeyRefreshBuilder::start Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.KeyRefreshBuilder.html?search= Executes the key refresh procedure. ```APIDOC ## KeyRefreshBuilder::start ### Description Carries out the refresh procedure. This method is asynchronous and performs the protocol execution. ### Parameters - **rng** (RngCore + CryptoRng) - Required - A cryptographically secure random number generator. - **party** (Mpc) - Required - The party implementation for the protocol. ``` -------------------------------- ### Configuration Methods Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.KeyRefreshBuilder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods to configure the behavior of the key refresh builder. ```APIDOC ## Configuration Methods - **set_digest(self)**: Specifies an alternative hash function to use. - **set_progress_tracer(self, tracer: &'a mut dyn Tracer)**: Sets a tracer to track the progress of the protocol execution. - **enforce_reliable_broadcast(self, v: bool)**: Toggles the use of a reliable broadcast channel for the first round. Default is `true`. - **precompute_multiexp_tables(self, v: bool)**: Enables precomputation of multiexponentiation tables to optimize future signing operations. - **precompute_crt(self, v: bool)**: Enables precomputation of CRT parameters to optimize Zero-Knowledge proof validation. ``` -------------------------------- ### Configuring KeygenBuilder Options Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/struct.GenericKeygenBuilder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods for configuring the key generation process, including threshold settings, digest algorithms, security levels, progress tracking, broadcast reliability, and HD wallet support. ```rust pub fn set_threshold( self, t: u16, ) -> GenericKeygenBuilder<'a, E, WithThreshold, L, D> ``` ```rust pub fn set_digest(self) -> GenericKeygenBuilder<'a, E, M, L, D2> where D2: Digest + Clone + 'static, ``` ```rust pub fn set_security_level(self) -> GenericKeygenBuilder<'a, E, M, L2, D> where L2: SecurityLevel, ``` ```rust pub fn set_progress_tracer( self, tracer: &'a mut dyn Tracer, ) -> GenericKeygenBuilder<'a, E, M, L, D> ``` ```rust pub fn enforce_reliable_broadcast( self, enforce: bool, ) -> GenericKeygenBuilder<'a, E, M, L, D> ``` ```rust pub fn hd_wallet(self, v: bool) -> GenericKeygenBuilder<'a, E, M, L, D> ``` -------------------------------- ### Get max exponent sizes in Rust Source: https://docs.rs/cggmp21/latest/cggmp21/security_level/fn.max_exponents_size.html?search= Retrieves the maximum bit sizes for exponents x and y as a tuple (x_bits, y_bits) based on the security level. ```rust pub fn max_exponents_size() -> (u32, u32) ``` -------------------------------- ### GenericKeygenBuilder Configuration and Execution Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/struct.GenericKeygenBuilder.html?search=u32+-%3E+bool Methods for configuring the key generation builder and initiating the protocol. ```APIDOC ## GenericKeygenBuilder ### new(eid: ExecutionId, i: u16, n: u16) -> GenericKeygenBuilder Constructs a new key generation builder. Requires the execution ID, the local party index, and the total number of parties. ### set_threshold(t: u16) -> GenericKeygenBuilder Configures the builder to generate key shares for a threshold scheme with threshold t. ### set_digest() -> GenericKeygenBuilder Specifies the hash function to be used during the protocol. ### set_security_level() -> GenericKeygenBuilder Sets the security level for the key generation. ### set_progress_tracer(tracer: &mut dyn Tracer) -> GenericKeygenBuilder Attaches a tracer to monitor the progress of the protocol execution. ### enforce_reliable_broadcast(enforce: bool) -> GenericKeygenBuilder Configures whether to enforce a reliable broadcast channel by adding an extra communication round. Defaults to true. ### hd_wallet(v: bool) -> GenericKeygenBuilder Enables or disables HD derivation for the generated key. Requires 'hd-wallet' feature. ### start(rng: &mut R, party: M) -> Result>, KeygenError> Starts the key generation protocol asynchronously using the provided random number generator and MPC party interface. ### into_state_machine(rng: &mut R) -> impl StateMachine Returns a state machine representation of the key generation protocol. Requires 'state-machine' feature. ``` -------------------------------- ### AuxInfoGenerationBuilder::start Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.AuxInfoGenerationBuilder.html?search= Executes the auxiliary information generation procedure. ```APIDOC ## start(rng: &mut R, party: M) -> Result, KeyRefreshError> ### Description Carries out the auxiliary information generation procedure. This is a time-intensive operation. ### Parameters - **rng** (RngCore + CryptoRng) - A cryptographically secure random number generator. - **party** (Mpc) - The party implementation for protocol communication. ``` -------------------------------- ### Constructing a KeygenBuilder Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/struct.GenericKeygenBuilder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Initializes a new builder instance with the execution ID, local party index, and total number of parties. ```rust pub fn new( eid: ExecutionId<'a>, i: u16, n: u16, ) -> GenericKeygenBuilder<'a, E, NonThreshold, L, D> ``` -------------------------------- ### ThresholdKeygenBuilder Configuration Methods Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/type.ThresholdKeygenBuilder.html?search=u32+-%3E+bool Methods available on the builder to configure the key generation process. ```APIDOC ## set_threshold(t: u16) Specifies to generate key shares for a threshold scheme. ## set_digest() Specifies another hash function to use for the protocol. ## set_security_level() Specifies the security level for the key generation. ## set_progress_tracer(tracer: &'a mut dyn Tracer) Sets a tracer that tracks the progress of the protocol execution. ## enforce_reliable_broadcast(enforce: bool) Ensures reliability of the broadcast channel by adding one extra communication round. Default is true. ## hd_wallet(v: bool) Specifies whether HD derivation is enabled for a key (requires `hd-wallet` feature). ``` -------------------------------- ### Configuration Methods Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.AuxInfoGenerationBuilder.html?search=u32+-%3E+bool Methods to configure the behavior of the auxiliary info generation builder. ```APIDOC ## Configuration Methods ### set_digest(self) -> GenericKeyRefreshBuilder<'a, T, L, D2> Specifies an alternative hash function to use. ### set_progress_tracer(self, tracer: &'a mut dyn Tracer) -> Self Sets a tracer to track the progress of the protocol execution. ### enforce_reliable_broadcast(self, v: bool) -> Self Ensures reliability of the broadcast channel by adding an extra communication round. Default is `true`. ### precompute_multiexp_tables(self, v: bool) -> Self Enables precomputation of multiexponentiation tables to optimize signing and presigning. ### precompute_crt(self, v: bool) -> Self Enables precomputation of CRT parameters to optimize modular exponentiation in Zero-Knowledge proofs. ``` -------------------------------- ### AuxInfoGenerationBuilder Methods Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.AuxInfoGenerationBuilder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods for initializing and executing the auxiliary info generation procedure. ```rust pub fn new_aux_gen( eid: ExecutionId<'a>, i: u16, n: u16, pregenerated: PregeneratedPrimes, ) -> Self ``` ```rust pub async fn start( self, rng: &mut R, party: M, ) -> Result, KeyRefreshError> where R: RngCore + CryptoRng, M: Mpc>, L: SecurityLevel, D: Digest + Clone + 'static, ``` ```rust pub fn into_state_machine( self, rng: &'a mut R, ) -> impl StateMachine, KeyRefreshError>, Msg = Msg> + 'a where R: RngCore + CryptoRng, L: SecurityLevel, D: Digest + Clone + 'static, ``` -------------------------------- ### Initialize KeyRefreshBuilder Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.KeyRefreshBuilder.html?search= Creates a new instance of the key refresh builder. ```rust pub fn new( eid: ExecutionId<'a>, key_share: &'a impl AnyKeyShare, pregenerated: PregeneratedPrimes, ) -> Self ``` -------------------------------- ### Configuration Methods Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.AuxInfoGenerationBuilder.html?search= Methods to configure the generation process. ```APIDOC ## Configuration Methods - **set_digest()** - Specifies a different hash function to use. - **set_progress_tracer(tracer: &'a mut dyn Tracer)** - Sets a tracer to track the progress of the protocol execution. - **enforce_reliable_broadcast(v: bool)** - Enables or disables an extra communication round to ensure broadcast reliability (Default: true). - **precompute_multiexp_tables(v: bool)** - Enables precomputation of multiexponentiation tables to optimize signing and presigning. - **precompute_crt(v: bool)** - Enables precomputation of CRT parameters to optimize ZK proof validation. ``` -------------------------------- ### pub fn keygen Source: https://docs.rs/cggmp21/latest/cggmp21/fn.keygen.html Initializes the distributed key generation protocol. Each party must be assigned a unique index i where 0 <= i < n. ```APIDOC ## Function: keygen ### Description Initiates the distributed key generation protocol. Each party of the protocol must have a uniquely assigned index `i` such that 0 <= i < n, where `n` is the total number of parties. ### Signature `pub fn keygen(eid: ExecutionId<'_>, i: u16, n: u16) -> GenericKeygenBuilder<'_, E, ...>` ### Parameters - **eid** (ExecutionId<'_>) - The execution identifier for the protocol session. - **i** (u16) - The unique index assigned to the current party (0 <= i < n). - **n** (u16) - The total number of parties participating in the protocol. ### Generic Constraints - **E** (Curve) - The elliptic curve used for the key generation protocol. ``` -------------------------------- ### Precompute Multiexponentiation Table Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.PartyAux.html Method to precompute the multiexponentiation table for performance optimization. Requires the security level to match the protocol configuration. ```rust pub fn precompute_multiexp_table( &mut self, ) -> Result<(), InvalidKeyShare> ``` -------------------------------- ### KeygenBuilder Configuration Methods Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/type.KeygenBuilder.html Methods to configure the key generation process before execution. ```APIDOC ## Configuration Methods ### set_threshold(t) Specifies to generate key shares for a threshold scheme with threshold `t`. ### set_digest() Specifies a custom hash function to use for the protocol. ### set_security_level() Specifies the security level for the key generation. ### set_progress_tracer(tracer) Sets a tracer that tracks the progress of the protocol execution. ### enforce_reliable_broadcast(enforce) Ensures reliability of the broadcast channel by adding one extra communication round. Default is true. ### hd_wallet(v) Specifies whether HD derivation is enabled for the key (requires `hd-wallet` feature). ``` -------------------------------- ### KeygenBuilder Configuration Methods Source: https://docs.rs/cggmp21/latest/cggmp21/keygen/type.KeygenBuilder.html?search= Methods to configure the key generation process before execution. ```APIDOC ## Configuration Methods - **set_threshold(t: u16)**: Specifies to generate key shares for a threshold scheme. - **set_digest()**: Specifies a custom hash function to use. - **set_security_level()**: Specifies the security level. - **set_progress_tracer(tracer: &mut dyn Tracer)**: Sets a tracer to track the progress of protocol execution. - **enforce_reliable_broadcast(enforce: bool)**: Ensures reliability of the broadcast channel by adding an extra communication round. Default is true. - **hd_wallet(v: bool)**: Specifies whether HD derivation is enabled (requires `hd-wallet` feature). ``` -------------------------------- ### Set HD Derivation Path with Custom Algorithm Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.Presignature.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Configures an HD derivation path using a custom wallet algorithm. Requires the hd-wallet feature. ```rust pub fn set_derivation_path_with_algo, Index>( self, epub: ExtendedPublicKey, derivation_path: impl IntoIterator, ) -> Result>::Error> where NonHardenedIndex: TryFrom, ``` -------------------------------- ### Execute Distributed Key Generation Source: https://docs.rs/cggmp21/latest/cggmp21/index.html?search= Sets up the DKG protocol parameters including indices, execution ID, and threshold. ```rust use cggmp21::supported_curves::Secp256k1; let eid = cggmp21::ExecutionId::new(b"execution id, unique per protocol execution"); let i = /* signer index (0 <= i < n) */ let n = /* number of signers taking part in key generation */ let t = /* threshold */ ``` -------------------------------- ### PerfProfiler::new Source: https://docs.rs/cggmp21/latest/cggmp21/progress/struct.PerfProfiler.html?search= Constructs a new instance of the PerfProfiler. ```APIDOC ## PerfProfiler::new() ### Description Constructs a new PerfProfiler instance to begin tracking protocol performance. ### Signature `pub fn new() -> PerfProfiler` ``` -------------------------------- ### pub fn signing Source: https://docs.rs/cggmp21/latest/cggmp21/fn.signing.html Initializes the signing protocol builder for generating a signature or presignature. ```APIDOC ## pub fn signing ### Description Initiates the protocol for generating a signature or presignature. ### Signature `pub fn signing<'r, E, L>(eid: ExecutionId<'r>, i: PartyIndex, parties_indexes_at_keygen: &'r [PartyIndex], key_share: &'r KeyShare) -> SigningBuilder<'r, E, L>` ### Parameters - **eid** (ExecutionId<'r>) - The execution identifier for the signing session. - **i** (PartyIndex) - The index of the current party. - **parties_indexes_at_keygen** (&'r [PartyIndex]) - The list of party indexes that participated in the keygen phase. - **key_share** (&'r KeyShare) - The key share associated with the party. ### Returns - **SigningBuilder<'r, E, L>** - A builder object to proceed with the signing protocol. ``` -------------------------------- ### Precompute CRT Parameters Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.DirtyKeyShare.html Optimizes modular exponentiation for ZK proof validation by precomputing CRT parameters. Note that these parameters contain secret information and must be handled securely. ```rust pub fn precompute_crt(&mut self) -> Result<(), InvalidKeyShare> ``` -------------------------------- ### Perform Signing Protocol Source: https://docs.rs/cggmp21/latest/cggmp21/index.html Executes the signing protocol using the provided key share and data. ```rust let signature = cggmp21::signing(eid, i, &parties_indexes_at_keygen, &key_share) .sign(&mut OsRng, party, data_to_sign) .await?; ``` -------------------------------- ### Configure I/O Display Source: https://docs.rs/cggmp21/latest/cggmp21/progress/struct.PerfReport.html?search= Method to toggle the inclusion of I/O wait times in the performance report. ```rust pub fn display_io(self, display: bool) -> PerfReport ``` -------------------------------- ### aux_info_gen Source: https://docs.rs/cggmp21/latest/cggmp21/fn.aux_info_gen.html Initializes the protocol for finalizing key generation by generating auxiliary information. ```APIDOC ## Function: aux_info_gen ### Description Protocol for finalizing the keygen by generating aux info. Outputs `AuxInfo` that can be used to complete `IncompleteKeyShare` using `KeyShare::from_parts`. ### Signature `pub fn aux_info_gen(eid: ExecutionId<'_>, i: u16, n: u16, pregenerated: PregeneratedPrimes) -> AuxInfoGenerationBuilder<'_, L> where L: SecurityLevel` ### Parameters - **eid** (ExecutionId) - The execution ID for the protocol. - **i** (u16) - Index of the party; should match the index inside the key share. - **n** (u16) - Number of parties; should match the number of signers sharing the key. - **pregenerated** (PregeneratedPrimes) - Pregenerated primes obtained via `key_refresh::PregeneratedPrimes::generate`. ### Returns - **AuxInfoGenerationBuilder** - A builder object to continue the auxiliary information generation process. ``` -------------------------------- ### Set HD Derivation Path Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.Presignature.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Configures an HD derivation path for the presignature using the SLIP-10 algorithm. Requires hd-slip10 and hd-wallet features. ```rust pub fn set_derivation_path( self, epub: ExtendedPublicKey, derivation_path: impl IntoIterator, ) -> Result>::Error> where Slip10: HdWallet, NonHardenedIndex: TryFrom, ``` -------------------------------- ### Initialize Trusted Dealer Builder Source: https://docs.rs/cggmp21/latest/cggmp21/trusted_dealer/fn.builder.html Constructs a new builder for a specified number of key shares. Requires the spof feature to be enabled. ```rust pub fn builder(n: u16) -> TrustedDealerBuilder ``` -------------------------------- ### Implement Send and Sync for MsgRound1 Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/msg/non_threshold/struct.MsgRound1.html Implements the Send and Sync marker traits for MsgRound1. ```rust impl Send for MsgRound1 ``` ```rust impl Sync for MsgRound1 ``` -------------------------------- ### KeyRefreshBuilder Configuration Methods Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.KeyRefreshBuilder.html?search= Methods to configure the key refresh builder before execution. ```APIDOC ## Configuration Methods ### set_digest(self) Specifies another hash function to use. ### set_progress_tracer(self, tracer: &'a mut dyn Tracer) Sets a tracer that tracks progress of protocol execution. ### enforce_reliable_broadcast(self, v: bool) Ensures reliability of broadcast channel by adding one extra communication round. Default is true. ### precompute_multiexp_tables(self, v: bool) Enables optimization that makes signing and presigning faster by precomputing multiexponentiation tables. ### precompute_crt(self, v: bool) Enables optimization of modular exponentiation in Zero-Knowledge proofs validation by precomputing CRT parameters. ``` -------------------------------- ### Construct MPC Party Source: https://docs.rs/cggmp21/latest/cggmp21/index.html?search= Initializes the party using the established delivery stream and sink. ```rust let delivery = (incoming, outgoing); let party = round_based::MpcParty::connected(delivery); ``` -------------------------------- ### precompute_multiexp_tables Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.DirtyAuxInfo.html?search= Precomputes multiexponentiation tables to accelerate signing and presigning operations. Note that this increases memory and disk usage. ```APIDOC ## pub fn precompute_multiexp_tables(&mut self) -> Result<(), InvalidKeyShare> ### Description Precomputes multiexponentiation tables to enable faster signing and presigning. This operation may take time and increases the size of auxiliary data. ### Returns - **Result<(), InvalidKeyShare>** - Returns Ok(()) on success, or an InvalidKeyShare error if the table generation fails. ``` -------------------------------- ### DirtyKeyInfo Methods Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.DirtyKeyInfo.html Methods available on DirtyKeyInfo for retrieving share preimages and performing HD wallet operations. ```Rust pub fn share_preimage(&self, j: u16) -> Option>> ``` ```Rust pub fn is_hd_wallet(&self) -> bool ``` ```Rust pub fn extended_public_key(&self) -> Option> ``` ```Rust pub fn derive_child_public_key( &self, derivation_path: impl IntoIterator, ) -> Result, HdError<>::Error>> where Hd: HdWallet, NonHardenedIndex: TryFrom, ``` -------------------------------- ### Implement Sync for MsgRound2 Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/msg/non_threshold/struct.MsgRound2.html Implements the Sync trait for MsgRound2. ```rust impl Sync for MsgRound2 ``` -------------------------------- ### signing Source: https://docs.rs/cggmp21/latest/cggmp21/fn.signing.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Initializes a SigningBuilder to perform a signature or presignature generation protocol. ```APIDOC ## signing ### Description Initiates the protocol for generating a signature or presignature. ### Signature `pub fn signing<'r, E, L>(eid: ExecutionId<'r>, i: PartyIndex, parties_indexes_at_keygen: &'r [PartyIndex], key_share: &'r KeyShare) -> SigningBuilder<'r, E, L>` ### Parameters - **eid** (ExecutionId<'r>) - The execution identifier for the signing session. - **i** (PartyIndex) - The index of the current party. - **parties_indexes_at_keygen** (&'r [PartyIndex]) - The list of party indexes present at keygen. - **key_share** (&'r KeyShare) - The key share data required for signing. ### Returns - **SigningBuilder<'r, E, L>** - A builder object to proceed with the signing protocol. ``` -------------------------------- ### HD Wallet Methods Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.DirtyKeyInfo.html?search=u32+-%3E+bool Methods for checking HD capability, retrieving extended public keys, and deriving child keys. These require the 'hd-wallet' feature. ```rust pub fn is_hd_wallet(&self) -> bool ``` ```rust pub fn extended_public_key(&self) -> Option> ``` ```rust pub fn derive_child_public_key( &self, derivation_path: impl IntoIterator, ) -> Result, HdError<>::Error>> where Hd: HdWallet, NonHardenedIndex: TryFrom, ``` -------------------------------- ### Construct and manage PregeneratedPrimes Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/struct.PregeneratedPrimes.html Methods for creating, splitting, and generating prime numbers for the struct. ```rust pub fn new(p: Integer, q: Integer) -> Option ``` ```rust pub fn split(self) -> (Integer, Integer) ``` ```rust pub fn generate(rng: &mut R) -> Self ``` -------------------------------- ### precompute_multiexp_table Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.PartyAux.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Precomputes a multiexponentiation table to optimize signing and presigning performance. This operation may be time-consuming and increases memory/disk usage. ```APIDOC ## fn precompute_multiexp_table(&mut self) -> Result<(), InvalidKeyShare> ### Description Precomputes a multiexponentiation table to enable optimizations that make signing and presigning faster. Note that the provided security level must match the actual security level used in the protocol. ### Parameters - **L** (SecurityLevel) - The security level to use for the precomputation. ### Returns - **Result<(), InvalidKeyShare>** - Returns an error if the table generation fails; otherwise, updates the internal multiexp table. ``` -------------------------------- ### precompute_multiexp_table Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.PartyAux.html?search=u32+-%3E+bool Precomputes a multiexponentiation table to optimize signing and presigning performance. This operation may take time and increases memory usage. ```APIDOC ## pub fn precompute_multiexp_table(&mut self) -> Result<(), InvalidKeyShare> ### Description Precomputes a multiexponentiation table to enable optimizations that make signing and presigning faster. Note that the provided security level must match the actual security level used in the protocol. ### Parameters - **L** (SecurityLevel) - The security level to use for precomputation. ### Returns - **Result<(), InvalidKeyShare>** - Returns Ok(()) on success, or an InvalidKeyShare error if the table generation fails. ``` -------------------------------- ### set_derivation_path_with_algo Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.Presignature.html?search=u32+-%3E+bool Specifies an HD derivation path for the presignature using a custom HD wallet algorithm. ```APIDOC ## pub fn set_derivation_path_with_algo, Index>(self, epub: ExtendedPublicKey, derivation_path: impl IntoIterator) -> Result ### Description Outputs a presignature configured to sign a message with a child key derived from the master extended public key using a provided HD wallet algorithm. Requires `hd-wallet` feature. ### Parameters - **epub** (ExtendedPublicKey) - The master extended public key associated with the key share. - **derivation_path** (impl IntoIterator) - The path to derive the child key. ``` -------------------------------- ### precompute_multiexp_table Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.PartyAux.html?search=std%3A%3Avec Precomputes a multiexponentiation table to optimize signing and presigning performance. This operation may take time and increases memory/storage usage. ```APIDOC ## pub fn precompute_multiexp_table(&mut self) -> Result<(), InvalidKeyShare> ### Description Precomputes a multiexponentiation table to enable optimizations that make signing and presigning faster. Note that the provided security level must match the actual security level used in the protocol. ### Parameters - **L** (SecurityLevel) - The security level to use for the precomputation. ### Returns - **Result<(), InvalidKeyShare>** - Returns an error if the table building fails; otherwise, updates the internal multiexp table. ``` -------------------------------- ### KeyRefreshBuilder::new Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.KeyRefreshBuilder.html?search= Initializes a new key refresh operation builder. ```APIDOC ## KeyRefreshBuilder::new ### Description Builds a key refresh operation. The operation can be started using the `start` method. ### Parameters - **eid** (ExecutionId) - Required - The execution ID for the protocol. - **key_share** (impl AnyKeyShare) - Required - The current key share to be refreshed. - **pregenerated** (PregeneratedPrimes) - Required - Pregenerated primes for the protocol. ``` -------------------------------- ### Implement Sync for MsgRound1 Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/msg/aux_only/struct.MsgRound1.html Implements the Sync trait for MsgRound1. ```rust impl Sync for MsgRound1 ``` -------------------------------- ### Check HD Wallet Capability Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.DirtyIncompleteKeyShare.html?search=std%3A%3Avec Checks whether the key is HD-capable. Requires the hd-wallet feature. ```rust pub fn is_hd_wallet(&self) -> bool ``` -------------------------------- ### Signature Creation and Normalization Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.Signature.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods for creating a signature from raw parts and normalizing the s component. ```rust pub fn from_raw_parts(r: NonZero>, s: NonZero>) -> Self ``` ```rust pub fn normalize_s(self) -> Self ``` -------------------------------- ### signing Source: https://docs.rs/cggmp21/latest/cggmp21/fn.signing.html?search=u32+-%3E+bool Initiates the signing protocol for generating a signature or presignature. ```APIDOC ## signing ### Description Protocol for generating a signature or presignature. ### Signature `pub fn signing<'r, E, L>(eid: ExecutionId<'r>, i: PartyIndex, parties_indexes_at_keygen: &'r [PartyIndex], key_share: &'r KeyShare) -> SigningBuilder<'r, E, L>` ### Constraints - `E: Curve` - `Point: HasAffineX` - `L: SecurityLevel` ``` -------------------------------- ### is_hd_wallet Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.DirtyIncompleteKeyShare.html?search=std%3A%3Avec Checks if the key is HD-capable. Requires the 'hd-wallet' feature. ```APIDOC ### Method `pub fn is_hd_wallet(&self) -> bool` ### Description Checks whether the key is HD-capable. This method is only available when the 'hd-wallet' crate feature is enabled. ``` -------------------------------- ### from_raw_parts Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.Signature.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a signature struct from r and s values. ```APIDOC ## pub fn from_raw_parts(r: NonZero>, s: NonZero>) -> Self ### Description Creates a signature struct from r and s values. ``` -------------------------------- ### KeyRefreshBuilder Methods Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.KeyRefreshBuilder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods for initializing and executing the key refresh operation. ```rust pub fn new( eid: ExecutionId<'a>, key_share: &'a impl AnyKeyShare, pregenerated: PregeneratedPrimes, ) -> Self ``` ```rust pub async fn start( self, rng: &mut R, party: M, ) -> Result, KeyRefreshError> where R: RngCore + CryptoRng, M: Mpc>, E: Curve, L: SecurityLevel, D: Digest + Clone + 'static, ``` ```rust pub fn into_state_machine( self, rng: &'a mut R, ) -> impl StateMachine, KeyRefreshError>, Msg = NonThresholdMsg> + 'a where R: RngCore + CryptoRng, E: Curve, L: SecurityLevel, D: Digest + Clone + 'static, ``` -------------------------------- ### Convert to state machine Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/type.KeyRefreshBuilder.html?search= Returns a state machine for the key refresh protocol, available only with the 'state-machine' feature. ```rust pub fn into_state_machine( self, rng: &'a mut R, ) -> impl StateMachine, KeyRefreshError>, Msg = NonThresholdMsg> + 'a where R: RngCore + CryptoRng, E: Curve, L: SecurityLevel, D: Digest + Clone + 'static, ``` -------------------------------- ### fn signing Source: https://docs.rs/cggmp21/latest/cggmp21/fn.signing.html?search=std%3A%3Avec Initializes a SigningBuilder to perform a signature or presignature generation protocol. ```APIDOC ## Function: signing ### Description Initiates the protocol for generating a signature or presignature. ### Signature `pub fn signing<'r, E, L>(eid: ExecutionId<'r>, i: PartyIndex, parties_indexes_at_keygen: &'r [PartyIndex], key_share: &'r KeyShare) -> SigningBuilder<'r, E, L>` ### Parameters - **eid** (ExecutionId<'r>) - The execution identifier for the signing session. - **i** (PartyIndex) - The index of the current party. - **parties_indexes_at_keygen** (&'r [PartyIndex]) - A slice of party indexes as they were during the keygen phase. - **key_share** (&'r KeyShare) - The key share associated with the curve E and security level L. ### Returns - **SigningBuilder<'r, E, L>** - A builder object used to execute the signing protocol. ``` -------------------------------- ### Sync implementation for MsgRound4 Source: https://docs.rs/cggmp21/latest/cggmp21/signing/msg/struct.MsgRound4.html Implements the Sync trait for MsgRound4. ```rust impl Sync for MsgRound4 ``` -------------------------------- ### precompute_crt Source: https://docs.rs/cggmp21/latest/cggmp21/key_share/struct.DirtyKeyShare.html?search= Precomputes CRT parameters to optimize modular exponentiation in Zero-Knowledge proofs validation. ```APIDOC ## pub fn precompute_crt(&mut self) -> Result<(), InvalidKeyShare> ### Description Precomputes CRT parameters to enable optimization of modular exponentiation in Zero-Knowledge proofs validation. Note that CRT parameters contain secret information and should be handled securely. ### Returns - **Result<(), InvalidKeyShare>** - Returns an error if precomputation fails, otherwise saves the parameters into the key share. ``` -------------------------------- ### Implement SecurityLevel constants Source: https://docs.rs/cggmp21/latest/cggmp21/security_level/struct.SecurityLevel128.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Constants defining the security parameters for the 128-bit level. ```rust const SECURITY_BITS: u32 = 384 ``` ```rust const SECURITY_BYTES: usize ``` ```rust type Rid = Rid ``` ```rust const EPSILON: usize = 230 ``` ```rust const ELL: usize = 256 ``` ```rust const ELL_PRIME: usize = 848 ``` ```rust const M: usize = 128 ``` ```rust fn q() -> Integer ``` -------------------------------- ### Import a key into 3-out-of-5 TSS Source: https://docs.rs/cggmp21/latest/cggmp21/trusted_dealer/index.html Demonstrates using the trusted dealer builder to generate key shares from an existing secret key. Requires the 'spof' feature flag to be enabled. ```rust use cggmp21::{supported_curves::Secp256k1, security_level::SecurityLevel128}; use cggmp21::generic_ec::{SecretScalar, NonZero}; let secret_key_to_be_imported = NonZero::>::random(&mut rng); let key_shares = cggmp21::trusted_dealer::builder::(5) .set_threshold(Some(3)) .set_shared_secret_key(secret_key_to_be_imported) .generate_shares(&mut rng)?; ``` -------------------------------- ### SigningBuilder Methods Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.SigningBuilder.html?search=u32+-%3E+bool Methods available on the SigningBuilder for configuring protocol parameters and initiating signing operations. ```APIDOC ## SigningBuilder::new ### Description Constructs a new SigningBuilder instance. ### Parameters - **eid** (ExecutionId) - The execution ID for the protocol. - **i** (PartyIndex) - The index of the current party. - **parties_indexes_at_keygen** (&[PartyIndex]) - List of party indexes present at key generation. - **secret_key_share** (&KeyShare) - The secret key share for the party. ## SigningBuilder::set_digest ### Description Specifies a different hash function to use for the protocol. ## SigningBuilder::set_progress_tracer ### Description Specifies a tracer to track the progress of the protocol execution. ## SigningBuilder::enforce_reliable_broadcast ### Description Ensures reliability of the broadcast channel by adding an extra communication round. Defaults to true. ## SigningBuilder::set_derivation_path ### Description Specifies an HD derivation path using the Slip10 algorithm. Requires 'hd-slip10' and 'hd-wallet' features. ## SigningBuilder::generate_presignature ### Description Starts the asynchronous presignature generation protocol. ## SigningBuilder::sign ### Description Starts the asynchronous signing protocol for a given message. ``` -------------------------------- ### Convert to and from scalars Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.DataToSign.html Methods for manual scalar construction and retrieval. ```rust pub fn from_scalar(scalar: Scalar) -> Self ``` ```rust pub fn to_scalar(self) -> Scalar ``` -------------------------------- ### DataToSign Construction Methods Source: https://docs.rs/cggmp21/latest/cggmp21/signing/struct.DataToSign.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods for creating a DataToSign instance from raw data, digest outputs, or existing scalars. ```rust pub fn digest(data: &[u8]) -> Self ``` ```rust pub fn from_digest(hash: D) -> Self ``` ```rust pub fn from_scalar(scalar: Scalar) -> Self ``` -------------------------------- ### Implement Send for MsgRound2 Source: https://docs.rs/cggmp21/latest/cggmp21/key_refresh/msg/non_threshold/struct.MsgRound2.html Implements the Send trait for MsgRound2. ```rust impl Send for MsgRound2 ```