Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing proto definitions #878

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions protobufs/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ lint:
- MINIMAL
- BASIC
- ENUM_ZERO_VALUE_SUFFIX
- ENUM_VALUE_PREFIX
- FILE_LOWER_SNAKE_CASE
- RPC_REQUEST_RESPONSE_UNIQUE
- RPC_REQUEST_STANDARD_NAME
Expand Down
34 changes: 26 additions & 8 deletions protobufs/crypto/wsts/wsts.proto
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@ message DkgEnd {
DkgStatus status = 3;
}

// Signature type
// This maps to this type <https://github.com/Trust-Machines/wsts/blob/ebd7d7775ad5e44cdbf4f5c1fb468bdf6c467265/src/net.rs#L373-L382>
message SignatureType {
oneof signature_type {
// FROST signature
FrostSignatureType frost = 1;
// BIP-340 Schnorr proof
SchnorrSignatureType schnorr = 2;
// BIP-341 Taproot style schnorr proof with a merkle root
TaprootSignatureType taproot = 3;
}
}

message FrostSignatureType {}

message SchnorrSignatureType {}

message TaprootSignatureType {
// Taproot merkle root. This field is optional
MerkleRoot merkle_root = 1;
}

// Nonce request message from coordinator to signers
// This maps to this type <https://github.com/Trust-Machines/wsts/blob/2d6cb87218bb8dd9ed0519356afe57a0b9a697cb/src/net.rs#L265-L280>
message NonceRequest {
Expand All @@ -113,10 +135,8 @@ message NonceRequest {
uint64 sign_iter_id = 3;
// The message to sign
bytes message = 4;
// Whether to make a taproot signature
bool is_taproot = 5;
// Taproot merkle root. This field is optional
MerkleRoot merkle_root = 6;
// What type of signature to create
SignatureType signature_type = 5;
}

// Nonce response message from signers to coordinator
Expand Down Expand Up @@ -151,10 +171,8 @@ message SignatureShareRequest {
repeated NonceResponse nonce_responses = 4;
// Bytes to sign.
bytes message = 5;
// Whether to make a taproot signature
bool is_taproot = 6;
// Taproot merkle root. This field is optional
MerkleRoot merkle_root = 7;
// What type of signature to create
SignatureType signature_type = 6;
}

// Signature share response message from signers to coordinator
Expand Down
129 changes: 129 additions & 0 deletions protobufs/stacks/signer/v1/messages.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
syntax = "proto3";

package stacks.signer.v1;

import "bitcoin/bitcoin.proto";
import "crypto/common.proto";
import "crypto/wsts/wsts.proto";
import "stacks/common.proto";
import "stacks/signer/v1/decisions.proto";
import "stacks/signer/v1/requests.proto";

// Messages exchanged between signers
message SignerMessage {
/// The bitcoin chain tip defining the signers view of the blockchain at the time the message was created
bitcoin.BitcoinBlockHash bitcoin_chain_tip = 1;
// The message payload
oneof payload {
/// A decision related to signer deposit
SignerDepositDecision signer_deposit_decision = 2;
// A decision related to signer withdrawal
SignerWithdrawalDecision signer_withdrawal_decision = 3;
// A request to sign a Stacks transaction
StacksTransactionSignRequest stacks_transaction_sign_request = 4;
// A signature of a Stacks transaction
StacksTransactionSignature stacks_transaction_signature = 5;
// A request to sign a Bitcoin transaction
BitcoinTransactionSignRequest bitcoin_transaction_sign_request = 6;
// An acknowledgment of a signed Bitcoin transaction
BitcoinTransactionSignAck bitcoin_transaction_sign_ack = 7;
// Contains all variants for DKG and WSTS signing rounds
WstsMessage wsts_message = 8;
// Information about a new sweep transaction
SweepTransactionInfo sweep_transaction_info = 9;
}
}

// Represents information about a deposit request being swept-in by a sweep transaction.
message SweptDeposit {
// The index of the deposit input in the sBTC sweep transaction.
uint32 input_index = 1;
// The Bitcoin txid of the deposit request UTXO being swept-in by this
// transaction.
bitcoin.BitcoinTxid deposit_request_txid = 2;
// The Bitcoin output index of the deposit request UTXO being swept-in by
// this transaction.
uint32 deposit_request_output_index = 3;
}

// Represents information about a withdrawal request being swept-out by a sweep transaction.
message SweptWithdrawal {
// The index of the withdrawal output in the sBTC sweep transaction.
uint32 output_index = 1;
// The public request id of the withdrawal request serviced by this
// transaction.
uint64 withdrawal_request_id = 2;
// The Stacks block hash of the Stacks block which included the withdrawal
// request transaction.
stacks.StacksBlockId withdrawal_request_block_hash = 3;
}

// Represents information about a new sweep transaction.
message SweepTransactionInfo {
matteojug marked this conversation as resolved.
Show resolved Hide resolved
// The Bitcoin transaction id of the sweep transaction.
bitcoin.BitcoinTxid txid = 1;
// The transaction id of the signer UTXO consumed by this transaction.
bitcoin.BitcoinTxid signer_prevout_txid = 2;
// The index of the signer UTXO consumed by this transaction.
uint32 signer_prevout_output_index = 3;
// The amount of the signer UTXO consumed by this transaction.
uint64 signer_prevout_amount = 4;
// The public key of the signer UTXO consumed by this transaction.
bytes signer_prevout_script_pubkey = 5;
// The total **output** amount of this transaction.
uint64 amount = 6;
// The fee paid for this transaction.
uint64 fee = 7;
// The virtual size of this transaction (in bytes).
uint32 vsize = 8;
// The Bitcoin block hash at which this transaction was created.
bitcoin.BitcoinBlockHash created_at_block_hash = 9;
// The market fee rate at the time of this transaction.
double market_fee_rate = 10;
// List of deposits which were swept-in by this transaction.
repeated SweptDeposit swept_deposits = 11;
// List of withdrawals which were swept-out by this transaction.
repeated SweptWithdrawal swept_withdrawals = 12;
}

// A wsts message.
message WstsMessage {
// The transaction ID this message relates to, will be a dummy ID for DKG messages
bitcoin.BitcoinTxid txid = 1;
// The wsts message
oneof inner {
// Tell signers to begin DKG by sending DKG public shares
crypto.wsts.DkgBegin dkg_begin = 2;
// Send DKG public shares
crypto.wsts.SignerDkgPublicShares signer_dkg_public_shares = 3;
// Tell signers to send DKG private shares
crypto.wsts.DkgPrivateBegin dkg_private_begin = 4;
// Send DKG private shares
crypto.wsts.DkgPrivateShares dkg_private_shares = 5;
// Tell signers to compute shares and send DKG end
crypto.wsts.DkgEndBegin dkg_end_begin = 6;
// Tell coordinator that DKG is complete
crypto.wsts.DkgEnd dkg_end = 7;
// Tell signers to send signing nonces
crypto.wsts.NonceRequest nonce_request = 8;
// Tell coordinator signing nonces
crypto.wsts.NonceResponse nonce_response = 9;
// Tell signers to construct signature shares
crypto.wsts.SignatureShareRequest signature_share_request = 10;
// Tell coordinator signature shares
crypto.wsts.SignatureShareResponse signature_share_response = 11;
}
}

// Wraps an inner type with a public key and a signature,
// allowing easy verification of the integrity of the inner data.
message Signed {
// The public key of the signer.
crypto.PublicKey signer_pub_key = 1;
// A signature over the hash of the inner structure.
bytes signature = 2;
// The signed structure.
oneof inner {
SignerMessage signer_message = 3;
}
}
27 changes: 24 additions & 3 deletions protobufs/stacks/signer/v1/requests.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ message StacksTransactionSignRequest {
// and a few other things.
crypto.Uint256 digest = 4;
// The transaction ID of the associated contract call transaction.
crypto.Uint256 txid = 5;
// The contract call transaction to sign.
oneof contract_call {
StacksTxid txid = 5;
// The contract transaction to sign.
oneof contract_tx {
// The `complete-deposit` contract call
CompleteDeposit complete_deposit = 6;
// The `accept-withdrawal-request` contract call
Expand All @@ -39,9 +39,30 @@ message StacksTransactionSignRequest {
RejectWithdrawal reject_withdrawal = 8;
// The `rotate-keys-wrapper` contract call
RotateKeys rotate_keys = 9;
// Ssmart contract deployment
SmartContract smart_contract = 10;
}
}

enum SmartContract {
SMART_CONTRACT_UNSPECIFIED = 0;
// The sbtc-registry contract. This contract needs to be deployed
// before any other contract.
SMART_CONTRACT_SBTC_REGISTRY = 1;
// The sbtc-token contract. This contract needs to be deployed right
// after the sbtc-registry contract.
SMART_CONTRACT_SBTC_TOKEN = 2;
// The sbtc-deposit contract. Can be deployed after the sbtc-token
// contract.
SMART_CONTRACT_SBTC_DEPOSIT = 3;
// The sbtc-withdrawal contract. Can be deployed after the sbtc-token
// contract.
SMART_CONTRACT_SBTC_WITHDRAWAL = 4;
// The sbtc-bootstrap-signers contract. Can be deployed after the
// sbtc-token contract.
SMART_CONTRACT_SBTC_BOOTSTRAP = 5;
}

// For making a `complete-deposit` contract call in the sbtc-deposit
// smart contract.
message CompleteDeposit {
Expand Down
1 change: 1 addition & 0 deletions signer/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub fn compile_protos() {
"protobufs/stacks/common.proto",
"protobufs/stacks/signer/v1/decisions.proto",
"protobufs/stacks/signer/v1/requests.proto",
"protobufs/stacks/signer/v1/messages.proto",
]
.map(|path| workingdir.join(path));

Expand Down
55 changes: 43 additions & 12 deletions signer/src/proto/generated/crypto.wsts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,43 @@ pub struct DkgEnd {
#[prost(message, optional, tag = "3")]
pub status: ::core::option::Option<DkgStatus>,
}
/// Signature type
/// This maps to this type <<https://github.com/Trust-Machines/wsts/blob/ebd7d7775ad5e44cdbf4f5c1fb468bdf6c467265/src/net.rs#L373-L382>>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SignatureType {
#[prost(oneof = "signature_type::SignatureType", tags = "1, 2, 3")]
pub signature_type: ::core::option::Option<signature_type::SignatureType>,
}
/// Nested message and enum types in `SignatureType`.
pub mod signature_type {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum SignatureType {
/// FROST signature
#[prost(message, tag = "1")]
Frost(super::FrostSignatureType),
/// BIP-340 Schnorr proof
#[prost(message, tag = "2")]
Schnorr(super::SchnorrSignatureType),
/// BIP-341 Taproot style schnorr proof with a merkle root
#[prost(message, tag = "3")]
Taproot(super::TaprootSignatureType),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FrostSignatureType {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SchnorrSignatureType {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TaprootSignatureType {
/// Taproot merkle root. This field is optional
#[prost(message, optional, tag = "1")]
pub merkle_root: ::core::option::Option<MerkleRoot>,
}
/// Nonce request message from coordinator to signers
/// This maps to this type <<https://github.com/Trust-Machines/wsts/blob/2d6cb87218bb8dd9ed0519356afe57a0b9a697cb/src/net.rs#L265-L280>>
#[allow(clippy::derive_partial_eq_without_eq)]
Expand All @@ -226,12 +263,9 @@ pub struct NonceRequest {
/// The message to sign
#[prost(bytes = "vec", tag = "4")]
pub message: ::prost::alloc::vec::Vec<u8>,
/// Whether to make a taproot signature
#[prost(bool, tag = "5")]
pub is_taproot: bool,
/// Taproot merkle root. This field is optional
#[prost(message, optional, tag = "6")]
pub merkle_root: ::core::option::Option<MerkleRoot>,
/// What type of signature to create
#[prost(message, optional, tag = "5")]
pub signature_type: ::core::option::Option<SignatureType>,
}
/// Nonce response message from signers to coordinator
/// This maps to this type <<https://github.com/Trust-Machines/wsts/blob/2d6cb87218bb8dd9ed0519356afe57a0b9a697cb/src/net.rs#L309-L326>>
Expand Down Expand Up @@ -280,12 +314,9 @@ pub struct SignatureShareRequest {
/// Bytes to sign.
#[prost(bytes = "vec", tag = "5")]
pub message: ::prost::alloc::vec::Vec<u8>,
/// Whether to make a taproot signature
#[prost(bool, tag = "6")]
pub is_taproot: bool,
/// Taproot merkle root. This field is optional
#[prost(message, optional, tag = "7")]
pub merkle_root: ::core::option::Option<MerkleRoot>,
/// What type of signature to create
#[prost(message, optional, tag = "6")]
pub signature_type: ::core::option::Option<SignatureType>,
}
/// Signature share response message from signers to coordinator
/// This maps to this type <<https://github.com/Trust-Machines/wsts/blob/2d6cb87218bb8dd9ed0519356afe57a0b9a697cb/src/net.rs#L422-L435>>
Expand Down
Loading
Loading