Skip to content

Commit 1efd120

Browse files
committed
Merge branch 'proto'
2 parents 77c967c + 05b3cb5 commit 1efd120

File tree

9 files changed

+254
-15
lines changed

9 files changed

+254
-15
lines changed

.github/workflows/rust.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,17 @@ jobs:
8080
make wasm
8181
make build-sandbox
8282
83-
Check-Protobufs:
84-
name: Check that the generated protobuf file is up to date
85-
runs-on: ubuntu-latest
86-
steps:
87-
- uses: actions/checkout@v3
88-
- uses: dtolnay/rust-toolchain@stable
89-
- run: |
90-
sudo apt-get update
91-
sudo apt-get install -y protobuf-compiler
92-
cargo install rust-script
93-
make build-protos
94-
git diff --quiet
83+
# Temporarily disabled; re-enable when we find a way to use the same protobuf compiler version
84+
# in the developer docs and here, otherwise this check will often fail.
85+
# Check-Protobufs:
86+
# name: Check that the generated protobuf file is up to date
87+
# runs-on: ubuntu-latest
88+
# steps:
89+
# - uses: actions/checkout@v3
90+
# - uses: dtolnay/rust-toolchain@stable
91+
# - run: |
92+
# sudo apt-get update
93+
# sudo apt-get install -y protobuf-compiler
94+
# cargo install rust-script
95+
# make build-protos
96+
# git diff --quiet

messages/btc.proto

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ enum BTCCoin {
2424
TBTC = 1;
2525
LTC = 2;
2626
TLTC = 3;
27+
// Regtest
28+
RBTC = 4;
2729
};
2830

2931

@@ -112,6 +114,7 @@ message BTCSignInitRequest {
112114
SAT = 1;
113115
}
114116
FormatUnit format_unit = 8;
117+
bool contains_silent_payment_outputs = 9;
115118
}
116119

