@@ -15,7 +15,7 @@ import {
15
15
import { generatePayGoAttestationProof } from '../../../src/testutil/generatePayGoAttestationProof.utils' ;
16
16
import { trimMessagePrefix } from '../../../src/paygo/trimMessagePrefix' ;
17
17
import { signMessage } from '../../../src/bip32utils' ;
18
- import { NIL_UUID } from '../../../src/paygo/attestation' ;
18
+ import { createPayGoAttestationBuffer , NIL_UUID } from '../../../src/paygo/attestation' ;
19
19
import { parsePayGoAttestation } from '../../../src/paygo' ;
20
20
21
21
// To construct our PSBTs
@@ -138,11 +138,33 @@ describe('getPaygoAddressProofIndex', () => {
138
138
// Small test to verify, leave in this test file
139
139
describe ( 'trimMessagePrefix' , function ( ) {
140
140
it ( 'should be the same proof constructed consistently' , function ( ) {
141
- const reconstructedProof = Buffer . concat ( [
141
+ const psbt = getTestPsbt ( ) ;
142
+ psbt . addOutput ( { script : utxolib . address . toOutputScript ( addressToVerify , network ) , value : BigInt ( 10000 ) } ) ;
143
+ const outputIndex = psbt . data . outputs . length - 1 ;
144
+ addPayGoAddressProof ( psbt , outputIndex , sig , addressProofEntropy ) ;
145
+ // manually check without the verify function to see if the entropy being stored
146
+ // in the psbt is the same as the entropy being extracted and trimmed.
147
+ const psbtOutputs = checkForOutput ( psbt . data . outputs , outputIndex ) ;
148
+ const stored = utxolib . bitgo . getProprietaryKeyValuesFromUnknownKeyValues ( psbtOutputs , {
149
+ identifier : utxolib . bitgo . PSBT_PROPRIETARY_IDENTIFIER ,
150
+ subtype : utxolib . bitgo . ProprietaryKeySubtype . PAYGO_ADDRESS_ATTESTATION_PROOF ,
151
+ } ) ;
152
+
153
+ assert ( stored [ 0 ] . key . keydata . equals ( payGoAttestationProofComponents . entropy ) ) ;
154
+ assert ( stored [ 0 ] . value . equals ( sig ) ) ;
155
+
156
+ const reconstructedProofFromComponents = Buffer . concat ( [
142
157
payGoAttestationProofComponents . entropy ,
143
158
payGoAttestationProofComponents . address ,
144
159
payGoAttestationProofComponents . uuid ,
145
160
] ) ;
146
- assert ( addressProofMsgBuffer . equals ( reconstructedProof ) ) ;
161
+ const verifyConstructedProof = createPayGoAttestationBuffer (
162
+ addressToVerify ,
163
+ stored [ 0 ] . key . keydata ,
164
+ utxolib . networks . bitcoin
165
+ ) ;
166
+
167
+ assert ( addressProofMsgBuffer . equals ( reconstructedProofFromComponents ) ) ;
168
+ assert ( verifyConstructedProof . equals ( reconstructedProofFromComponents ) ) ;
147
169
} ) ;
148
170
} ) ;
0 commit comments