@@ -2,7 +2,6 @@ import assert from 'assert';
2
2
import crypto from 'crypto' ;
3
3
4
4
import * as utxolib from '@bitgo/utxo-lib' ;
5
- import * as bitcoinMessage from 'bitcoinjs-message' ;
6
5
import { decodeProprietaryKey } from 'bip174/src/lib/proprietaryKeyVal' ;
7
6
import { KeyValue } from 'bip174/src/lib/interfaces' ;
8
7
import { checkForOutput } from 'bip174/src/lib/utils' ;
@@ -15,7 +14,7 @@ import {
15
14
} from '../../../src/paygo/psbt/PayGoUtils' ;
16
15
import { generatePayGoAttestationProof } from '../../../src/testutil/generatePayGoAttestationProof.utils' ;
17
16
import { parseVaspProof } from '../../../src/testutil/parseVaspProof' ;
18
- // import { signMessage } from '../../../src/bip32utils';
17
+ import { signMessage } from '../../../src/bip32utils' ;
19
18
20
19
// To construct our PSBTs
21
20
const network = utxolib . networks . bitcoin ;
@@ -54,7 +53,7 @@ const addressProofMsgBuffer = parseVaspProof(addressProofBuffer);
54
53
const addressProofEntropy = addressProofMsgBuffer . subarray ( 0 , 65 ) ;
55
54
56
55
// signature with the given msg addressProofBuffer
57
- const sig = bitcoinMessage . sign ( addressProofMsgBuffer , attestationPrvKey ! , true ) ;
56
+ const sig = signMessage ( addressProofMsgBuffer . toString ( ) , attestationPrvKey ! , network ) ;
58
57
59
58
function getTestPsbt ( ) {
60
59
return utxolib . testutil . constructPsbt ( psbtInputs , psbtOutputs , network , rootWalletKeys , 'unsigned' ) ;
@@ -82,7 +81,7 @@ describe('addPaygoAddressProof and verifyPaygoAddressProof', () => {
82
81
const proofInPsbt = getPaygoProprietaryKey ( output . unknownKeyVals ! ) ;
83
82
assert ( proofInPsbt . length === 1 ) ;
84
83
assert . throws (
85
- ( ) => verifyPayGoAddressProof ( psbt , 0 , '00000000-0000-0000-0000-000000000001' ) ,
84
+ ( ) => verifyPayGoAddressProof ( psbt , 0 , '00000000-0000-0000-0000-000000000001' , attestationPubKey ) ,
86
85
( e : any ) => e . message === 'Cannot verify the paygo address signature with the provided pubkey.'
87
86
) ;
88
87
} ) ;
@@ -92,7 +91,7 @@ describe('addPaygoAddressProof and verifyPaygoAddressProof', () => {
92
91
psbt . addOutput ( { script : utxolib . address . toOutputScript ( addressToVerify , network ) , value : BigInt ( 10000 ) } ) ;
93
92
const outputIndex = psbt . data . outputs . length - 1 ;
94
93
addPayGoAddressProof ( psbt , outputIndex , sig , addressProofEntropy ) ;
95
- verifyPayGoAddressProof ( psbt , outputIndex , nilUUID , Buffer . from ( addressToVerify ) ) ;
94
+ verifyPayGoAddressProof ( psbt , outputIndex , nilUUID , attestationPubKey ) ;
96
95
} ) ;
97
96
98
97
it ( 'should throw an error if there are multiple PayGo proprietary keys in the PSBT' , ( ) => {
@@ -105,7 +104,7 @@ describe('addPaygoAddressProof and verifyPaygoAddressProof', () => {
105
104
assert ( proofInPsbt . length !== 0 ) ;
106
105
assert ( proofInPsbt . length > 1 ) ;
107
106
assert . throws (
108
- ( ) => verifyPayGoAddressProof ( psbt , outputIndex , nilUUID ) ,
107
+ ( ) => verifyPayGoAddressProof ( psbt , outputIndex , nilUUID , attestationPubKey ) ,
109
108
( e : any ) => e . message === 'There are multiple paygo address proofs encoded in the PSBT. Something went wrong.'
110
109
) ;
111
110
} ) ;
@@ -115,7 +114,7 @@ describe('verifyPaygoAddressProof', () => {
115
114
it ( 'should throw an error if there is no PayGo address in PSBT' , ( ) => {
116
115
const psbt = getTestPsbt ( ) ;
117
116
assert . throws (
118
- ( ) => verifyPayGoAddressProof ( psbt , 0 , nilUUID ) ,
117
+ ( ) => verifyPayGoAddressProof ( psbt , 0 , nilUUID , attestationPubKey ) ,
119
118
( e : any ) => e . message === 'There is no paygo address proof encoded in the PSBT at output 0.'
120
119
) ;
121
120
} ) ;
0 commit comments