Skip to content

Commit 0d2d2f5

Browse files
OttoAllmendingerllm-git
andcommitted
feat(utxo-lib): clarify MuSig2 variant used in P2TR implementation
Update documentation to clearly differentiate between the older MuSig2 variant used in BitGo's p2tr script type (chain 30, 31) versus the standard MuSig2 implementation used in p2trMusig2 script type (chain 40, 41). Issue: BTC-2652 Co-authored-by: llm-git <llm-git@ttll.de>
1 parent ee95e5b commit 0d2d2f5

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

modules/utxo-lib/src/taproot.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// Taproot-specific key aggregation and taptree logic as defined in:
2-
// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
3-
// https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki
1+
// This code is used in the BitGo `p2tr` script type (chain 30, 31), which uses
2+
// an older variant of the MuSig2 key aggregation algorithm.
3+
// The BitGo `p2trMusig2` script type (chain 40, 41) uses the standard MuSig2
4+
// key aggregation algorithm which is implemented by the `@brandonblack/musig` library.
45

56
import { TapTree as PsbtTapTree, TapLeaf as PsbtTapLeaf } from 'bip174/src/lib/interfaces';
67
import assert = require('assert');
@@ -27,10 +28,14 @@ export interface TinySecp256k1Interface {
2728
}
2829

2930
/**
30-
* Aggregates a list of public keys into a single MuSig2* public key
31-
* according to the MuSig2 paper.
31+
* Aggregates a list of public keys into a single public key.
32+
*
33+
* This is an older variant of the MuSig2 key aggregation algorithm that
34+
* (1) expects x-only pubkeys with even Y coordinate, and
35+
* (2) sorts the keys in ascending order before aggregation.
36+
*
3237
* @param ecc Elliptic curve implementation
33-
* @param pubkeys The list of pub keys to aggregate
38+
* @param pubkeys The list of pub keys to aggregate (32 byte x-only pubkeys)
3439
* @returns a 32 byte Buffer representing the aggregate key
3540
*/
3641
export function aggregateMuSigPubkeys(ecc: TinySecp256k1Interface, pubkeys: Buffer[]): Uint8Array {

0 commit comments

Comments
 (0)