From 9fbf59a143a0390a93bd97e5bbfe984887f2ac7b Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Wed, 15 Oct 2025 17:08:13 +0200 Subject: [PATCH] fix(utxo-lib): clarify musig2 implementation notes The current implementation is not the final Musig2 spec but an earlier variant that aggregates x-only pubkeys. Added reference to specific implementation details and updated test comments. Issue: BTC-2651 Co-authored-by: llm-git --- modules/utxo-lib/src/taproot.ts | 5 +++++ modules/utxo-lib/test/taproot.spec.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/utxo-lib/src/taproot.ts b/modules/utxo-lib/src/taproot.ts index f1657ecd73..1009e782d2 100644 --- a/modules/utxo-lib/src/taproot.ts +++ b/modules/utxo-lib/src/taproot.ts @@ -1,6 +1,11 @@ // Taproot-specific key aggregation and taptree logic as defined in: // https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki // https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki +// +// The implementation here is unfortunately not the same as the final Musig2 +// implementation. It is a variant of an earlier version that aggregates the +// x-only 32-byte pubkeys instead of the plain 33-byte pubkeys. +// See https://github.com/OttoAllmendinger/bips/blob/musig-bitgo/bip-musig2/reference.py for details. import { TapTree as PsbtTapTree, TapLeaf as PsbtTapLeaf } from 'bip174/src/lib/interfaces'; import assert = require('assert'); diff --git a/modules/utxo-lib/test/taproot.spec.ts b/modules/utxo-lib/test/taproot.spec.ts index 3655742790..68c980b85d 100644 --- a/modules/utxo-lib/test/taproot.spec.ts +++ b/modules/utxo-lib/test/taproot.spec.ts @@ -7,9 +7,13 @@ const ECPair: ECPairAPI = ECPairFactory(ecc); describe('taproot utils', () => { describe('musig key aggregation', () => { - // Expected values for the test cases assertions below are derived from the + // Expected values for the test cases assertions below are derived from a // MuSig2 implementation example code in secp256k1-zkp. - // https://github.com/jonasnick/secp256k1-zkp/blob/musig2/src/modules/musig/example.c + // https://github.com/jonasnick/secp256k1-zkp/blob/musig2/src/modules/musig/example.c (link defunct) + // + // Reconstruction of the code in the above link: + // https://github.com/OttoAllmendinger/bips/commit/3683cc46e0cf4fc101f1c06492eb1f9f2ab9e450 + // https://github.com/OttoAllmendinger/bips/blob/musig-bitgo/bip-musig2/reference.py it('aggregates 2 pubkeys', () => { const aggregatePubkey = taproot.aggregateMuSigPubkeys(ecc, [