From 08845763542f78f068031e66f36b5167d87b6782 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Tue, 20 Jun 2023 02:35:14 +0200 Subject: [PATCH] miniscript: add proto messages We will support miniscript as part of output descriptors. Descriptors are an expression language to specify Bitcoin outputs. For example, `wsh(multi(2,,,))` is a 2-of-3 multisig wrapped in a P2WSH (pay-to-witness-script-hash) output. Descriptors specification: https://github.com/bitcoin/bitcoin/blob/8f402710371a40c5777dc3f9c4ba6ca8505a2f90/doc/descriptors.md In fragments wrapping SCRIPT expressions, SCRIPT can also be a miniscript expression, for example: `wsh(or_b(pk(),s:pk()))`. With hardware signers, we want to use xpubs with derivations instead of raw pubkeys, and also have a shorter representation than inlining the xpubs for readability. That is why we will follow the 'Wallet Policies for Descriptor Wallets' proposal specied here: https://github.com/bigspider/bips/blob/bip-wallet-policies/bip-wallet-policies.mediawiki (https://github.com/bitcoin/bips/pull/1389). The above example then become `wsh(or_b(pk(@0/**),s:pk(@1/**)))`. The `@NUM` references a key provided in the keys list. For the policy with the keys, one can then derive pkScripts for receive and change addresses and use these to create addresses. --- messages/btc.proto | 8 ++ messages/common.proto | 6 + .../communication/generated/btc_pb2.py | 114 +++++++++--------- .../communication/generated/btc_pb2.pyi | 27 ++++- .../communication/generated/common_pb2.py | 4 +- .../communication/generated/common_pb2.pyi | 20 +++ .../bitbox02-rust/src/shiftcrypto.bitbox02.rs | 24 +++- 7 files changed, 142 insertions(+), 61 deletions(-) diff --git a/messages/btc.proto b/messages/btc.proto index e3370ebab6..f0f5d2a65a 100644 --- a/messages/btc.proto +++ b/messages/btc.proto @@ -52,9 +52,17 @@ message BTCScriptConfig { ScriptType script_type = 4; } + // A policy as specified by 'Wallet policies': + // https://github.com/bitcoin/bips/pull/1389 + message Policy { + string policy = 1; + repeated KeyOriginInfo keys = 2; + } + oneof config { SimpleType simple_type = 1; Multisig multisig = 2; + Policy policy = 3; } } diff --git a/messages/common.proto b/messages/common.proto index f16755de5b..0b80c6f85f 100644 --- a/messages/common.proto +++ b/messages/common.proto @@ -40,3 +40,9 @@ message XPub { message Keypath { repeated uint32 keypath = 1; } + +message KeyOriginInfo { + bytes root_fingerprint = 1; + repeated uint32 keypath = 2; + XPub xpub = 3; +} diff --git a/py/bitbox02/bitbox02/communication/generated/btc_pb2.py b/py/bitbox02/bitbox02/communication/generated/btc_pb2.py index 73a1e179e1..f94d03b35d 100644 --- a/py/bitbox02/bitbox02/communication/generated/btc_pb2.py +++ b/py/bitbox02/bitbox02/communication/generated/btc_pb2.py @@ -15,67 +15,69 @@ from . import antiklepto_pb2 as antiklepto__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\tbtc.proto\x12\x14shiftcrypto.bitbox02\x1a\x0c\x63ommon.proto\x1a\x10\x61ntiklepto.proto\"\xb9\x03\n\x0f\x42TCScriptConfig\x12G\n\x0bsimple_type\x18\x01 \x01(\x0e\x32\x30.shiftcrypto.bitbox02.BTCScriptConfig.SimpleTypeH\x00\x12\x42\n\x08multisig\x18\x02 \x01(\x0b\x32..shiftcrypto.bitbox02.BTCScriptConfig.MultisigH\x00\x1a\xd9\x01\n\x08Multisig\x12\x11\n\tthreshold\x18\x01 \x01(\r\x12)\n\x05xpubs\x18\x02 \x03(\x0b\x32\x1a.shiftcrypto.bitbox02.XPub\x12\x16\n\x0eour_xpub_index\x18\x03 \x01(\r\x12N\n\x0bscript_type\x18\x04 \x01(\x0e\x32\x39.shiftcrypto.bitbox02.BTCScriptConfig.Multisig.ScriptType\"\'\n\nScriptType\x12\t\n\x05P2WSH\x10\x00\x12\x0e\n\nP2WSH_P2SH\x10\x01\"3\n\nSimpleType\x12\x0f\n\x0bP2WPKH_P2SH\x10\x00\x12\n\n\x06P2WPKH\x10\x01\x12\x08\n\x04P2TR\x10\x02\x42\x08\n\x06\x63onfig\"\xfc\x02\n\rBTCPubRequest\x12+\n\x04\x63oin\x18\x01 \x01(\x0e\x32\x1d.shiftcrypto.bitbox02.BTCCoin\x12\x0f\n\x07keypath\x18\x02 \x03(\r\x12\x41\n\txpub_type\x18\x03 \x01(\x0e\x32,.shiftcrypto.bitbox02.BTCPubRequest.XPubTypeH\x00\x12>\n\rscript_config\x18\x04 \x01(\x0b\x32%.shiftcrypto.bitbox02.BTCScriptConfigH\x00\x12\x0f\n\x07\x64isplay\x18\x05 \x01(\x08\"\x8e\x01\n\x08XPubType\x12\x08\n\x04TPUB\x10\x00\x12\x08\n\x04XPUB\x10\x01\x12\x08\n\x04YPUB\x10\x02\x12\x08\n\x04ZPUB\x10\x03\x12\x08\n\x04VPUB\x10\x04\x12\x08\n\x04UPUB\x10\x05\x12\x10\n\x0c\x43\x41PITAL_VPUB\x10\x06\x12\x10\n\x0c\x43\x41PITAL_ZPUB\x10\x07\x12\x10\n\x0c\x43\x41PITAL_UPUB\x10\x08\x12\x10\n\x0c\x43\x41PITAL_YPUB\x10\tB\x08\n\x06output\"k\n\x1a\x42TCScriptConfigWithKeypath\x12<\n\rscript_config\x18\x02 \x01(\x0b\x32%.shiftcrypto.bitbox02.BTCScriptConfig\x12\x0f\n\x07keypath\x18\x03 \x03(\r\"\xc5\x02\n\x12\x42TCSignInitRequest\x12+\n\x04\x63oin\x18\x01 \x01(\x0e\x32\x1d.shiftcrypto.bitbox02.BTCCoin\x12H\n\x0escript_configs\x18\x02 \x03(\x0b\x32\x30.shiftcrypto.bitbox02.BTCScriptConfigWithKeypath\x12\x0f\n\x07version\x18\x04 \x01(\r\x12\x12\n\nnum_inputs\x18\x05 \x01(\r\x12\x13\n\x0bnum_outputs\x18\x06 \x01(\r\x12\x10\n\x08locktime\x18\x07 \x01(\r\x12H\n\x0b\x66ormat_unit\x18\x08 \x01(\x0e\x32\x33.shiftcrypto.bitbox02.BTCSignInitRequest.FormatUnit\"\"\n\nFormatUnit\x12\x0b\n\x07\x44\x45\x46\x41ULT\x10\x00\x12\x07\n\x03SAT\x10\x01\"\xe8\x02\n\x13\x42TCSignNextResponse\x12<\n\x04type\x18\x01 \x01(\x0e\x32..shiftcrypto.bitbox02.BTCSignNextResponse.Type\x12\r\n\x05index\x18\x02 \x01(\r\x12\x15\n\rhas_signature\x18\x03 \x01(\x08\x12\x11\n\tsignature\x18\x04 \x01(\x0c\x12\x12\n\nprev_index\x18\x05 \x01(\r\x12W\n\x1d\x61nti_klepto_signer_commitment\x18\x06 \x01(\x0b\x32\x30.shiftcrypto.bitbox02.AntiKleptoSignerCommitment\"m\n\x04Type\x12\t\n\x05INPUT\x10\x00\x12\n\n\x06OUTPUT\x10\x01\x12\x08\n\x04\x44ONE\x10\x02\x12\x0f\n\x0bPREVTX_INIT\x10\x03\x12\x10\n\x0cPREVTX_INPUT\x10\x04\x12\x11\n\rPREVTX_OUTPUT\x10\x05\x12\x0e\n\nHOST_NONCE\x10\x06\"\xea\x01\n\x13\x42TCSignInputRequest\x12\x13\n\x0bprevOutHash\x18\x01 \x01(\x0c\x12\x14\n\x0cprevOutIndex\x18\x02 \x01(\r\x12\x14\n\x0cprevOutValue\x18\x03 \x01(\x04\x12\x10\n\x08sequence\x18\x04 \x01(\r\x12\x0f\n\x07keypath\x18\x06 \x03(\r\x12\x1b\n\x13script_config_index\x18\x07 \x01(\r\x12R\n\x15host_nonce_commitment\x18\x08 \x01(\x0b\x32\x33.shiftcrypto.bitbox02.AntiKleptoHostNonceCommitment\"\xa5\x01\n\x14\x42TCSignOutputRequest\x12\x0c\n\x04ours\x18\x01 \x01(\x08\x12\x31\n\x04type\x18\x02 \x01(\x0e\x32#.shiftcrypto.bitbox02.BTCOutputType\x12\r\n\x05value\x18\x03 \x01(\x04\x12\x0f\n\x07payload\x18\x04 \x01(\x0c\x12\x0f\n\x07keypath\x18\x05 \x03(\r\x12\x1b\n\x13script_config_index\x18\x06 \x01(\r\"\x99\x01\n\x1b\x42TCScriptConfigRegistration\x12+\n\x04\x63oin\x18\x01 \x01(\x0e\x32\x1d.shiftcrypto.bitbox02.BTCCoin\x12<\n\rscript_config\x18\x02 \x01(\x0b\x32%.shiftcrypto.bitbox02.BTCScriptConfig\x12\x0f\n\x07keypath\x18\x03 \x03(\r\"\x0c\n\nBTCSuccess\"m\n\"BTCIsScriptConfigRegisteredRequest\x12G\n\x0cregistration\x18\x01 \x01(\x0b\x32\x31.shiftcrypto.bitbox02.BTCScriptConfigRegistration\"<\n#BTCIsScriptConfigRegisteredResponse\x12\x15\n\ris_registered\x18\x01 \x01(\x08\"\xfc\x01\n\x1e\x42TCRegisterScriptConfigRequest\x12G\n\x0cregistration\x18\x01 \x01(\x0b\x32\x31.shiftcrypto.bitbox02.BTCScriptConfigRegistration\x12\x0c\n\x04name\x18\x02 \x01(\t\x12P\n\txpub_type\x18\x03 \x01(\x0e\x32=.shiftcrypto.bitbox02.BTCRegisterScriptConfigRequest.XPubType\"1\n\x08XPubType\x12\x11\n\rAUTO_ELECTRUM\x10\x00\x12\x12\n\x0e\x41UTO_XPUB_TPUB\x10\x01\"b\n\x14\x42TCPrevTxInitRequest\x12\x0f\n\x07version\x18\x01 \x01(\r\x12\x12\n\nnum_inputs\x18\x02 \x01(\r\x12\x13\n\x0bnum_outputs\x18\x03 \x01(\r\x12\x10\n\x08locktime\x18\x04 \x01(\r\"r\n\x15\x42TCPrevTxInputRequest\x12\x15\n\rprev_out_hash\x18\x01 \x01(\x0c\x12\x16\n\x0eprev_out_index\x18\x02 \x01(\r\x12\x18\n\x10signature_script\x18\x03 \x01(\x0c\x12\x10\n\x08sequence\x18\x04 \x01(\r\">\n\x16\x42TCPrevTxOutputRequest\x12\r\n\x05value\x18\x01 \x01(\x04\x12\x15\n\rpubkey_script\x18\x02 \x01(\x0c\"\xee\x01\n\x15\x42TCSignMessageRequest\x12+\n\x04\x63oin\x18\x01 \x01(\x0e\x32\x1d.shiftcrypto.bitbox02.BTCCoin\x12G\n\rscript_config\x18\x02 \x01(\x0b\x32\x30.shiftcrypto.bitbox02.BTCScriptConfigWithKeypath\x12\x0b\n\x03msg\x18\x03 \x01(\x0c\x12R\n\x15host_nonce_commitment\x18\x04 \x01(\x0b\x32\x33.shiftcrypto.bitbox02.AntiKleptoHostNonceCommitment\"+\n\x16\x42TCSignMessageResponse\x12\x11\n\tsignature\x18\x01 \x01(\x0c\"\xb6\x04\n\nBTCRequest\x12_\n\x1bis_script_config_registered\x18\x01 \x01(\x0b\x32\x38.shiftcrypto.bitbox02.BTCIsScriptConfigRegisteredRequestH\x00\x12V\n\x16register_script_config\x18\x02 \x01(\x0b\x32\x34.shiftcrypto.bitbox02.BTCRegisterScriptConfigRequestH\x00\x12\x41\n\x0bprevtx_init\x18\x03 \x01(\x0b\x32*.shiftcrypto.bitbox02.BTCPrevTxInitRequestH\x00\x12\x43\n\x0cprevtx_input\x18\x04 \x01(\x0b\x32+.shiftcrypto.bitbox02.BTCPrevTxInputRequestH\x00\x12\x45\n\rprevtx_output\x18\x05 \x01(\x0b\x32,.shiftcrypto.bitbox02.BTCPrevTxOutputRequestH\x00\x12\x43\n\x0csign_message\x18\x06 \x01(\x0b\x32+.shiftcrypto.bitbox02.BTCSignMessageRequestH\x00\x12P\n\x14\x61ntiklepto_signature\x18\x07 \x01(\x0b\x32\x30.shiftcrypto.bitbox02.AntiKleptoSignatureRequestH\x00\x42\t\n\x07request\"\x90\x03\n\x0b\x42TCResponse\x12\x33\n\x07success\x18\x01 \x01(\x0b\x32 .shiftcrypto.bitbox02.BTCSuccessH\x00\x12`\n\x1bis_script_config_registered\x18\x02 \x01(\x0b\x32\x39.shiftcrypto.bitbox02.BTCIsScriptConfigRegisteredResponseH\x00\x12>\n\tsign_next\x18\x03 \x01(\x0b\x32).shiftcrypto.bitbox02.BTCSignNextResponseH\x00\x12\x44\n\x0csign_message\x18\x04 \x01(\x0b\x32,.shiftcrypto.bitbox02.BTCSignMessageResponseH\x00\x12X\n\x1c\x61ntiklepto_signer_commitment\x18\x05 \x01(\x0b\x32\x30.shiftcrypto.bitbox02.AntiKleptoSignerCommitmentH\x00\x42\n\n\x08response*/\n\x07\x42TCCoin\x12\x07\n\x03\x42TC\x10\x00\x12\x08\n\x04TBTC\x10\x01\x12\x07\n\x03LTC\x10\x02\x12\x08\n\x04TLTC\x10\x03*R\n\rBTCOutputType\x12\x0b\n\x07UNKNOWN\x10\x00\x12\t\n\x05P2PKH\x10\x01\x12\x08\n\x04P2SH\x10\x02\x12\n\n\x06P2WPKH\x10\x03\x12\t\n\x05P2WSH\x10\x04\x12\x08\n\x04P2TR\x10\x05\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\tbtc.proto\x12\x14shiftcrypto.bitbox02\x1a\x0c\x63ommon.proto\x1a\x10\x61ntiklepto.proto\"\xc6\x04\n\x0f\x42TCScriptConfig\x12G\n\x0bsimple_type\x18\x01 \x01(\x0e\x32\x30.shiftcrypto.bitbox02.BTCScriptConfig.SimpleTypeH\x00\x12\x42\n\x08multisig\x18\x02 \x01(\x0b\x32..shiftcrypto.bitbox02.BTCScriptConfig.MultisigH\x00\x12>\n\x06policy\x18\x03 \x01(\x0b\x32,.shiftcrypto.bitbox02.BTCScriptConfig.PolicyH\x00\x1a\xd9\x01\n\x08Multisig\x12\x11\n\tthreshold\x18\x01 \x01(\r\x12)\n\x05xpubs\x18\x02 \x03(\x0b\x32\x1a.shiftcrypto.bitbox02.XPub\x12\x16\n\x0eour_xpub_index\x18\x03 \x01(\r\x12N\n\x0bscript_type\x18\x04 \x01(\x0e\x32\x39.shiftcrypto.bitbox02.BTCScriptConfig.Multisig.ScriptType\"\'\n\nScriptType\x12\t\n\x05P2WSH\x10\x00\x12\x0e\n\nP2WSH_P2SH\x10\x01\x1aK\n\x06Policy\x12\x0e\n\x06policy\x18\x01 \x01(\t\x12\x31\n\x04keys\x18\x02 \x03(\x0b\x32#.shiftcrypto.bitbox02.KeyOriginInfo\"3\n\nSimpleType\x12\x0f\n\x0bP2WPKH_P2SH\x10\x00\x12\n\n\x06P2WPKH\x10\x01\x12\x08\n\x04P2TR\x10\x02\x42\x08\n\x06\x63onfig\"\xfc\x02\n\rBTCPubRequest\x12+\n\x04\x63oin\x18\x01 \x01(\x0e\x32\x1d.shiftcrypto.bitbox02.BTCCoin\x12\x0f\n\x07keypath\x18\x02 \x03(\r\x12\x41\n\txpub_type\x18\x03 \x01(\x0e\x32,.shiftcrypto.bitbox02.BTCPubRequest.XPubTypeH\x00\x12>\n\rscript_config\x18\x04 \x01(\x0b\x32%.shiftcrypto.bitbox02.BTCScriptConfigH\x00\x12\x0f\n\x07\x64isplay\x18\x05 \x01(\x08\"\x8e\x01\n\x08XPubType\x12\x08\n\x04TPUB\x10\x00\x12\x08\n\x04XPUB\x10\x01\x12\x08\n\x04YPUB\x10\x02\x12\x08\n\x04ZPUB\x10\x03\x12\x08\n\x04VPUB\x10\x04\x12\x08\n\x04UPUB\x10\x05\x12\x10\n\x0c\x43\x41PITAL_VPUB\x10\x06\x12\x10\n\x0c\x43\x41PITAL_ZPUB\x10\x07\x12\x10\n\x0c\x43\x41PITAL_UPUB\x10\x08\x12\x10\n\x0c\x43\x41PITAL_YPUB\x10\tB\x08\n\x06output\"k\n\x1a\x42TCScriptConfigWithKeypath\x12<\n\rscript_config\x18\x02 \x01(\x0b\x32%.shiftcrypto.bitbox02.BTCScriptConfig\x12\x0f\n\x07keypath\x18\x03 \x03(\r\"\xc5\x02\n\x12\x42TCSignInitRequest\x12+\n\x04\x63oin\x18\x01 \x01(\x0e\x32\x1d.shiftcrypto.bitbox02.BTCCoin\x12H\n\x0escript_configs\x18\x02 \x03(\x0b\x32\x30.shiftcrypto.bitbox02.BTCScriptConfigWithKeypath\x12\x0f\n\x07version\x18\x04 \x01(\r\x12\x12\n\nnum_inputs\x18\x05 \x01(\r\x12\x13\n\x0bnum_outputs\x18\x06 \x01(\r\x12\x10\n\x08locktime\x18\x07 \x01(\r\x12H\n\x0b\x66ormat_unit\x18\x08 \x01(\x0e\x32\x33.shiftcrypto.bitbox02.BTCSignInitRequest.FormatUnit\"\"\n\nFormatUnit\x12\x0b\n\x07\x44\x45\x46\x41ULT\x10\x00\x12\x07\n\x03SAT\x10\x01\"\xe8\x02\n\x13\x42TCSignNextResponse\x12<\n\x04type\x18\x01 \x01(\x0e\x32..shiftcrypto.bitbox02.BTCSignNextResponse.Type\x12\r\n\x05index\x18\x02 \x01(\r\x12\x15\n\rhas_signature\x18\x03 \x01(\x08\x12\x11\n\tsignature\x18\x04 \x01(\x0c\x12\x12\n\nprev_index\x18\x05 \x01(\r\x12W\n\x1d\x61nti_klepto_signer_commitment\x18\x06 \x01(\x0b\x32\x30.shiftcrypto.bitbox02.AntiKleptoSignerCommitment\"m\n\x04Type\x12\t\n\x05INPUT\x10\x00\x12\n\n\x06OUTPUT\x10\x01\x12\x08\n\x04\x44ONE\x10\x02\x12\x0f\n\x0bPREVTX_INIT\x10\x03\x12\x10\n\x0cPREVTX_INPUT\x10\x04\x12\x11\n\rPREVTX_OUTPUT\x10\x05\x12\x0e\n\nHOST_NONCE\x10\x06\"\xea\x01\n\x13\x42TCSignInputRequest\x12\x13\n\x0bprevOutHash\x18\x01 \x01(\x0c\x12\x14\n\x0cprevOutIndex\x18\x02 \x01(\r\x12\x14\n\x0cprevOutValue\x18\x03 \x01(\x04\x12\x10\n\x08sequence\x18\x04 \x01(\r\x12\x0f\n\x07keypath\x18\x06 \x03(\r\x12\x1b\n\x13script_config_index\x18\x07 \x01(\r\x12R\n\x15host_nonce_commitment\x18\x08 \x01(\x0b\x32\x33.shiftcrypto.bitbox02.AntiKleptoHostNonceCommitment\"\xa5\x01\n\x14\x42TCSignOutputRequest\x12\x0c\n\x04ours\x18\x01 \x01(\x08\x12\x31\n\x04type\x18\x02 \x01(\x0e\x32#.shiftcrypto.bitbox02.BTCOutputType\x12\r\n\x05value\x18\x03 \x01(\x04\x12\x0f\n\x07payload\x18\x04 \x01(\x0c\x12\x0f\n\x07keypath\x18\x05 \x03(\r\x12\x1b\n\x13script_config_index\x18\x06 \x01(\r\"\x99\x01\n\x1b\x42TCScriptConfigRegistration\x12+\n\x04\x63oin\x18\x01 \x01(\x0e\x32\x1d.shiftcrypto.bitbox02.BTCCoin\x12<\n\rscript_config\x18\x02 \x01(\x0b\x32%.shiftcrypto.bitbox02.BTCScriptConfig\x12\x0f\n\x07keypath\x18\x03 \x03(\r\"\x0c\n\nBTCSuccess\"m\n\"BTCIsScriptConfigRegisteredRequest\x12G\n\x0cregistration\x18\x01 \x01(\x0b\x32\x31.shiftcrypto.bitbox02.BTCScriptConfigRegistration\"<\n#BTCIsScriptConfigRegisteredResponse\x12\x15\n\ris_registered\x18\x01 \x01(\x08\"\xfc\x01\n\x1e\x42TCRegisterScriptConfigRequest\x12G\n\x0cregistration\x18\x01 \x01(\x0b\x32\x31.shiftcrypto.bitbox02.BTCScriptConfigRegistration\x12\x0c\n\x04name\x18\x02 \x01(\t\x12P\n\txpub_type\x18\x03 \x01(\x0e\x32=.shiftcrypto.bitbox02.BTCRegisterScriptConfigRequest.XPubType\"1\n\x08XPubType\x12\x11\n\rAUTO_ELECTRUM\x10\x00\x12\x12\n\x0e\x41UTO_XPUB_TPUB\x10\x01\"b\n\x14\x42TCPrevTxInitRequest\x12\x0f\n\x07version\x18\x01 \x01(\r\x12\x12\n\nnum_inputs\x18\x02 \x01(\r\x12\x13\n\x0bnum_outputs\x18\x03 \x01(\r\x12\x10\n\x08locktime\x18\x04 \x01(\r\"r\n\x15\x42TCPrevTxInputRequest\x12\x15\n\rprev_out_hash\x18\x01 \x01(\x0c\x12\x16\n\x0eprev_out_index\x18\x02 \x01(\r\x12\x18\n\x10signature_script\x18\x03 \x01(\x0c\x12\x10\n\x08sequence\x18\x04 \x01(\r\">\n\x16\x42TCPrevTxOutputRequest\x12\r\n\x05value\x18\x01 \x01(\x04\x12\x15\n\rpubkey_script\x18\x02 \x01(\x0c\"\xee\x01\n\x15\x42TCSignMessageRequest\x12+\n\x04\x63oin\x18\x01 \x01(\x0e\x32\x1d.shiftcrypto.bitbox02.BTCCoin\x12G\n\rscript_config\x18\x02 \x01(\x0b\x32\x30.shiftcrypto.bitbox02.BTCScriptConfigWithKeypath\x12\x0b\n\x03msg\x18\x03 \x01(\x0c\x12R\n\x15host_nonce_commitment\x18\x04 \x01(\x0b\x32\x33.shiftcrypto.bitbox02.AntiKleptoHostNonceCommitment\"+\n\x16\x42TCSignMessageResponse\x12\x11\n\tsignature\x18\x01 \x01(\x0c\"\xb6\x04\n\nBTCRequest\x12_\n\x1bis_script_config_registered\x18\x01 \x01(\x0b\x32\x38.shiftcrypto.bitbox02.BTCIsScriptConfigRegisteredRequestH\x00\x12V\n\x16register_script_config\x18\x02 \x01(\x0b\x32\x34.shiftcrypto.bitbox02.BTCRegisterScriptConfigRequestH\x00\x12\x41\n\x0bprevtx_init\x18\x03 \x01(\x0b\x32*.shiftcrypto.bitbox02.BTCPrevTxInitRequestH\x00\x12\x43\n\x0cprevtx_input\x18\x04 \x01(\x0b\x32+.shiftcrypto.bitbox02.BTCPrevTxInputRequestH\x00\x12\x45\n\rprevtx_output\x18\x05 \x01(\x0b\x32,.shiftcrypto.bitbox02.BTCPrevTxOutputRequestH\x00\x12\x43\n\x0csign_message\x18\x06 \x01(\x0b\x32+.shiftcrypto.bitbox02.BTCSignMessageRequestH\x00\x12P\n\x14\x61ntiklepto_signature\x18\x07 \x01(\x0b\x32\x30.shiftcrypto.bitbox02.AntiKleptoSignatureRequestH\x00\x42\t\n\x07request\"\x90\x03\n\x0b\x42TCResponse\x12\x33\n\x07success\x18\x01 \x01(\x0b\x32 .shiftcrypto.bitbox02.BTCSuccessH\x00\x12`\n\x1bis_script_config_registered\x18\x02 \x01(\x0b\x32\x39.shiftcrypto.bitbox02.BTCIsScriptConfigRegisteredResponseH\x00\x12>\n\tsign_next\x18\x03 \x01(\x0b\x32).shiftcrypto.bitbox02.BTCSignNextResponseH\x00\x12\x44\n\x0csign_message\x18\x04 \x01(\x0b\x32,.shiftcrypto.bitbox02.BTCSignMessageResponseH\x00\x12X\n\x1c\x61ntiklepto_signer_commitment\x18\x05 \x01(\x0b\x32\x30.shiftcrypto.bitbox02.AntiKleptoSignerCommitmentH\x00\x42\n\n\x08response*/\n\x07\x42TCCoin\x12\x07\n\x03\x42TC\x10\x00\x12\x08\n\x04TBTC\x10\x01\x12\x07\n\x03LTC\x10\x02\x12\x08\n\x04TLTC\x10\x03*R\n\rBTCOutputType\x12\x0b\n\x07UNKNOWN\x10\x00\x12\t\n\x05P2PKH\x10\x01\x12\x08\n\x04P2SH\x10\x02\x12\n\n\x06P2WPKH\x10\x03\x12\t\n\x05P2WSH\x10\x04\x12\x08\n\x04P2TR\x10\x05\x62\x06proto3') _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'btc_pb2', globals()) if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None - _BTCCOIN._serialized_start=4235 - _BTCCOIN._serialized_end=4282 - _BTCOUTPUTTYPE._serialized_start=4284 - _BTCOUTPUTTYPE._serialized_end=4366 + _BTCCOIN._serialized_start=4376 + _BTCCOIN._serialized_end=4423 + _BTCOUTPUTTYPE._serialized_start=4425 + _BTCOUTPUTTYPE._serialized_end=4507 _BTCSCRIPTCONFIG._serialized_start=68 - _BTCSCRIPTCONFIG._serialized_end=509 - _BTCSCRIPTCONFIG_MULTISIG._serialized_start=229 - _BTCSCRIPTCONFIG_MULTISIG._serialized_end=446 - _BTCSCRIPTCONFIG_MULTISIG_SCRIPTTYPE._serialized_start=407 - _BTCSCRIPTCONFIG_MULTISIG_SCRIPTTYPE._serialized_end=446 - _BTCSCRIPTCONFIG_SIMPLETYPE._serialized_start=448 - _BTCSCRIPTCONFIG_SIMPLETYPE._serialized_end=499 - _BTCPUBREQUEST._serialized_start=512 - _BTCPUBREQUEST._serialized_end=892 - _BTCPUBREQUEST_XPUBTYPE._serialized_start=740 - _BTCPUBREQUEST_XPUBTYPE._serialized_end=882 - _BTCSCRIPTCONFIGWITHKEYPATH._serialized_start=894 - _BTCSCRIPTCONFIGWITHKEYPATH._serialized_end=1001 - _BTCSIGNINITREQUEST._serialized_start=1004 - _BTCSIGNINITREQUEST._serialized_end=1329 - _BTCSIGNINITREQUEST_FORMATUNIT._serialized_start=1295 - _BTCSIGNINITREQUEST_FORMATUNIT._serialized_end=1329 - _BTCSIGNNEXTRESPONSE._serialized_start=1332 - _BTCSIGNNEXTRESPONSE._serialized_end=1692 - _BTCSIGNNEXTRESPONSE_TYPE._serialized_start=1583 - _BTCSIGNNEXTRESPONSE_TYPE._serialized_end=1692 - _BTCSIGNINPUTREQUEST._serialized_start=1695 - _BTCSIGNINPUTREQUEST._serialized_end=1929 - _BTCSIGNOUTPUTREQUEST._serialized_start=1932 - _BTCSIGNOUTPUTREQUEST._serialized_end=2097 - _BTCSCRIPTCONFIGREGISTRATION._serialized_start=2100 - _BTCSCRIPTCONFIGREGISTRATION._serialized_end=2253 - _BTCSUCCESS._serialized_start=2255 - _BTCSUCCESS._serialized_end=2267 - _BTCISSCRIPTCONFIGREGISTEREDREQUEST._serialized_start=2269 - _BTCISSCRIPTCONFIGREGISTEREDREQUEST._serialized_end=2378 - _BTCISSCRIPTCONFIGREGISTEREDRESPONSE._serialized_start=2380 - _BTCISSCRIPTCONFIGREGISTEREDRESPONSE._serialized_end=2440 - _BTCREGISTERSCRIPTCONFIGREQUEST._serialized_start=2443 - _BTCREGISTERSCRIPTCONFIGREQUEST._serialized_end=2695 - _BTCREGISTERSCRIPTCONFIGREQUEST_XPUBTYPE._serialized_start=2646 - _BTCREGISTERSCRIPTCONFIGREQUEST_XPUBTYPE._serialized_end=2695 - _BTCPREVTXINITREQUEST._serialized_start=2697 - _BTCPREVTXINITREQUEST._serialized_end=2795 - _BTCPREVTXINPUTREQUEST._serialized_start=2797 - _BTCPREVTXINPUTREQUEST._serialized_end=2911 - _BTCPREVTXOUTPUTREQUEST._serialized_start=2913 - _BTCPREVTXOUTPUTREQUEST._serialized_end=2975 - _BTCSIGNMESSAGEREQUEST._serialized_start=2978 - _BTCSIGNMESSAGEREQUEST._serialized_end=3216 - _BTCSIGNMESSAGERESPONSE._serialized_start=3218 - _BTCSIGNMESSAGERESPONSE._serialized_end=3261 - _BTCREQUEST._serialized_start=3264 - _BTCREQUEST._serialized_end=3830 - _BTCRESPONSE._serialized_start=3833 - _BTCRESPONSE._serialized_end=4233 + _BTCSCRIPTCONFIG._serialized_end=650 + _BTCSCRIPTCONFIG_MULTISIG._serialized_start=293 + _BTCSCRIPTCONFIG_MULTISIG._serialized_end=510 + _BTCSCRIPTCONFIG_MULTISIG_SCRIPTTYPE._serialized_start=471 + _BTCSCRIPTCONFIG_MULTISIG_SCRIPTTYPE._serialized_end=510 + _BTCSCRIPTCONFIG_POLICY._serialized_start=512 + _BTCSCRIPTCONFIG_POLICY._serialized_end=587 + _BTCSCRIPTCONFIG_SIMPLETYPE._serialized_start=589 + _BTCSCRIPTCONFIG_SIMPLETYPE._serialized_end=640 + _BTCPUBREQUEST._serialized_start=653 + _BTCPUBREQUEST._serialized_end=1033 + _BTCPUBREQUEST_XPUBTYPE._serialized_start=881 + _BTCPUBREQUEST_XPUBTYPE._serialized_end=1023 + _BTCSCRIPTCONFIGWITHKEYPATH._serialized_start=1035 + _BTCSCRIPTCONFIGWITHKEYPATH._serialized_end=1142 + _BTCSIGNINITREQUEST._serialized_start=1145 + _BTCSIGNINITREQUEST._serialized_end=1470 + _BTCSIGNINITREQUEST_FORMATUNIT._serialized_start=1436 + _BTCSIGNINITREQUEST_FORMATUNIT._serialized_end=1470 + _BTCSIGNNEXTRESPONSE._serialized_start=1473 + _BTCSIGNNEXTRESPONSE._serialized_end=1833 + _BTCSIGNNEXTRESPONSE_TYPE._serialized_start=1724 + _BTCSIGNNEXTRESPONSE_TYPE._serialized_end=1833 + _BTCSIGNINPUTREQUEST._serialized_start=1836 + _BTCSIGNINPUTREQUEST._serialized_end=2070 + _BTCSIGNOUTPUTREQUEST._serialized_start=2073 + _BTCSIGNOUTPUTREQUEST._serialized_end=2238 + _BTCSCRIPTCONFIGREGISTRATION._serialized_start=2241 + _BTCSCRIPTCONFIGREGISTRATION._serialized_end=2394 + _BTCSUCCESS._serialized_start=2396 + _BTCSUCCESS._serialized_end=2408 + _BTCISSCRIPTCONFIGREGISTEREDREQUEST._serialized_start=2410 + _BTCISSCRIPTCONFIGREGISTEREDREQUEST._serialized_end=2519 + _BTCISSCRIPTCONFIGREGISTEREDRESPONSE._serialized_start=2521 + _BTCISSCRIPTCONFIGREGISTEREDRESPONSE._serialized_end=2581 + _BTCREGISTERSCRIPTCONFIGREQUEST._serialized_start=2584 + _BTCREGISTERSCRIPTCONFIGREQUEST._serialized_end=2836 + _BTCREGISTERSCRIPTCONFIGREQUEST_XPUBTYPE._serialized_start=2787 + _BTCREGISTERSCRIPTCONFIGREQUEST_XPUBTYPE._serialized_end=2836 + _BTCPREVTXINITREQUEST._serialized_start=2838 + _BTCPREVTXINITREQUEST._serialized_end=2936 + _BTCPREVTXINPUTREQUEST._serialized_start=2938 + _BTCPREVTXINPUTREQUEST._serialized_end=3052 + _BTCPREVTXOUTPUTREQUEST._serialized_start=3054 + _BTCPREVTXOUTPUTREQUEST._serialized_end=3116 + _BTCSIGNMESSAGEREQUEST._serialized_start=3119 + _BTCSIGNMESSAGEREQUEST._serialized_end=3357 + _BTCSIGNMESSAGERESPONSE._serialized_start=3359 + _BTCSIGNMESSAGERESPONSE._serialized_end=3402 + _BTCREQUEST._serialized_start=3405 + _BTCREQUEST._serialized_end=3971 + _BTCRESPONSE._serialized_start=3974 + _BTCRESPONSE._serialized_end=4374 # @@protoc_insertion_point(module_scope) diff --git a/py/bitbox02/bitbox02/communication/generated/btc_pb2.pyi b/py/bitbox02/bitbox02/communication/generated/btc_pb2.pyi index a4e69cff22..5108833def 100644 --- a/py/bitbox02/bitbox02/communication/generated/btc_pb2.pyi +++ b/py/bitbox02/bitbox02/communication/generated/btc_pb2.pyi @@ -123,19 +123,40 @@ class BTCScriptConfig(google.protobuf.message.Message): ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal["our_xpub_index",b"our_xpub_index","script_type",b"script_type","threshold",b"threshold","xpubs",b"xpubs"]) -> None: ... + class Policy(google.protobuf.message.Message): + """A policy as specified by 'Wallet policies': + https://github.com/bitcoin/bips/pull/1389 + """ + DESCRIPTOR: google.protobuf.descriptor.Descriptor + POLICY_FIELD_NUMBER: builtins.int + KEYS_FIELD_NUMBER: builtins.int + policy: typing.Text + @property + def keys(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[common_pb2.KeyOriginInfo]: ... + def __init__(self, + *, + policy: typing.Text = ..., + keys: typing.Optional[typing.Iterable[common_pb2.KeyOriginInfo]] = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["keys",b"keys","policy",b"policy"]) -> None: ... + SIMPLE_TYPE_FIELD_NUMBER: builtins.int MULTISIG_FIELD_NUMBER: builtins.int + POLICY_FIELD_NUMBER: builtins.int simple_type: global___BTCScriptConfig.SimpleType.ValueType @property def multisig(self) -> global___BTCScriptConfig.Multisig: ... + @property + def policy(self) -> global___BTCScriptConfig.Policy: ... def __init__(self, *, simple_type: global___BTCScriptConfig.SimpleType.ValueType = ..., multisig: typing.Optional[global___BTCScriptConfig.Multisig] = ..., + policy: typing.Optional[global___BTCScriptConfig.Policy] = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["config",b"config","multisig",b"multisig","simple_type",b"simple_type"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["config",b"config","multisig",b"multisig","simple_type",b"simple_type"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions.Literal["config",b"config"]) -> typing.Optional[typing_extensions.Literal["simple_type","multisig"]]: ... + def HasField(self, field_name: typing_extensions.Literal["config",b"config","multisig",b"multisig","policy",b"policy","simple_type",b"simple_type"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["config",b"config","multisig",b"multisig","policy",b"policy","simple_type",b"simple_type"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal["config",b"config"]) -> typing.Optional[typing_extensions.Literal["simple_type","multisig","policy"]]: ... global___BTCScriptConfig = BTCScriptConfig class BTCPubRequest(google.protobuf.message.Message): diff --git a/py/bitbox02/bitbox02/communication/generated/common_pb2.py b/py/bitbox02/bitbox02/communication/generated/common_pb2.py index 2da2b86d55..3109f6e384 100644 --- a/py/bitbox02/bitbox02/communication/generated/common_pb2.py +++ b/py/bitbox02/bitbox02/communication/generated/common_pb2.py @@ -13,7 +13,7 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0c\x63ommon.proto\x12\x14shiftcrypto.bitbox02\"\x1a\n\x0bPubResponse\x12\x0b\n\x03pub\x18\x01 \x01(\t\"\x18\n\x16RootFingerprintRequest\".\n\x17RootFingerprintResponse\x12\x13\n\x0b\x66ingerprint\x18\x01 \x01(\x0c\"l\n\x04XPub\x12\r\n\x05\x64\x65pth\x18\x01 \x01(\x0c\x12\x1a\n\x12parent_fingerprint\x18\x02 \x01(\x0c\x12\x11\n\tchild_num\x18\x03 \x01(\r\x12\x12\n\nchain_code\x18\x04 \x01(\x0c\x12\x12\n\npublic_key\x18\x05 \x01(\x0c\"\x1a\n\x07Keypath\x12\x0f\n\x07keypath\x18\x01 \x03(\rb\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0c\x63ommon.proto\x12\x14shiftcrypto.bitbox02\"\x1a\n\x0bPubResponse\x12\x0b\n\x03pub\x18\x01 \x01(\t\"\x18\n\x16RootFingerprintRequest\".\n\x17RootFingerprintResponse\x12\x13\n\x0b\x66ingerprint\x18\x01 \x01(\x0c\"l\n\x04XPub\x12\r\n\x05\x64\x65pth\x18\x01 \x01(\x0c\x12\x1a\n\x12parent_fingerprint\x18\x02 \x01(\x0c\x12\x11\n\tchild_num\x18\x03 \x01(\r\x12\x12\n\nchain_code\x18\x04 \x01(\x0c\x12\x12\n\npublic_key\x18\x05 \x01(\x0c\"\x1a\n\x07Keypath\x12\x0f\n\x07keypath\x18\x01 \x03(\r\"d\n\rKeyOriginInfo\x12\x18\n\x10root_fingerprint\x18\x01 \x01(\x0c\x12\x0f\n\x07keypath\x18\x02 \x03(\r\x12(\n\x04xpub\x18\x03 \x01(\x0b\x32\x1a.shiftcrypto.bitbox02.XPubb\x06proto3') _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'common_pb2', globals()) @@ -30,4 +30,6 @@ _XPUB._serialized_end=248 _KEYPATH._serialized_start=250 _KEYPATH._serialized_end=276 + _KEYORIGININFO._serialized_start=278 + _KEYORIGININFO._serialized_end=378 # @@protoc_insertion_point(module_scope) diff --git a/py/bitbox02/bitbox02/communication/generated/common_pb2.pyi b/py/bitbox02/bitbox02/communication/generated/common_pb2.pyi index adda12f503..93864b54fb 100644 --- a/py/bitbox02/bitbox02/communication/generated/common_pb2.pyi +++ b/py/bitbox02/bitbox02/communication/generated/common_pb2.pyi @@ -77,3 +77,23 @@ class Keypath(google.protobuf.message.Message): ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal["keypath",b"keypath"]) -> None: ... global___Keypath = Keypath + +class KeyOriginInfo(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + ROOT_FINGERPRINT_FIELD_NUMBER: builtins.int + KEYPATH_FIELD_NUMBER: builtins.int + XPUB_FIELD_NUMBER: builtins.int + root_fingerprint: builtins.bytes + @property + def keypath(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: ... + @property + def xpub(self) -> global___XPub: ... + def __init__(self, + *, + root_fingerprint: builtins.bytes = ..., + keypath: typing.Optional[typing.Iterable[builtins.int]] = ..., + xpub: typing.Optional[global___XPub] = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["xpub",b"xpub"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["keypath",b"keypath","root_fingerprint",b"root_fingerprint","xpub",b"xpub"]) -> None: ... +global___KeyOriginInfo = KeyOriginInfo diff --git a/src/rust/bitbox02-rust/src/shiftcrypto.bitbox02.rs b/src/rust/bitbox02-rust/src/shiftcrypto.bitbox02.rs index 38cc3d19a0..4e3e805200 100644 --- a/src/rust/bitbox02-rust/src/shiftcrypto.bitbox02.rs +++ b/src/rust/bitbox02-rust/src/shiftcrypto.bitbox02.rs @@ -38,6 +38,16 @@ pub struct Keypath { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct KeyOriginInfo { + #[prost(bytes = "vec", tag = "1")] + pub root_fingerprint: ::prost::alloc::vec::Vec, + #[prost(uint32, repeated, tag = "2")] + pub keypath: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "3")] + pub xpub: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct CheckBackupRequest { #[prost(bool, tag = "1")] pub silent: bool, @@ -203,7 +213,7 @@ pub struct AntiKleptoSignatureRequest { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BtcScriptConfig { - #[prost(oneof = "btc_script_config::Config", tags = "1, 2")] + #[prost(oneof = "btc_script_config::Config", tags = "1, 2, 3")] pub config: ::core::option::Option, } /// Nested message and enum types in `BTCScriptConfig`. @@ -265,6 +275,16 @@ pub mod btc_script_config { } } } + /// A policy as specified by 'Wallet policies': + /// + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Policy { + #[prost(string, tag = "1")] + pub policy: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub keys: ::prost::alloc::vec::Vec, + } /// SimpleType is a "simple" script: one public key, no additional inputs. #[derive( Clone, @@ -312,6 +332,8 @@ pub mod btc_script_config { SimpleType(i32), #[prost(message, tag = "2")] Multisig(Multisig), + #[prost(message, tag = "3")] + Policy(Policy), } } #[allow(clippy::derive_partial_eq_without_eq)]