Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions modules/utxo-lib/src/taproot.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
8 changes: 6 additions & 2 deletions modules/utxo-lib/test/taproot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down