OpenAgentID documentation
Source referencesRust module referenceoas-crypto

oas-crypto · frost

Declared module signatures, types, configuration, and source documentation.

Source: oas/oas/oas-crypto/src/frost.rs. SHA-256: 3912035cf53fba877d0f3104766a7316caa0801ccdd8d5361751c0deb3e85d0c.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

Module condition:

#[cfg(feature = "frost")]

frost::FrostKeySet

A complete FROST threshold key set for a group of participants.

Generated via trusted dealer key generation using [frost_keygen]. Contains individual key packages for each participant and the shared group public key package used for signature aggregation and verification.

Security

The key packages contain secret shares that MUST be distributed securely to individual participants. In production, each participant should receive only their own key package. This struct holds all packages together for testing and single-node scenarios.

Private key material is redacted in Debug output.

Examples

use oas_crypto::frost::frost_keygen;

let key_set = frost_keygen(2, 3).unwrap();
assert_eq!(key_set.min_signers(), 2);
assert_eq!(key_set.max_signers(), 3);
assert_eq!(key_set.group_public_key().len(), 32);
#[cfg(feature = "frost")]
pub struct FrostKeySet {

}

Source line: 77.

frost::FrostKeySet::group_public_key

Returns the group verifying (public) key as raw bytes.

This key can verify any threshold signature produced by this key set. It is a standard 32-byte Ed25519 public key.

Returns

32-byte Ed25519 verifying key for the group.

Panics

Never panics — serialization of a valid verifying key always succeeds.

Examples

use oas_crypto::frost::frost_keygen;

let key_set = frost_keygen(2, 3).unwrap();
assert_eq!(key_set.group_public_key().len(), 32);
#[cfg(feature = "frost")]
pub fn group_public_key(&self) -> Vec<u8>;

Source line: 119.

frost::FrostKeySet::min_signers

Returns the minimum number of signers required to produce a signature.

Returns

The threshold value t from the t-of-n configuration.

#[cfg(feature = "frost")]
pub fn min_signers(&self) -> u16;

Source line: 133.

frost::FrostKeySet::max_signers

Returns the total number of participants in the group.

Returns

The total participant count n from the t-of-n configuration.

#[cfg(feature = "frost")]
pub fn max_signers(&self) -> u16;

Source line: 142.

frost::FrostKeySet::pubkey_package

Returns a reference to the FROST public key package.

Useful for advanced scenarios like manual signature aggregation or interoperability with other FROST implementations.

#[cfg(feature = "frost")]
pub fn pubkey_package(&self) -> &frost::keys::PublicKeyPackage;

Source line: 150.

frost::frost_keygen

Generates a FROST threshold key set using trusted dealer key generation.

Creates a t-of-n threshold configuration where any min_signers participants out of max_signers total can collaboratively sign. The dealer generates all secret shares and distributes them — the dealer must be trusted.

Arguments

  • min_signers - Minimum number of participants required to sign (threshold t). Must be >= 2 for threshold security.
  • max_signers - Total number of participants (n). Must be >= min_signers.

Returns

A [FrostKeySet] containing all participant key packages and the group public key.

Errors

Returns [CryptoError::FrostKeyGenFailed] if:

  • min_signers < 2 (single-signer defeats the purpose of threshold)
  • max_signers < min_signers (impossible threshold)
  • Internal FROST key generation fails

Examples

use oas_crypto::frost::frost_keygen;

// 3-of-5 threshold
let key_set = frost_keygen(3, 5).unwrap();
assert_eq!(key_set.min_signers(), 3);
assert_eq!(key_set.max_signers(), 5);
assert_eq!(key_set.group_public_key().len(), 32);

// 2-of-2 is the minimum valid threshold
let key_set_2 = frost_keygen(2, 2).unwrap();
assert_eq!(key_set_2.min_signers(), 2);
#[cfg(feature = "frost")]
pub fn frost_keygen(min_signers: u16, max_signers: u16) -> Result<FrostKeySet, CryptoError>;

Source line: 193.

frost::frost_sign

Performs a complete FROST threshold signing operation.

Executes the full two-round FROST signing protocol with the specified participants. The result is a standard 64-byte Ed25519 signature that can be verified by any Ed25519 verifier using the group public key.

Arguments

  • message - The message bytes to sign.
  • key_set - The FROST key set generated by [frost_keygen].
  • participant_indices - Zero-based indices selecting which participants sign. Must contain exactly [FrostKeySet::min_signers()] entries, with no duplicates, and all indices must be < [FrostKeySet::max_signers()].

Returns

A 64-byte Ed25519 signature.

Errors

Returns [CryptoError::FrostInvalidParticipants] if:

  • Number of participants doesn't equal min_signers
  • Any participant index is out of range
  • Duplicate participant indices are provided

Returns [CryptoError::FrostSigningFailed] if a signing round fails.

Returns [CryptoError::FrostAggregationFailed] if signature aggregation fails.

Returns [CryptoError::FrostSerializationFailed] if the signature cannot be serialized.

Examples

use oas_crypto::frost::{frost_keygen, frost_sign};

let key_set = frost_keygen(2, 3).unwrap();

// Any 2 of the 3 participants can sign
let sig_01 = frost_sign(b"hello", &key_set, &[0, 1]).unwrap();
let sig_12 = frost_sign(b"hello", &key_set, &[1, 2]).unwrap();
let sig_02 = frost_sign(b"hello", &key_set, &[0, 2]).unwrap();

assert_eq!(sig_01.len(), 64);
assert_eq!(sig_12.len(), 64);
assert_eq!(sig_02.len(), 64);
#[cfg(feature = "frost")]
pub fn frost_sign(
    message: &[u8],
    key_set: &FrostKeySet,
    participant_indices: &[usize],
) -> Result<Vec<u8>, CryptoError>;

Source line: 298.

frost::frost_verify

Verifies a FROST threshold signature against a group public key.

Since FROST produces standard Ed25519 signatures, this delegates to the same Ed25519 verification used throughout OAS. The group public key is obtained from [FrostKeySet::group_public_key].

Arguments

  • message - The original message that was signed.
  • signature_bytes - The 64-byte Ed25519 signature from [frost_sign].
  • group_public_key - The 32-byte group verifying key from [FrostKeySet::group_public_key].

Returns

Ok(()) if the signature is valid.

Errors

Returns [CryptoError::FrostVerificationFailed] if the signature does not verify against the group public key.

Returns [CryptoError::InvalidKeyLength] if key or signature bytes are the wrong length.

Examples

use oas_crypto::frost::{frost_keygen, frost_sign, frost_verify};

let key_set = frost_keygen(2, 3).unwrap();
let sig = frost_sign(b"test", &key_set, &[0, 1]).unwrap();

// Valid verification
assert!(frost_verify(b"test", &sig, &key_set.group_public_key()).is_ok());

// Wrong message fails
assert!(frost_verify(b"wrong", &sig, &key_set.group_public_key()).is_err());
#[cfg(feature = "frost")]
pub fn frost_verify(
    message: &[u8],
    signature_bytes: &[u8],
    group_public_key: &[u8],
) -> Result<(), CryptoError>;

Source line: 441.

On this page