Trait Scheme

Source
pub(crate) trait Scheme {
    // Required methods
    fn new(host_url: String) -> Self;
    fn host_url(&self) -> &str;

    // Provided methods
    fn with_default_host() -> Self
       where Self: Sized { ... }
    fn init_keygen(&self) -> Result<(KeygenId, KeygenPrivateKey), SodotError> { ... }
    fn create_room(
        &self,
        num_parties: NonZeroU16,
        api_key: &str,
    ) -> impl Future<Output = Result<RoomUUID, SodotError>> { ... }
}
Expand description

The core trait for implementing cryptographic schemes using threshold signatures.

The Scheme trait provides the foundational functionality for multi-party computation protocols, including key generation initialization and room creation. Concrete implementations of this trait will provide specific cryptographic schemes like ECDSA, Ed25519, BIP340, and SR25519.

§Key Concepts

  • Threshold Cryptography: Multiple parties collaborate to generate keys and sign messages
  • MPC (Multi-Party Computation): Secure protocols that don’t require a trusted dealer
  • Rooms: Communication channels that coordinate the MPC protocols between parties
  • Host URL: The Sodot relay server that facilitates communication between parties

§Basic Workflow

  1. Initialize the scheme with a host URL
  2. Generate keygen initialization material using init_keygen()
  3. Create a room using create_room()
  4. Coordinate with other parties to perform MPC operations

This trait defines the common interface for all cryptographic schemes supported by the Sodot SDK. It provides methods for key generation initialization and room creation for multi-party computation operations.

Required Methods§

Source

fn new(host_url: String) -> Self

Creates a new instance of the scheme with the specified host URL.

Source

fn host_url(&self) -> &str

Returns the host URL configured for this scheme instance.

Provided Methods§

Source

fn with_default_host() -> Self
where Self: Sized,

Creates a new scheme instance using the default production host URL.

Convenience method that creates an instance configured to use the default Sodot production relay server at “us1.sodot.dev”.

Source

fn init_keygen(&self) -> Result<(KeygenId, KeygenPrivateKey), SodotError>

Initializes the key generation process by creating a keygen ID and private key.

Generates the initial cryptographic material needed to participate in multi-party key generation protocols. The keygen ID serves as a unique identifier for this party, while the keygen private key is used for authentication.

Source

fn create_room( &self, num_parties: NonZeroU16, api_key: &str, ) -> impl Future<Output = Result<RoomUUID, SodotError>>

Creates a room for coordinating multi-party computation protocols.

A room serves as a communication channel and session identifier for MPC operations. All parties participating in the same protocol must use the same room UUID. Typically, one party creates the room and shares the UUID with other participants.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§