Skip to content

Commit c184a96

Browse files
committed
Fix multisig taproot example's provable nonce calculation
1 parent 5909559 commit c184a96

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/integration/taproot.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,15 +777,16 @@ function makeUnspendableInternalKey(provableNonce?: Buffer): Buffer {
777777
);
778778

779779
if (provableNonce) {
780-
// Using a shared random value, we create an unspendable internalKey
781-
// P = H + int(hash_taptweak(provableNonce))*G
782-
// Since we don't know H's private key (see explanation above), we can't know P's private key
783780
if (provableNonce.length !== 32) {
784781
throw new Error(
785782
'provableNonce must be a 32 byte random value shared between script holders',
786783
);
787784
}
788-
const ret = ecc.xOnlyPointAddTweak(Hx, provableNonce);
785+
// Using a shared random value, we create an unspendable internalKey
786+
// P = H + int(hash_taptweak(provableNonce))*G
787+
// Since we don't know H's private key (see explanation above), we can't know P's private key
788+
const tapHash = bitcoin.crypto.taggedHash('TapTweak', provableNonce);
789+
const ret = ecc.xOnlyPointAddTweak(Hx, tapHash);
789790
if (!ret) {
790791
throw new Error(
791792
'provableNonce produced an invalid key when tweaking the G hash',

0 commit comments

Comments
 (0)