117120
message BTCSignNextResponse {
@@ -124,6 +127,7 @@ message BTCSignNextResponse {
124127
PREVTX_INPUT = 4;
125128
PREVTX_OUTPUT = 5;
126129
HOST_NONCE = 6;
130+
PAYMENT_REQUEST = 7;
127131
}
128132
Type type = 1;
129133
// index of the current input or output
@@ -134,6 +138,9 @@ message BTCSignNextResponse {
134138
// Previous tx's input/output index in case of PREV_INPUT or PREV_OUTPUT, for the input at `index`.
135139
uint32 prev_index = 5;
136140
AntiKleptoSignerCommitment anti_klepto_signer_commitment = 6;
141+
// Generated output. The host *must* verify its correctness using `silent_payment_dleq_proof`.
142+
bytes generated_output_pkscript = 7;
143+
bytes silent_payment_dleq_proof = 8;
137144
}
138145

139146
message BTCSignInputRequest {
@@ -157,6 +164,10 @@ enum BTCOutputType {
157164
}
158165

159166
message BTCSignOutputRequest {
167+
// https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki
168+
message SilentPayment {
169+
string address = 1;
170+
}
160171
bool ours = 1;
161172
BTCOutputType type = 2; // if ours is false
162173
// 20 bytes for p2pkh, p2sh, pw2wpkh. 32 bytes for p2wsh.
@@ -165,6 +176,10 @@ message BTCSignOutputRequest {
165176
repeated uint32 keypath = 5; // if ours is true
166177
// If ours is true. References a script config from BTCSignInitRequest
167178
uint32 script_config_index = 6;
179+
optional uint32 payment_request_index = 7;
180+
// If provided, `type` and `payload` is ignored. The generated output pkScript is returned in
181+
// BTCSignNextResponse. `contains_silent_payment_outputs` in the init request must be true.
182+
SilentPayment silent_payment = 8;
168183
}
169184

170185
message BTCScriptConfigRegistration {
@@ -217,6 +232,23 @@ message BTCPrevTxOutputRequest {
217232
bytes pubkey_script = 2;
218233
}
219234

235+
message BTCPaymentRequestRequest {
236+
message Memo {
237+
message TextMemo {
238+
string note = 1;
239+
}
240+
oneof memo {
241+
TextMemo text_memo = 1;
242+
}
243+
}
244+
245+
string recipient_name = 1;
246+
repeated Memo memos = 2;
247+
bytes nonce = 3;
248+
uint64 total_amount = 4;
249+
bytes signature = 5;
250+
}
251+
220252
message BTCSignMessageRequest {
221253
BTCCoin coin = 1;
222254
BTCScriptConfigWithKeypath script_config = 2;
@@ -238,6 +270,7 @@ message BTCRequest {
238270
BTCPrevTxOutputRequest prevtx_output = 5;
239271
BTCSignMessageRequest sign_message = 6;
240272
AntiKleptoSignatureRequest antiklepto_signature = 7;
273+
BTCPaymentRequestRequest payment_request = 8;
241274
}
242275
}
243276

messages/eth.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ enum ETHCoin {
2727
RinkebyETH = 2;
2828
}
2929

30+
enum ETHAddressCase {
31+
ETH_ADDRESS_CASE_MIXED = 0;
32+
ETH_ADDRESS_CASE_UPPER = 1;
33+
ETH_ADDRESS_CASE_LOWER = 2;
34+
}
35+
3036
message ETHPubRequest {
3137
repeated uint32 keypath = 1;
3238
// Deprecated: use chain_id instead.
@@ -56,6 +62,7 @@ message ETHSignRequest {
5662
AntiKleptoHostNonceCommitment host_nonce_commitment = 9;
5763
// If non-zero, `coin` is ignored and `chain_id` is used to identify the network.
5864
uint64 chain_id = 10;
65+
ETHAddressCase address_case = 11;
5966
}
6067

6168
// TX payload for an EIP-1559 (type 2) transaction: https://eips.ethereum.org/EIPS/eip-1559
@@ -70,6 +77,7 @@ message ETHSignEIP1559Request {
7077
bytes value = 8; // smallest big endian serialization, max. 32 bytes
7178
bytes data = 9;
7279
AntiKleptoHostNonceCommitment host_nonce_commitment = 10;
80+
ETHAddressCase address_case = 11;
7381
}
7482

7583
message ETHSignMessageRequest {

messages/hww.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ message Request {
6666
BTCRequest btc = 25;
6767
ElectrumEncryptionKeyRequest electrum_encryption_key = 26;
6868
CardanoRequest cardano = 27;
69+
BIP85Request bip85 = 28;
6970
}
7071
}
7172

@@ -87,5 +88,6 @@ message Response {
8788
BTCResponse btc = 13;
8889
ElectrumEncryptionKeyResponse electrum_encryption_key = 14;
8990
CardanoResponse cardano = 15;
91+
BIP85Response bip85 = 16;
9092
}
9193
}

messages/keystore.proto

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,30 @@
44
syntax = "proto3";
55
package shiftcrypto.bitbox02;
66

7+
import "google/protobuf/empty.proto";
8+
79
message ElectrumEncryptionKeyRequest {
810
repeated uint32 keypath = 1;
911
}
1012

1113
message ElectrumEncryptionKeyResponse {
1214
string key = 1;
1315
}
16+
17+
message BIP85Request {
18+
message AppLn {
19+
uint32 account_number = 1;
20+
}
21+
22+
oneof app {
23+
google.protobuf.Empty bip39 = 1;
24+
AppLn ln = 2;
25+
}
26+
}
27+
28+
message BIP85Response {
29+
oneof app {
30+
google.protobuf.Empty bip39 = 1;
31+
bytes ln = 2;
32+
}
33+
}

src/btc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ impl<R: Runtime> PairedBitBox<R> {
696696
num_outputs: transaction.outputs.len() as _,
697697
locktime: transaction.locktime,
698698
format_unit: format_unit as _,
699+
contains_silent_payment_outputs: false,
699700
}))
700701
.await?;
701702

@@ -846,6 +847,7 @@ impl<R: Runtime> PairedBitBox<R> {
846847
pb::btc_sign_next_response::Type::HostNonce => {
847848
return Err(Error::UnexpectedResponse);
848849
}
850+
_ => return Err(Error::UnexpectedResponse),
849851
}
850852
}
851853
Ok(sigs)

src/eth.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ impl<R: Runtime> PairedBitBox<R> {
483483
commitment: crate::antiklepto::host_commit(&host_nonce).to_vec(),
484484
}),
485485
chain_id,
486+
address_case: pb::EthAddressCase::Mixed as _,
486487
});
487488
let response = self.query_proto_eth(request).await?;
488489
self.handle_antiklepto(&response, host_nonce).await
@@ -515,6 +516,7 @@ impl<R: Runtime> PairedBitBox<R> {
515516
host_nonce_commitment: Some(pb::AntiKleptoHostNonceCommitment {
516517
commitment: crate::antiklepto::host_commit(&host_nonce).to_vec(),
517518
}),
519+
address_case: pb::EthAddressCase::Mixed as _,
518520
});
519521
let response = self.query_proto_eth(request).await?;
520522
self.handle_antiklepto(&response, host_nonce).await

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ mod u2fframing;
2424
mod util;
2525

2626
/// BitBox protobuf messages.
27+
#[allow(clippy::all)]
2728
pub mod pb {
2829
include!("./shiftcrypto.bitbox02.rs");
2930
}

0 commit comments

Comments
 (0)