WIP: feat-shamir (old) #103

Draft
CleverWild wants to merge 66 commits from feat-shamir into main
5 changed files with 19 additions and 37 deletions
Showing only changes of commit d64478b301 - Show all commits

View File

@@ -2,6 +2,8 @@ syntax = "proto3";
package arbiter.operator.governance;
import "google/protobuf/empty.proto";
message Request {
oneof payload {
CreateProposalRequest create = 1;
@@ -13,13 +15,13 @@ message Request {
message CreateProposalRequest {
oneof kind {
ApproveSdkClientPayload approve_sdk_client = 1;
GrantWalletAccessPayload grant_wallet_access = 3;
ReplaceOperatorPayload replace_operator = 5;
UpdateShamirParametersPayload update_shamir_parameters = 6;
ApprovePersistentGrantPayload approve_persistent_grant = 7;
ApproveOneOffTransactionPayload approve_one_off_transaction = 8;
GrantWalletAccessPayload grant_wallet_access = 2;
ReplaceOperatorPayload replace_operator = 3;
google.protobuf.Empty trigger_rekey = 4;
ApprovePersistentGrantPayload approve_persistent_grant = 5;
ApproveOneOffTransactionPayload approve_one_off_transaction = 6;
}
optional uint32 ttl_secs = 2;
optional uint32 ttl_secs = 7;
}
message ReplaceOperatorPayload {
@@ -27,10 +29,6 @@ message ReplaceOperatorPayload {
bytes new_pubkey = 2;
}
message UpdateShamirParametersPayload {
uint32 new_n = 1;
}
message ApproveSdkClientPayload {
int32 client_id = 1;
}

View File

@@ -42,9 +42,7 @@ pub enum ProposalKind {
old_operator_id: i32,
new_pubkey: Vec<u8>,
},
UpdateShamirParameters {
new_n: u8,
},
TriggerRekey,
ApprovePersistentGrant {
CleverWild marked this conversation as resolved Outdated

Scope creep, remove this for now

Scope creep, remove this for now
payload_bytes: Vec<u8>,
},
@@ -77,7 +75,7 @@ impl ProposalKind {
buf.extend_from_slice(new_pubkey);
buf
}
Self::UpdateShamirParameters { new_n } => vec![*new_n],
Self::TriggerRekey => vec![],
Self::ApprovePersistentGrant { payload_bytes }
CleverWild marked this conversation as resolved Outdated

Wigga, please. Remove homebrew protocol, instead, make those as protobuf entities. And convert to them using already established traits, wigga

Wigga, please. Remove homebrew protocol, instead, make those as protobuf entities. And convert to them using already established traits, wigga
| Self::ApproveOneOffTransaction { payload_bytes } => payload_bytes.clone(),
}
@@ -88,7 +86,7 @@ impl ProposalKind {
pub fn requires_full_quorum(kind: &str) -> bool {
matches!(
kind.parse::<ProposalKindTag>(),
Ok(ProposalKindTag::ReplaceOperator | ProposalKindTag::UpdateShamirParameters)
Ok(ProposalKindTag::ReplaceOperator | ProposalKindTag::TriggerRekey)
)
}
@@ -131,12 +129,7 @@ impl ProposalKind {
new_pubkey,
})
}
ProposalKindTag::UpdateShamirParameters => {
let &[new_n] = payload else {
return Err("invalid payload for update_shamir_parameters".to_owned());
};
Ok(Self::UpdateShamirParameters { new_n })
}
ProposalKindTag::TriggerRekey => Ok(Self::TriggerRekey),
ProposalKindTag::ApprovePersistentGrant => Ok(Self::ApprovePersistentGrant {
payload_bytes: payload.to_vec(),
}),
@@ -696,9 +689,7 @@ impl ProposalManager {
self.execute_replace_operator(old_operator_id, new_pubkey)
.await
}
ProposalKind::UpdateShamirParameters { new_n } => {
self.execute_update_shamir_parameters(new_n).await
}
ProposalKind::TriggerRekey => self.execute_trigger_rekey().await,
ProposalKind::ApprovePersistentGrant { payload_bytes } => {
self.execute_approve_persistent_grant(payload_bytes).await
}
@@ -764,7 +755,7 @@ impl ProposalManager {
}
/// Triggers a Shamir re-key with the current operator set (§3.3).
async fn execute_update_shamir_parameters(&self, _new_n: u8) -> Result<(), Error> {
async fn execute_trigger_rekey(&self) -> Result<(), Error> {
self.vault_coordinator
.ask(StartRekey {})
.await

View File

@@ -62,7 +62,7 @@ enum CoordinatorState {
ordinary_passphrases: HashMap<i32, Vec<u8>>,
recovery_passphrases: HashMap<i32, Vec<u8>>,
},
/// Shamir re-key after `replace_operator` or `update_shamir_parameters` is approved (§3.3).
/// Shamir re-key after `replace_operator` or `trigger_rekey` is approved (§3.3).
/// Collects new passphrases from all current operators, then generates a fresh seal key,
/// re-splits it, and re-encrypts the vault root key.
Rekeying {
@@ -297,7 +297,7 @@ async fn finalize_unseal(
}
/// §3.3: Generate a fresh seal key, split across current operators, re-encrypt the vault root key.
/// Called after `replace_operator` or `update_shamir_parameters` is approved and all contributors submit.
/// Called after `replace_operator` or `trigger_rekey` is approved and all contributors submit.
async fn finalize_rekey(
db: db::DatabasePool,
vault: ActorRef<Vault>,

View File

@@ -56,14 +56,7 @@ async fn handle_create(
old_operator_id: p.old_operator_id,
new_pubkey: p.new_pubkey,
},
Some(ProtoKind::UpdateShamirParameters(p)) => ProposalKind::UpdateShamirParameters {
#[expect(
clippy::cast_possible_truncation,
clippy::as_conversions,
reason = "new_n is always a small operator count"
)]
new_n: p.new_n as u8,
},
Some(ProtoKind::TriggerRekey(())) => ProposalKind::TriggerRekey,
Some(ProtoKind::ApprovePersistentGrant(p)) => {
use prost::Message as _;
ProposalKind::ApprovePersistentGrant {

View File

@@ -827,7 +827,7 @@ async fn replace_operator_updates_pubkey_and_starts_rekey() {
}
#[tokio::test]
async fn update_shamir_parameters_reaches_quorum() {
async fn trigger_rekey_reaches_quorum() {
let db = db::create_test_pool().await;
let actors = GlobalActors::spawn(db.clone()).await.unwrap();
actors
@@ -842,7 +842,7 @@ async fn update_shamir_parameters_reaches_quorum() {
let proposal_id = actors
.proposal_manager
.ask(CreateProposal {
kind: ProposalKind::UpdateShamirParameters { new_n: 5 },
kind: ProposalKind::TriggerRekey,
initiator_id: op_id,
ttl_secs: None,
})