diff --git a/bitcoin_client/ledger_bitcoin/client.py b/bitcoin_client/ledger_bitcoin/client.py index 89279df36..6fe983152 100644 --- a/bitcoin_client/ledger_bitcoin/client.py +++ b/bitcoin_client/ledger_bitcoin/client.py @@ -42,7 +42,7 @@ def parse_stream_to_map(f: BufferedReader) -> Mapping[bytes, bytes]: def aggr_xpub(pubkeys: List[bytes], chain: Chain) -> str: - BIP_MUSIG_CHAINCODE = bytes.fromhex( + BIP_328_CHAINCODE = bytes.fromhex( "868087ca02a6f974c4598924c36b57762d32cb45717167e300622c7167e38965") # sort the pubkeys prior to aggregation ctx = key_agg(list(sorted(pubkeys))) @@ -59,7 +59,7 @@ def aggr_xpub(pubkeys: List[bytes], chain: Chain) -> str: b'\x00', # depth b'\x00\x00\x00\x00', # parent fingerprint b'\x00\x00\x00\x00', # child number - BIP_MUSIG_CHAINCODE, + BIP_328_CHAINCODE, compressed_pubkey ])) diff --git a/src/handler/lib/policy.c b/src/handler/lib/policy.c index 38408c5d3..1bbf1630c 100644 --- a/src/handler/lib/policy.c +++ b/src/handler/lib/policy.c @@ -500,7 +500,7 @@ __attribute__((warn_unused_result)) static int get_derived_pubkey( ext_pubkey.compressed_pubkey[0] = (musig_ctx.Q.y[31] % 2 == 0) ? 2 : 3; memcpy(&ext_pubkey.compressed_pubkey[1], musig_ctx.Q.x, sizeof(musig_ctx.Q.x)); - memcpy(&ext_pubkey.chain_code, BIP_MUSIG_CHAINCODE, sizeof(BIP_MUSIG_CHAINCODE)); + memcpy(&ext_pubkey.chain_code, BIP_328_CHAINCODE, sizeof(BIP_328_CHAINCODE)); } else { LEDGER_ASSERT(false, "Unreachable code"); } diff --git a/src/handler/sign_psbt.c b/src/handler/sign_psbt.c index fd2b5731c..afa39e3c8 100644 --- a/src/handler/sign_psbt.c +++ b/src/handler/sign_psbt.c @@ -821,9 +821,7 @@ static bool fill_keyexpr_info_if_internal(dispatcher_context_t *dc, memcpy(&keyexpr_info->pubkey.compressed_pubkey[1], musig_ctx.Q.x, sizeof(musig_ctx.Q.x)); - memcpy(&keyexpr_info->pubkey.chain_code, - BIP_MUSIG_CHAINCODE, - sizeof(BIP_MUSIG_CHAINCODE)); + memcpy(&keyexpr_info->pubkey.chain_code, BIP_328_CHAINCODE, sizeof(BIP_328_CHAINCODE)); keyexpr_info->fingerprint = crypto_get_key_fingerprint(keyexpr_info->pubkey.compressed_pubkey); @@ -2589,7 +2587,7 @@ sign_sighash_musig_and_yield(dispatcher_context_t *dc, ext_pubkey.compressed_pubkey[0] = (musig_ctx.Q.y[31] % 2 == 0) ? 2 : 3; memcpy(&ext_pubkey.compressed_pubkey[1], musig_ctx.Q.x, sizeof(musig_ctx.Q.x)); - memcpy(&ext_pubkey.chain_code, BIP_MUSIG_CHAINCODE, sizeof(BIP_MUSIG_CHAINCODE)); + memcpy(&ext_pubkey.chain_code, BIP_328_CHAINCODE, sizeof(BIP_328_CHAINCODE)); // 2) compute musig2 tweaks // We always have exactly 2 BIP32 tweaks in wallet policies; if the musig is in the keypath diff --git a/src/musig/musig.h b/src/musig/musig.h index 1632bd085..4a7657672 100644 --- a/src/musig/musig.h +++ b/src/musig/musig.h @@ -5,8 +5,7 @@ #define MUSIG_PUBNONCE_SIZE 66 -// TODO: rename once BIP number is assigned -static uint8_t BIP_MUSIG_CHAINCODE[32] = { +static uint8_t BIP_328_CHAINCODE[32] = { 0x86, 0x80, 0x87, 0xCA, 0x02, 0xA6, 0xF9, 0x74, 0xC4, 0x59, 0x89, 0x24, 0xC3, 0x6B, 0x57, 0x76, 0x2D, 0x32, 0xCB, 0x45, 0x71, 0x71, 0x67, 0xE3, 0x00, 0x62, 0x2C, 0x71, 0x67, 0xE3, 0x89, 0x65};