Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5ee6fec
Augment coordinator round 1 proto message with additional signing req…
plaidfinch Mar 22, 2024
edfa3e9
Adapt threshold code to thread signing requests of different kinds
plaidfinch Mar 16, 2024
a298afb
Add fields to auth data proto to accommodate validator def and vote
plaidfinch Mar 22, 2024
fe37923
Rename AuthorizationData to TransactionAuthorizationData
plaidfinch Mar 22, 2024
270533b
Finish up transaction authorization data refactor by adding missing i…
plaidfinch Mar 22, 2024
c8b7bbc
Generalize the cached effect hash in coordinator state
plaidfinch Mar 22, 2024
d092754
Re-add no-LFS proto descriptor deleted by accident in rebase
plaidfinch Mar 22, 2024
d464365
Fill in todo items to actually sign val defs and votes
plaidfinch Mar 22, 2024
4b4b925
Add RPC methods to protos for authorizing validator actions
plaidfinch Mar 22, 2024
ca8b8f9
Fill in missing methods with unimplemented errors
plaidfinch Mar 22, 2024
3ab5995
Implement validator signing custody rpc methods
plaidfinch Mar 22, 2024
45cb35c
Rename TransactionAuthorizationData back to just AuthorizationData
plaidfinch Mar 23, 2024
1de881c
Refactor CoordinatorRound1 to proper oneof
plaidfinch Mar 23, 2024
aab99fd
Use custody service for all signing in pcli
plaidfinch Mar 23, 2024
f09f338
Fix threshold tests
plaidfinch Mar 23, 2024
221c6c2
Use separate governance custody in pcli, once more
plaidfinch Mar 23, 2024
893ede9
Automatically pick correct custody for pcli threshold sign
plaidfinch Mar 23, 2024
3d4e2f1
Correct help text for threshold signing
cronokirby Mar 26, 2024
d83c705
Add shortcut for threshold signing with no signatures
cronokirby Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add shortcut for threshold signing with no signatures
This will no longer prompt for signatures if none are required for a
transaction.
  • Loading branch information
cronokirby committed Mar 26, 2024
commit d83c705b08648da14c8addb2d7219335843f232c
6 changes: 6 additions & 0 deletions crates/custody/src/threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use penumbra_proto::{custody::v1 as pb, DomainType};
use crate::{AuthorizeRequest, AuthorizeValidatorDefinitionRequest, AuthorizeValidatorVoteRequest};

pub use self::config::Config;
use self::sign::no_signature_response;
pub use self::sign::{SigningRequest, SigningResponse};

mod config;
Expand Down Expand Up @@ -206,6 +207,11 @@ impl<T> Threshold<T> {
impl<T: Terminal> Threshold<T> {
/// Try and create the necessary signatures to authorize the transaction plan.
async fn authorize(&self, request: SigningRequest) -> Result<SigningResponse> {
// Some requests will have no signatures to gather, so there's no need
// to send around empty threshold signature requests.
if let Some(out) = no_signature_response(self.config.fvk(), &request)? {
return Ok(out);
}
// Round 1
let (round1_message, state1) = sign::coordinator_round1(&mut OsRng, &self.config, request)?;
self.terminal
Expand Down
31 changes: 25 additions & 6 deletions crates/custody/src/threshold/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{

use anyhow::{anyhow, Result};
use ed25519_consensus::{Signature, SigningKey, VerificationKey};
use penumbra_keys::FullViewingKey;
use rand_core::CryptoRngCore;

use decaf377_frost as frost;
Expand Down Expand Up @@ -352,6 +353,23 @@ fn required_signatures(request: &SigningRequest) -> usize {
}
}

/// Create a trivial signing response if no signatures are needed.
pub fn no_signature_response(
fvk: &FullViewingKey,
request: &SigningRequest,
) -> Result<Option<SigningResponse>> {
match request {
SigningRequest::TransactionPlan(plan) if required_signatures(request) <= 0 => {
Ok(Some(SigningResponse::Transaction(AuthorizationData {
effect_hash: Some(plan.effect_hash(fvk)?),
spend_auths: Vec::new(),
delegator_vote_auths: Vec::new(),
})))
}
_ => Ok(None),
}
}

pub struct CoordinatorState1 {
request: SigningRequest,
my_round1_reply: FollowerRound1,
Expand All @@ -372,18 +390,19 @@ enum ToBeSigned {
}

impl SigningRequest {
fn to_be_signed(&self, config: &Config) -> ToBeSigned {
match self {
fn to_be_signed(&self, config: &Config) -> Result<ToBeSigned> {
let out = match self {
SigningRequest::TransactionPlan(plan) => {
ToBeSigned::EffectHash(plan.effect_hash(config.fvk()).unwrap())
ToBeSigned::EffectHash(plan.effect_hash(config.fvk())?)
}
SigningRequest::ValidatorDefinition(validator) => ToBeSigned::ValidatorDefinitionBytes(
ProtoValidator::from(validator.clone()).encode_to_vec(),
),
SigningRequest::ValidatorVote(vote) => ToBeSigned::ValidatorVoteBytes(
ProtoValidatorVoteBody::from(vote.clone()).encode_to_vec(),
),
}
};
Ok(out)
}
}

Expand Down Expand Up @@ -444,7 +463,7 @@ pub fn coordinator_round2(

let my_round2_reply = follower_round2(config, state.my_round1_state, reply.clone())?;

let to_be_signed = state.request.to_be_signed(&config);
let to_be_signed = state.request.to_be_signed(&config)?;

let signing_packages = {
reply
Expand Down Expand Up @@ -564,7 +583,7 @@ pub fn follower_round2(
state: FollowerState,
coordinator: CoordinatorRound2,
) -> Result<FollowerRound2> {
let to_be_signed = state.request.to_be_signed(config);
let to_be_signed = state.request.to_be_signed(config)?;
let signing_packages = coordinator
.all_commitments
.into_iter()
Expand Down