Skip to main content

ThresholdPolicy

Struct ThresholdPolicy 

Source
pub struct ThresholdPolicy {
    pub threshold: u8,
    pub signers: Vec<String>,
    pub policy_id: String,
    pub scope: Option<Capability>,
    pub ceremony_endpoint: Option<String>,
}
Expand description

Policy for threshold signature operations (M-of-N).

This struct defines the parameters for FROST (Flexible Round-Optimized Schnorr Threshold) signature operations. FROST enables M-of-N threshold signing where at least M participants must cooperate to produce a valid signature, but no single participant can sign alone.

§Protocol Choice: FROST

FROST was chosen over alternatives for several reasons:

  • Ed25519 native: Works with existing Ed25519 key infrastructure
  • Round-optimized: Only 2 rounds for signing (vs 3+ for alternatives)
  • Rust ecosystem: frost-ed25519 crate from ZcashFoundation is mature
  • Security: Proven secure under discrete log assumption

§Key Generation Approaches

Two approaches exist for generating threshold key shares:

  1. Trusted Dealer: One party generates the key and distributes shares

    • Simpler to implement
    • Single point of failure during key generation
    • Appropriate for org-controlled scenarios
  2. Distributed Key Generation (DKG): Participants jointly generate key

    • No single party ever sees the full key
    • More complex, requires additional round-trips
    • Better for trustless scenarios

§Integration with Auths

Threshold policies can be attached to high-value operations like:

  • sign-release: Release signing requires M-of-N approvers
  • rotate-keys: Key rotation requires multi-party approval
  • manage-members: Adding admins requires quorum

§Example

let policy = ThresholdPolicy {
    threshold: 2,
    signers: vec![
        "did:key:alice".to_string(),
        "did:key:bob".to_string(),
        "did:key:carol".to_string(),
    ],
    policy_id: "release-signing-v1".to_string(),
    scope: Some(Capability::sign_release()),
    ceremony_endpoint: Some("wss://auths.example/ceremony".to_string()),
};
// 2-of-3: Any 2 of Alice, Bob, Carol can sign releases

§Storage

Key shares are NOT stored in Git refs (they are secrets). Options:

  • Platform keychain (macOS Keychain, Windows Credential Manager)
  • Hardware security modules (HSMs)
  • Secret managers (Vault, AWS Secrets Manager)

The policy itself (public info) is stored in Git at: refs/auths/policies/threshold/<policy_id>

Fields§

§threshold: u8

Minimum signers required (M in M-of-N)

§signers: Vec<String>

Total authorized signers (N in M-of-N) - DIDs of participants

§policy_id: String

Unique identifier for this policy

§scope: Option<Capability>

Scope of operations this policy covers (optional)

§ceremony_endpoint: Option<String>

Ceremony coordination endpoint (e.g., WebSocket URL for signing rounds)

Implementations§

Source§

impl ThresholdPolicy

Source

pub fn new(threshold: u8, signers: Vec<String>, policy_id: String) -> Self

Create a new threshold policy

Source

pub fn is_valid(&self) -> bool

Check if the policy parameters are valid

Source

pub fn m_of_n(&self) -> (u8, usize)

Returns M (threshold) and N (total signers)

Trait Implementations§

Source§

impl Clone for ThresholdPolicy

Source§

fn clone(&self) -> ThresholdPolicy

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ThresholdPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ThresholdPolicy

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ThresholdPolicy

Source§

fn eq(&self, other: &ThresholdPolicy) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ThresholdPolicy

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for ThresholdPolicy

Source§

impl StructuralPartialEq for ThresholdPolicy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,