### Starting Threshold Key Generation Source: https://docs.rs/cggmp21/0.6.3/cggmp21/keygen/type.ThresholdKeygenBuilder.html Methods to initiate the threshold key generation process, either by starting directly or by obtaining a state machine. ```APIDOC ## Starting Threshold Key Generation ### Description These methods are used to begin the threshold key generation protocol after the builder has been configured. ### Methods #### `start` - **Description**: Starts the threshold key generation protocol asynchronously. - **Method**: `self.start(rng: &mut R, party: M)` - **Parameters**: - `rng` (type: `&mut R` where `R: RngCore + CryptoRng`) - A random number generator. - `party` (type: `M` where `M: Mpc>`) - The current party in the Multi-Party Computation. - **Returns**: `Result>, KeygenError>` - A `Result` containing the generated key share or a `KeygenError`. #### `into_state_machine` - **Description**: Returns a state machine that can be used to carry out the key generation protocol. Available only with the `state-machine` feature flag. - **Method**: `self.into_state_machine(rng: &'a mut R)` - **Parameters**: - `rng` (type: `&'a mut R` where `R: RngCore + CryptoRng`) - A random number generator. - **Returns**: `impl StateMachine>, KeygenError>, Msg = Msg> + 'a` - An object implementing the `StateMachine` trait for protocol execution. ``` -------------------------------- ### Execute AuxInfoGenerationBuilder Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/type.AuxInfoGenerationBuilder.html Starts the asynchronous auxiliary information generation procedure. ```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, ``` -------------------------------- ### Example: Define MyLevel Security Level Source: https://docs.rs/cggmp21/0.6.3/cggmp21/macro.define_security_level.html This example demonstrates defining a security level with specific parameters for κ, ε, ℓ, m, and q. The 'm' parameter is hardcoded to 128. ```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, }); ``` -------------------------------- ### Trace Protocol Begins Source: https://docs.rs/cggmp21/0.6.3/cggmp21/progress/struct.PerfProfiler.html Traces the start of the protocol execution. This method is called when Event::ProtocolBegins occurs. ```rust fn protocol_begins(&mut self) ``` -------------------------------- ### GenericKeygenBuilder Configuration and Execution Source: https://docs.rs/cggmp21/0.6.3/cggmp21/keygen/struct.GenericKeygenBuilder.html Methods for initializing the key generation builder, configuring protocol parameters, and starting the execution. ```APIDOC ## GenericKeygenBuilder ### Description Provides methods to configure and start the key generation protocol for the CGGMP21 library. ### Methods - **new(eid, i, n)**: Constructs a new builder instance. - **set_threshold(t)**: Configures the builder for a threshold scheme. - **set_digest()**: Sets the hash function to be used. - **set_security_level()**: Sets the security level. - **set_progress_tracer(tracer)**: Attaches a tracer to monitor protocol progress. - **enforce_reliable_broadcast(enforce)**: Toggles the use of an extra communication round to ensure reliable broadcast. - **hd_wallet(v)**: Enables or disables HD derivation (requires `hd-wallet` feature). - **start(rng, party)**: Executes the key generation protocol. - **into_state_machine(rng)**: Returns a state machine for the protocol (requires `state-machine` feature). ``` -------------------------------- ### Construct New PerfProfiler Source: https://docs.rs/cggmp21/0.6.3/cggmp21/progress/struct.PerfProfiler.html Creates a new instance of PerfProfiler. This is the entry point for starting performance profiling. ```rust pub fn new() -> PerfProfiler ``` -------------------------------- ### Start Key Refresh Procedure Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/struct.GenericKeyRefreshBuilder.html Executes the key refresh procedure asynchronously. This operation can take a significant amount of time. ```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, ``` -------------------------------- ### Threshold Key Generation Execution Source: https://docs.rs/cggmp21/0.6.3/cggmp21/keygen/type.ThresholdKeygenBuilder.html Methods to start the key generation protocol or convert it into 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, ``` -------------------------------- ### KeyShare Validation Example Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/trait.ValidateFromParts.html Demonstrates implementing ValidateFromParts for a KeyShare struct, allowing validation from pre-validated core key share and auxiliary data. ```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 } ``` ```rust 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() } } } ``` -------------------------------- ### Start Auxiliary Info Generation Procedure Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/struct.GenericKeyRefreshBuilder.html Executes the auxiliary info generation procedure asynchronously. This operation can take a significant amount of time. ```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, ``` -------------------------------- ### SecurityLevel Implementations Source: https://docs.rs/cggmp21/0.6.3/cggmp21/security_level/trait.SecurityLevel.html Example implementation of the SecurityLevel trait for SecurityLevel128. ```APIDOC ## Implementors ### impl SecurityLevel for SecurityLevel128 #### const EPSILON: usize = 230usize #### const ELL: usize = 256usize #### const ELL_PRIME: usize = 848usize #### const M: usize = 128usize ``` -------------------------------- ### SecurityLevel128 Implementation Source: https://docs.rs/cggmp21/0.6.3/cggmp21/security_level/trait.KeygenSecurityLevel.html Example implementation of SecurityLevel for SecurityLevel128, specifying 384 security bits and 48 security bytes. ```rust const SECURITY_BITS: u32 = 384u32; const SECURITY_BYTES: usize = 48usize; ``` -------------------------------- ### Build Key Refresh Operation Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/struct.GenericKeyRefreshBuilder.html Constructs a GenericKeyRefreshBuilder for key refresh operations. Use `start` to initiate the process. PregeneratedPrimes can be obtained via `PregeneratedPrimes::generate`. ```rust pub fn new( eid: ExecutionId<'a>, key_share: &'a impl AnyKeyShare, pregenerated: PregeneratedPrimes, ) -> Self ``` -------------------------------- ### Get Multiexp Tables Size Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/struct.DirtyAuxInfo.html Returns the total size in bytes of all multiexponentiation tables stored within the key share. ```rust pub fn multiexp_tables_size(&self) -> usize ``` -------------------------------- ### Implement Error for KeyRefreshError: description (Deprecated) Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/struct.KeyRefreshError.html Deprecated method to get a string description of the error. Use the Display implementation or to_string() instead. ```rust fn description(&self) -> &str ``` -------------------------------- ### Get Type ID Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/struct.PregeneratedPrimes.html Gets the TypeId of the value. This is a blanket implementation for any type T that is 'static and Send. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Getting Affine X Coordinate and Parity Source: https://docs.rs/cggmp21/0.6.3/cggmp21/supported_curves/type.Stark.html Implements the HasAffineXAndParity trait, providing methods to get the x-coordinate and y-parity of a point. ```rust fn x_and_parity( point: & as Curve>::Point, ) -> Option<( as Curve>::CoordinateArray, Parity)> ``` -------------------------------- ### Borrowing and Conversion Implementations Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/struct.GenericKeyRefreshBuilder.html This section details implementations for borrowing, general conversions, and instrumentation. ```APIDOC ## impl<'a, M, L, D> !UnwindSafe for GenericKeyRefreshBuilder<'a, M, L, D> ### Description Marks `GenericKeyRefreshBuilder` as `!UnwindSafe`. ## impl Borrow for T ### Description Provides a `Borrow` implementation for `T` from `T` where `T` is not `?Sized`. ### Methods #### fn borrow(&self) -> &T Immutably borrows from an owned value. ## impl BorrowMut for T ### Description Provides a `BorrowMut` implementation for `T` from `T` where `T` is not `?Sized`. ### Methods #### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. ## impl From for T ### Description Provides a `From` implementation for `T` from `T`. ### Methods #### fn from(t: T) -> T Returns the argument unchanged. ## impl Into for T ### Description Provides an `Into` implementation for `U` from `T` where `U` implements `From`. ### Methods #### fn into(self) -> U Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ## impl Instrument for T ### Description Provides the `Instrument` trait for any type `T`. ### Methods #### fn instrument(self, span: Span) -> Instrumented Instruments this type with the provided `Span`, returning an `Instrumented` wrapper. #### fn in_current_span(self) -> Instrumented Instruments this type with the current `Span`, returning an `Instrumented` wrapper. ## impl TryFrom for T ### Description Provides a `TryFrom` implementation for `T` from `U` where `U` implements `Into`. ### Associated Types #### type Error = Infallible The type returned in the event of a conversion error. ### Methods #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ## impl TryInto for T ### Description Provides a `TryInto` implementation for `U` from `T` where `U` implements `TryFrom`. ### Associated Types #### type Error = >::Error The type returned in the event of a conversion error. ### Methods #### fn try_into(self) -> Result>::Error> Performs the conversion. ## impl WithSubscriber for T ### Description Provides the `WithSubscriber` trait for any type `T`. ### Methods #### fn with_subscriber(self, subscriber: S) -> WithDispatch where S: Into, Attaches the provided `Subscriber` to this type, returning a `WithDispatch` wrapper. #### fn with_current_subscriber(self) -> WithDispatch Attaches the current default `Subscriber` to this type, returning a `WithDispatch` wrapper. ``` -------------------------------- ### PerfReport Struct Definition Source: https://docs.rs/cggmp21/0.6.3/cggmp21/progress/struct.PerfReport.html Defines the structure for performance reporting, including setup duration, setup stages, and round durations. This struct is generated by PerfProfiler. ```rust pub struct PerfReport { pub setup: Duration, pub setup_stages: Vec, pub rounds: Vec, /* private fields */ } ``` -------------------------------- ### KeygenBuilder Configuration and Execution Source: https://docs.rs/cggmp21/0.6.3/cggmp21/keygen/type.KeygenBuilder.html Methods for initializing the key generation process and configuring protocol parameters. ```APIDOC ## KeygenBuilder::new ### Description Constructs a new KeygenBuilder instance. ### Parameters #### Path Parameters - **eid** (ExecutionId) - Required - The execution ID for the protocol. - **i** (u16) - Required - The local party index. - **n** (u16) - Required - The total number of parties. ## KeygenBuilder::set_threshold ### Description Specifies to generate key shares for a threshold scheme. ### Parameters - **t** (u16) - Required - The threshold value. ## KeygenBuilder::start ### Description Starts the key generation protocol. ### Parameters - **rng** (RngCore + CryptoRng) - Required - Random number generator. - **party** (Mpc) - Required - The party implementation. ### Response - **Result>, KeygenError>** - Returns the generated key share or an error. ``` -------------------------------- ### Implement SecurityLevel128 Source: https://docs.rs/cggmp21/0.6.3/cggmp21/security_level/trait.SecurityLevel.html Example implementation of the SecurityLevel trait for the 128-bit security level. ```rust impl SecurityLevel for SecurityLevel128 { const EPSILON: usize = 230usize; const ELL: usize = 256usize; const ELL_PRIME: usize = 848usize; const M: usize = 128usize; } ``` -------------------------------- ### Get ExecutionId Bytes Source: https://docs.rs/cggmp21/0.6.3/cggmp21/struct.ExecutionId.html Retrieves the byte slice representation of an ExecutionId. This is useful for verification or logging purposes. ```rust pub fn as_bytes(&self) -> &'id [u8] ``` -------------------------------- ### Initialize AuxInfoGenerationBuilder Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/type.AuxInfoGenerationBuilder.html Creates a new instance of the builder for auxiliary information generation. ```rust pub fn new_aux_gen( eid: ExecutionId<'a>, i: u16, n: u16, pregenerated: PregeneratedPrimes, ) -> Self ``` -------------------------------- ### TryInto and TryFrom Implementations Source: https://docs.rs/cggmp21/0.6.3/cggmp21/signing/msg/struct.MsgRound1a.html Provides functionality for attempting conversions that may fail, returning a Result. ```APIDOC ## TryInto for T ### Description Provides a `try_into` method for attempting conversions that may fail, returning a `Result`. ### Method `try_into` ### Endpoint N/A (In-memory operation) ### Parameters None ### Request Body None ### Request Example ```rust let value: i32 = 10; let result: Result = value.try_into(); ``` ### Response #### Success Response (Ok) - **U** (type) - The successfully converted value. #### Error Response (Err) - **Error** (type) - The error type defined by `TryFrom` for `U`, indicating conversion failure. #### Response Example ```rust // Success Ok(10u32) // Error Err(conversion_error) ``` ## TryFrom for T ### Description Provides a `try_from` function for attempting conversions that may fail, returning a `Result`. ### Method `try_from` ### Endpoint N/A (In-memory operation) ### Parameters - **value** (U) - Required - The value to convert from. ### Request Body None ### Request Example ```rust let value: u32 = 10; let result: Result = i32::try_from(value); ``` ### Response #### Success Response (Ok) - **T** (type) - The successfully converted value. #### Error Response (Err) - **Error** (type) - The error type defined by `TryFrom` for `T`, indicating conversion failure. #### Response Example ```rust // Success Ok(10i32) // Error Err(conversion_error) ``` ``` -------------------------------- ### TryInto and TryFrom Implementations Source: https://docs.rs/cggmp21/0.6.3/cggmp21/signing/msg/struct.MsgRound4.html Provides functionality for attempting conversions that may fail, returning a Result. ```APIDOC ## TryInto for T ### Description Provides a `try_into` method for attempting conversions that may fail, returning a `Result`. ### Method `try_into` ### Endpoint N/A (Trait method) ### Parameters - `self` (T) - The value to convert. ### Request Body N/A ### Response #### Success Response (Result) - `Ok(U)`: The converted value of type U. - `Err(E)`: The error type returned if conversion fails. ### Response Example ```json { "example": "Ok(converted_value)" } ``` ## TryFrom for T ### Description Provides a `try_from` function for attempting conversions that may fail, returning a `Result`. ### Method `try_from` ### Endpoint N/A (Function) ### Parameters - `value` (U) - The value to convert. ### Request Body N/A ### Response #### Success Response (Result) - `Ok(T)`: The converted value of type T. - `Err(E)`: The error type returned if conversion fails. ### Response Example ```json { "example": "Ok(converted_value)" } ``` ### Error Type `Error = Infallible` (for specific implementations, otherwise `Result>::Error>`) ``` -------------------------------- ### TryFrom and TryInto for Safe Conversions Source: https://docs.rs/cggmp21/0.6.3/cggmp21/signing/msg/struct.MsgRound3.html Demonstrates the use of `TryFrom` and `TryInto` traits for performing fallible conversions between types. These traits are useful when a conversion might fail, providing a `Result` to handle potential errors. ```APIDOC ## TryFrom for T ### Description Provides a way to perform a fallible conversion from type `U` into type `T`. The conversion result is wrapped in a `Result` to handle potential errors. ### Type Alias - **Error** (`Infallible`) - The type returned in the event of a conversion error. In this specific implementation, the error type is `Infallible`, meaning the conversion is guaranteed to succeed if the `U: Into` bound is met. ### Method - **try_from**(value: U) -> Result>::Error> Performs the conversion from `value` of type `U` to type `T`. ## TryInto for T ### Description Provides a way to perform a fallible conversion from type `T` into type `U`. This is the reciprocal trait of `TryFrom`. ### Type Alias - **Error** (`>::Error`) - The type returned in the event of a conversion error. ### Method - **try_into**(self) -> Result>::Error> Performs the conversion from `self` of type `T` to type `U`. ``` -------------------------------- ### PerfReport Struct Source: https://docs.rs/cggmp21/0.6.3/cggmp21/progress/struct.PerfReport.html Represents a performance report generated by PerfProfiler, containing details about setup and round performance. ```APIDOC ## Struct PerfReport ### Description Performance report generated by `PerfProfiler` ### Fields - **setup** (Duration) - Duration of setup phase (time after protocol began and before first round started) - **setup_stages** (Vec) - Stages of setup phase - **rounds** (Vec) - Performance report for each round ``` -------------------------------- ### Getting Affine X Coordinate Source: https://docs.rs/cggmp21/0.6.3/cggmp21/supported_curves/type.Stark.html Implements the HasAffineX trait, providing a method to retrieve the affine x-coordinate of a point. ```rust fn x( point: & as Curve>::Point, ) -> Option< as Curve>::CoordinateArray> ``` -------------------------------- ### Generate auxiliary information Source: https://docs.rs/cggmp21 Run this protocol before DKG to set up Paillier moduli. Prime generation is computationally intensive. ```rust // Prime generation can take a while let pregenerated_primes = cggmp21::PregeneratedPrimes::generate(&mut OsRng); let eid = cggmp21::ExecutionId::new(b"execution id, unique per protocol execution"); let i = /* signer index, same as at keygen */ let n = /* number of signers */ let aux_info = cggmp21::aux_info_gen(eid, i, n, pregenerated_primes) .start(&mut OsRng, party) .await?; ``` -------------------------------- ### ProtocolMessage Implementation for Msg Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/msg/non_threshold/enum.Msg.html Implements the ProtocolMessage trait, providing a method to get the round number associated with the message. ```rust impl ProtocolMessage for Msg { fn round(&self) -> u16 { // ... implementation details ... } } ``` -------------------------------- ### CloneToUninit Method (Nightly) Source: https://docs.rs/cggmp21/0.6.3/cggmp21/signing/struct.DataToSign.html Performs copy-assignment from `self` to `dest` in an uninitialized memory location. This is a nightly-only experimental API. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) where T: Clone, ``` -------------------------------- ### GenericKeygenBuilder Methods for Threshold Keygen Source: https://docs.rs/cggmp21/0.6.3/cggmp21/keygen/type.ThresholdKeygenBuilder.html Provides methods to configure the key generation process, including setting the threshold, digest, security level, progress tracer, broadcast reliability, and HD wallet support. ```APIDOC ## GenericKeygenBuilder Methods ### Description These methods allow configuration of the key generation process before starting. ### Methods #### `set_threshold` - **Description**: Specifies the number of parties required for a threshold scheme. - **Method**: `self.set_threshold(t: u16)` - **Returns**: `GenericKeygenBuilder` configured for threshold. #### `set_digest` - **Description**: Specifies an alternative hash function to use. - **Method**: `self.set_digest()` - **Parameters**: `D2` (type: `Digest + Clone + 'static`) - The new digest type. - **Returns**: `GenericKeygenBuilder` with the updated digest. #### `set_security_level` - **Description**: Specifies the security level for the key generation. - **Method**: `self.set_security_level()` - **Parameters**: `L2` (type: `SecurityLevel`) - The new security level. - **Returns**: `GenericKeygenBuilder` with the updated security level. #### `set_progress_tracer` - **Description**: Sets a tracer to monitor the progress of the protocol execution. - **Method**: `self.set_progress_tracer(tracer: &'a mut dyn Tracer)` - **Parameters**: `tracer` (type: `&'a mut dyn Tracer`) - The progress tracer. - **Returns**: `GenericKeygenBuilder` with the tracer set. #### `enforce_reliable_broadcast` - **Description**: Ensures reliability of the broadcast channel by adding an extra communication round. Defaults to `true`. - **Method**: `self.enforce_reliable_broadcast(enforce: bool)` - **Parameters**: `enforce` (type: `bool`) - `true` to enforce reliable broadcast, `false` otherwise. - **Returns**: `GenericKeygenBuilder` with broadcast reliability setting. #### `hd_wallet` - **Description**: Specifies whether Hierarchical Deterministic (HD) derivation is enabled for the key. Available only with the `hd-wallet` feature flag. - **Method**: `self.hd_wallet(v: bool)` - **Parameters**: `v` (type: `bool`) - `true` to enable HD derivation, `false` otherwise. - **Returns**: `GenericKeygenBuilder` with HD wallet setting. ``` -------------------------------- ### Implement Error for KeyRefreshError: cause (Deprecated) Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/struct.KeyRefreshError.html Deprecated method to get the underlying cause of the error. Replaced by Error::source. ```rust fn cause(&self) -> Option<&dyn Error> ``` -------------------------------- ### GenericKeyRefreshBuilder Configuration Methods Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/type.KeyRefreshBuilder.html Details configuration options for the GenericKeyRefreshBuilder, which also apply to KeyRefreshBuilder. ```APIDOC ## GenericKeyRefreshBuilder Implementations ### `impl<'a, L, D, T> GenericKeyRefreshBuilder<'a, T, L, D>` #### `pub fn set_digest(self) -> GenericKeyRefreshBuilder<'a, T, L, D2>` ##### Description Specifies a different hash function (Digest) to be used in the protocol. #### `pub fn set_progress_tracer(self, tracer: &'a mut dyn Tracer) -> Self` ##### Description Sets a tracer that monitors and reports the progress of the protocol execution. #### `pub fn enforce_reliable_broadcast(self, v: bool) -> Self` ##### Description Ensures the reliability of the broadcast channel by adding an extra communication round. This is crucial for the CGGMP21 protocol's first round. It can be disabled if the transport layer is inherently reliable. - **Default**: `true` #### `pub fn precompute_multiexp_tables(self, v: bool) -> Self` ##### Description Precomputes multiexponentiation tables for auxiliary output data. This optimization speeds up signing and presigning operations but increases the protocol duration and the size of auxiliary data. #### `pub fn precompute_crt(self, v: bool) -> Self` ##### Description Precomputes Chinese Remainder Theorem (CRT) parameters. This optimization speeds up modular exponentiation in Zero-Knowledge proof validation. Precomputation is generally fast and slightly increases the size of the key share in memory and on disk. Note that CRT parameters contain secret information and should be kept confidential. ``` -------------------------------- ### CloneToUninit Trait Implementation Source: https://docs.rs/cggmp21/0.6.3/cggmp21/signing/msg/enum.Msg.html Nightly-only experimental API for cloning to uninitialized memory. ```APIDOC ## impl CloneToUninit for T where T: Clone, ### unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. ``` -------------------------------- ### Get Number of Key Co-holders Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/type.IncompleteKeyShare.html Retrieves the total number of co-holders for the key share. This is a fundamental property for understanding the distribution of the key. ```rust pub fn n(&self) -> u16 ``` -------------------------------- ### Conversion and Casting Traits Source: https://docs.rs/cggmp21/0.6.3/cggmp21/keygen/msg/threshold/struct.MsgRound2Uni.html Documentation for conversion traits (TryFrom, TryInto) and casting traits (UnwrappedCast, WrappingCast). ```APIDOC ## TryFrom for T ### Description Performs a fallible conversion from type U to type T. ### Methods - **try_from(value: U) -> Result**: Performs the conversion. ## TryInto for T ### Description Performs a fallible conversion from type T to type U. ### Methods - **try_into(self) -> Result**: Performs the conversion. ## UnwrappedCast ### Description Provides methods for casting values between types. ### Methods - **unwrapped_as(self) -> Dst**: Casts the value. - **unwrapped_cast_from(src: Src) -> Dst**: Casts the value from a source type. ``` -------------------------------- ### Precompute Multiexponentiation Tables Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/type.AuxInfoGenerationBuilder.html Enables precomputation of multiexponentiation tables to optimize signing and presigning performance. ```rust pub fn precompute_multiexp_tables(self, v: bool) -> Self ``` -------------------------------- ### Get Shared Public Key Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/type.IncompleteKeyShare.html Retrieves the public key that is shared among all signers. This public key is derived from the individual secret shares. ```rust pub fn shared_public_key(&self) -> NonZero> ``` -------------------------------- ### AnyKeyShare Trait Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/trait.AnyKeyShare.html Documentation for the AnyKeyShare trait and its provided methods. ```APIDOC ## Trait AnyKeyShare ### Description Any (validated) key share. Implemented for both `KeyShare` and `IncompleteKeyShare`. Used in methods that accept both types of key shares, like `reconstruct_secret_key`. ### Provided Methods #### fn n(&self) -> u16 Returns the amount of key co-holders. #### fn min_signers(&self) -> u16 Returns the threshold. The threshold is the amount of signers required to cooperate in order to sign a message and/or generate a presignature. #### fn shared_public_key(&self) -> NonZero> Returns the public key shared by signers. ### Implementors #### impl>> AnyKeyShare for T ``` -------------------------------- ### Implement Serialize for VssSetup Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/struct.VssSetup.html Allows VssSetup instances to be serialized into a Serde data format. This is essential for saving and transmitting configurations. ```rust impl Serialize for VssSetup where E: Curve, { fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where __S: Serializer, } ``` -------------------------------- ### Implement CloneToUninit for T (Nightly) Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/msg/non_threshold/struct.MsgReliabilityCheck.html A nightly-only experimental API that performs copy-assignment from self to an uninitialized destination. Use with caution. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. Read more ``` -------------------------------- ### Get Minimum Signers Required Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/type.IncompleteKeyShare.html Returns the threshold, which is the minimum number of signers required to cooperate for signing messages or generating presignatures. This is crucial for threshold cryptography. ```rust pub fn min_signers(&self) -> u16 ``` -------------------------------- ### Set HD Derivation Path Source: https://docs.rs/cggmp21/0.6.3/cggmp21/signing/struct.SigningBuilder.html Configures the HD derivation path for the signing process. Requires the hd-wallet and hd-slip10 crate features. ```rust cggmp21::signing(eid, i, &parties_indexes_at_keygen, &key_share) .set_derivation_path([1, 999])? ``` -------------------------------- ### VssSetup Struct Definition Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/struct.VssSetup.html The VssSetup struct is used to configure the secret sharing setup of a key, specifying the minimum number of signers and their respective key share indexes. ```APIDOC ## VssSetup Struct ### Description Represents the secret sharing setup configuration for a key. ### Fields - **min_signers** (u16) - Threshold parameter specifying how many signers are required to perform signing. - **I** (Vec>>) - Key shares indexes where I[i] corresponds to the key share index of the ith signer. ``` -------------------------------- ### Implement PartialEq for VssSetup Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/struct.VssSetup.html Enables comparison of VssSetup instances for equality. This is used to check if two secret sharing configurations are identical. ```rust impl PartialEq for VssSetup where E: PartialEq + Curve, { fn eq(&self, other: &VssSetup) -> bool } ``` -------------------------------- ### Deref Implementation for Valid Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/type.IncompleteKeyShare.html Enables dereferencing a `Valid` to get a reference to the inner value `T`. This allows `Valid` to be used in contexts where `&T` is expected, providing seamless access to the validated data. ```rust type Target = T ``` ```rust fn deref(&self) -> & as Deref>::Target ``` -------------------------------- ### Conversion Traits Source: https://docs.rs/cggmp21/0.6.3/cggmp21/keygen/struct.GenericKeygenBuilder.html Documentation for standard conversion traits like From, Into, and TryFrom. ```APIDOC ## Conversion Traits ### Description Standard traits for converting between types. ### Methods - **from(t: T) -> T**: Returns the argument unchanged. - **into(self) -> U**: Converts the type into another type U. - **try_from(value: U) -> Result**: Attempts to convert from type U to T. - **try_into(self) -> Result**: Attempts to convert the type into U. ``` -------------------------------- ### Import Key into 3-out-of-5 TSS using Trusted Dealer Source: https://docs.rs/cggmp21/0.6.3/cggmp21/trusted_dealer/index.html Use this snippet to import a secret key into a 3-out-of-5 TSS setup using the trusted dealer builder. Ensure you have a random number generator available. ```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)?; ``` -------------------------------- ### Implement CloneToUninit for T Source: https://docs.rs/cggmp21/0.6.3/cggmp21/keygen/msg/non_threshold/struct.MsgRound2.html An experimental nightly-only API for performing copy-assignment from a value to an uninitialized memory location. ```rust impl CloneToUninit for T where T: Clone, { unsafe fn clone_to_uninit(&self, dest: *mut u8) // ... implementation details ... } ``` -------------------------------- ### GenericKeygenBuilder Configuration Methods Source: https://docs.rs/cggmp21/0.6.3/cggmp21/keygen/type.ThresholdKeygenBuilder.html Methods available on the GenericKeygenBuilder to configure the key generation process. ```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> ``` -------------------------------- ### CloneToUninit Trait Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/msg/non_threshold/enum.Msg.html An experimental nightly-only API for performing copy-assignment to uninitialized memory. ```APIDOC ## CloneToUninit for T ### Description Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API. ### Method `unsafe fn clone_to_uninit(&self, dest: *mut u8)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### PregeneratedPrimes Methods Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/struct.PregeneratedPrimes.html Methods for constructing, splitting, and generating pregenerated primes. ```APIDOC ## new(p, q) ### Description Constructs a new instance of PregeneratedPrimes from two provided big integers. ### Parameters - **p** (Integer) - Required - The first prime number. - **q** (Integer) - Required - The second prime number. ### Response - **Option** - Returns the instance if numbers are >= 4 * L::SECURITY_BITS, otherwise None. --- ## split() ### Description Retrieves the prime numbers stored within the instance. ### Response - **(Integer, Integer)** - Returns the tuple of (p, q). --- ## generate(rng) ### Description Generates new primes using the provided random number generator. ### Parameters - **rng** (RngCore) - Required - A random number generator. ### Response - **Self** - A new instance of PregeneratedPrimes. ``` -------------------------------- ### Implement Clone for MsgRound2 Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/msg/aux_only/struct.MsgRound2.html Provides a `clone` method for MsgRound2, allowing for duplication of its values. Requires the associated `Rid` type to also implement `Clone`. ```rust impl Clone for MsgRound2 where L::Rid: Clone, { fn clone(&self) -> MsgRound2 { // ... implementation details ... } } ``` -------------------------------- ### PerfProfiler Constructor Source: https://docs.rs/cggmp21/0.6.3/cggmp21/progress/struct.PerfProfiler.html Creates a new instance of the PerfProfiler. ```APIDOC ## PerfProfiler::new ### Description Constructs a new PerfProfiler instance. ### Method Rust Function ### Response - **PerfProfiler** (struct) - A new instance of the performance profiler. ``` -------------------------------- ### Implement Error for KeyRefreshError: provide (Nightly) Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_refresh/struct.KeyRefreshError.html Nightly-only experimental API for providing type-based access to error report context. ```rust fn provide<'a>(&'a self, request: &mut Request<'a>) ``` -------------------------------- ### Perform full signing Source: https://docs.rs/cggmp21 Execute a signing protocol using completed key shares. Requires exactly the threshold number of signers. ```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"); let signature = cggmp21::signing(eid, i, &parties_indexes_at_keygen, &key_share) .sign(&mut OsRng, party, data_to_sign) .await?; ``` -------------------------------- ### PartyAux Implementations Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/struct.PartyAux.html Provides methods for precomputing optimization tables for PartyAux, such as multiexponentiation tables and CRT parameters. ```APIDOC ## Implementations for PartyAux ### pub fn precompute_multiexp_table(&mut self) -> Result<(), InvalidKeyShare> #### Description Precompute multiexponentiation table. Enables optimization that makes signing and presigning faster. Precomputation may take a while. It noticeably increases the size of aux data both in RAM and on disk (after serialization). #### Returns - `Ok(())` on success. - `Err(InvalidKeyShare)` if building a multiexp table failed. #### Notes - On success, multiexp tables are saved (old tables, if present, are overwritten). - Provided security level must match the actual security level being used in the protocol. Otherwise, optimization won’t work, and it will actually make the protocol slower. ### pub fn precompute_crt(&mut self, p: &Integer, q: &Integer) -> Result<(), InvalidKeyShare> #### Description Precomputes CRT parameters. Enables optimization of modular exponentiation in Zero-Knowledge proofs validation. Precomputation should be relatively fast. It increases the size of the key share in RAM and on disk, but not noticeably. #### Parameters - **p** (Integer) - Prime factor p of N. - **q** (Integer) - Prime factor q of N. #### Returns - `Ok(())` on success. - `Err(InvalidKeyShare)` if provided primes do not correspond to a Paillier secret key of the signer, or if precomputation failed. #### Notes - On success, updates CRT params stored within the structure (old params, if present, are overwritten). - CRT parameters contain secret information. Leaking them exposes the secret Paillier key. Keep `AuxInfo::parties` secret (as well as the rest of the key share). ``` -------------------------------- ### CloneToUninit Trait Source: https://docs.rs/cggmp21/0.6.3/cggmp21/key_share/struct.DirtyIncompleteKeyShare.html Nightly-only experimental API for cloning to uninitialized memory. ```APIDOC ## impl CloneToUninit for T where T: Clone, #### unsafe fn clone_to_uninit(&self, dest: *mut u8) 🔬This is a nightly-only experimental API. (`clone_to_uninit`) Performs copy-assignment from `self` to `dest`. Read more ``` -------------------------------- ### Implement Instrument for MsgRound2Uni Source: https://docs.rs/cggmp21/0.6.3/cggmp21/keygen/msg/threshold/struct.MsgRound2Uni.html Provides methods to instrument MsgRound2Uni with spans for tracing. ```rust fn instrument(self, span: Span) -> Instrumented ``` ```rust fn in_current_span(self) -> Instrumented ``` -------------------------------- ### Sync API Wrapper for CGGMP21 Protocols Source: https://docs.rs/cggmp21/0.6.3/cggmp21/index.html Provides a synchronous API for CGGMP21 protocols when running in a non-async environment. Requires enabling the `state-machine` feature. Use companion functions like `generate_presignature_sync`. ```rust // Example for presignature generation: let state_machine = cggmp21::signing::SigningBuilder::generate_presignature_sync(...); // Use state_machine to carry out the protocol synchronously. ``` -------------------------------- ### Set Derivation Path (Generic Algorithm) Source: https://docs.rs/cggmp21/0.6.3/cggmp21/signing/struct.Presignature.html Specifies an HD derivation path using a generic HdWallet algorithm. This method is available only when the 'hd-wallet' feature is enabled. It requires an extended public key and a derivation path, and outputs a presignature signed with a child key. Ensure all signers use the same derivation path for a valid signature. ```rust pub fn set_derivation_path_with_algo, Index>( self, epub: ExtendedPublicKey, derivation_path: impl IntoIterator, ) -> Result>::Error> where NonHardenedIndex: TryFrom, ```