Skip to content

Commit

Permalink
Update BIP_MUSIG_CHAINCODE ==> BIP_328_CHAINCODE
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed Oct 9, 2024
1 parent 07dc69d commit 1064cdf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions bitcoin_client/ledger_bitcoin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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
]))

Expand Down
2 changes: 1 addition & 1 deletion src/handler/lib/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
6 changes: 2 additions & 4 deletions src/handler/sign_psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/musig/musig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down

0 comments on commit 1064cdf

Please sign in to comment.