Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cronokirby committed Nov 17, 2023
1 parent bca4578 commit d45aee1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
1 change: 1 addition & 0 deletions crates/custody/src/threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use tonic::{async_trait, Request, Response, Status};

use crate::AuthorizeRequest;

mod config;
mod sign;

/// A custody backend using threshold signing.
Expand Down
9 changes: 9 additions & 0 deletions crates/custody/src/threshold/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[derive(Debug, Clone)]
pub struct Config {
}

impl Config {
pub fn deal(t: usize, n: usize) -> Vec<Config> {
todo!()
}
}
42 changes: 34 additions & 8 deletions crates/custody/src/threshold/sign.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use anyhow::anyhow;
use anyhow::{anyhow, Result};
use decaf377_frost as frost;
use ed25519_consensus::{Signature, VerificationKey};
use penumbra_proto::{penumbra::custody::threshold::v1alpha1 as pb, DomainType, TypeUrl};
use penumbra_transaction::plan::TransactionPlan;

use super::config::Config;

/// Represents the message sent by the coordinator at the start of the signing process.
///
/// This is nominally "round 1", even though it's the only message the coordinator ever sends.
Expand All @@ -12,13 +14,6 @@ pub struct CoordinatorRound1 {
plan: TransactionPlan,
}

impl CoordinatorRound1 {
/// Construct a new round1 package given a transaction plan.
pub fn new(plan: TransactionPlan) -> Self {
Self { plan }
}
}

impl From<CoordinatorRound1> for pb::CoordinatorRound1 {
fn from(value: CoordinatorRound1) -> Self {
Self {
Expand All @@ -45,6 +40,8 @@ impl DomainType for CoordinatorRound1 {
type Proto = pb::CoordinatorRound1;
}

pub struct CoordinatorRound2 {}

/// The message sent by the followers in round1 of signing.
#[derive(Debug, Clone)]
pub struct FollowerRound1 {
Expand Down Expand Up @@ -143,3 +140,32 @@ impl TypeUrl for FollowerRound2 {
impl DomainType for FollowerRound2 {
type Proto = pb::FollowerRound2;
}

pub struct CoordinatorState {}

pub struct FollowerState {}

pub fn coordinator_round1(
config: &Config,
plan: TransactionPlan,
) -> Result<(CoordinatorRound1, CoordinatorState)> {
todo!()
}

pub fn coordinator_round2(
config: &Config,
follower_messages: &[FollowerRound1],
) -> Result<CoordinatorRound2> {
todo!()
}

pub fn follower_round1(
config: &Config,
coordinator: CoordinatorRound1,
) -> Result<(FollowerRound1, FollowerState)> {
todo!()
}

pub fn follower_round2(config: &Config, state: FollowerState) -> Result<FollowerRound2> {
todo!()
}

0 comments on commit d45aee1

Please sign in to comment.