@@ -13,8 +13,6 @@ import {
1313 psbtOutputIncludesPaygoAddressProof ,
1414 verifyPayGoAddressProof ,
1515} from '../../../src/paygo/psbt/payGoAddressProof' ;
16- import { generatePayGoAttestationProof } from '../../../src/testutil/generatePayGoAttestationProof.utils' ;
17- import { trimMessagePrefix } from '../../../src/testutil/trimMessagePrefix' ;
1816import { signMessage } from '../../../src/bip32utils' ;
1917import { NIL_UUID } from '../../../src/paygo/attestation' ;
2018
@@ -45,19 +43,64 @@ export const addressToVerify = utxolib.address.toBase58Check(
4543 utxolib . networks . bitcoin
4644) ;
4745
48- // this should be retuning a Buffer
49- export const addressProofBuffer = generatePayGoAttestationProof ( NIL_UUID , Buffer . from ( addressToVerify ) ) ;
50- export const addressProofMsgBuffer = trimMessagePrefix ( addressProofBuffer ) ;
51- // We know that that the entropy is a set 64 bytes.
52- export const addressProofEntropy = addressProofMsgBuffer . subarray ( 0 , 65 ) ;
46+ // Fixed entropy for deterministic test fixtures (64 bytes of 0x00)
47+ export const addressProofEntropy = Buffer . alloc ( 64 , 0x00 ) ;
5348
54- // signature with the given msg addressProofBuffer
49+ // Create the message buffer manually with our fixed entropy
50+ const addressBuffer = Buffer . from ( addressToVerify ) ;
51+ const uuidBuffer = Buffer . from ( NIL_UUID ) ;
52+ export const addressProofMsgBuffer = Buffer . concat ( [ addressProofEntropy , addressBuffer , uuidBuffer ] ) ;
53+
54+ // signature with the given msg addressProofMsgBuffer
5555export const sig = signMessage ( addressProofMsgBuffer , attestationPrvKey ! , network ) ;
5656
5757function getTestPsbt ( ) {
5858 return utxolib . testutil . constructPsbt ( psbtInputs , psbtOutputs , network , rootWalletKeys , 'unsigned' ) ;
5959}
6060
61+ describe ( 'test fixtures' , ( ) => {
62+ it ( 'should have expected test fixture values' , ( ) => {
63+ // Address fixture - derived from backup key
64+ assert . strictEqual ( addressToVerify , '1CdWUVacSQQJ617HfuNWByGiisEGXGNx2c' ) ;
65+
66+ // Entropy fixture - fixed 64 bytes of zeros for deterministic testing
67+ assert . strictEqual (
68+ addressProofEntropy . toString ( 'hex' ) ,
69+ '0000000000000000000000000000000000000000000000000000000000000000' +
70+ '0000000000000000000000000000000000000000000000000000000000000000'
71+ ) ;
72+ assert . strictEqual ( addressProofEntropy . length , 64 ) ;
73+
74+ // Signature fixture - Bitcoin message signature (65 bytes with recovery ID)
75+ assert . strictEqual (
76+ sig . toString ( 'hex' ) ,
77+ '1fd62abac20bb963f5150aa4b3f4753c5f2f53ced5183ab7761d0c95c2820f6b' +
78+ 'b722b6d0d9adbab782d2d0d66402794b6bd6449dc26f634035ee388a2b5e7b53f6'
79+ ) ;
80+ assert . strictEqual ( sig . length , 65 ) ;
81+
82+ // Public key fixture - compressed secp256k1 public key (33 bytes)
83+ assert . strictEqual (
84+ attestationPubKey . toString ( 'hex' ) ,
85+ '02456f4f788b6af55eb9c54d88692cadef4babdbc34cde75218cc1d6b6de3dea2d'
86+ ) ;
87+ assert . strictEqual ( attestationPubKey . length , 33 ) ;
88+
89+ // Message buffer structure: [ENTROPY][ADDRESS][UUID]
90+ // Total length: 64 (entropy) + 34 (address) + 36 (UUID) = 134
91+ assert . strictEqual ( addressProofMsgBuffer . length , 134 ) ;
92+
93+ // Verify message components
94+ const entropy = addressProofMsgBuffer . subarray ( 0 , 64 ) ;
95+ const address = addressProofMsgBuffer . subarray ( 64 , 98 ) ;
96+ const uuid = addressProofMsgBuffer . subarray ( 98 , 134 ) ;
97+
98+ assert . strictEqual ( entropy . toString ( 'hex' ) , addressProofEntropy . toString ( 'hex' ) ) ;
99+ assert . strictEqual ( address . toString ( ) , addressToVerify ) ;
100+ assert . strictEqual ( uuid . toString ( ) , NIL_UUID ) ;
101+ } ) ;
102+ } ) ;
103+
61104describe ( 'addPaygoAddressProof and verifyPaygoAddressProof' , ( ) => {
62105 function getPayGoProprietaryKey ( proprietaryKeyVals : KeyValue [ ] ) {
63106 return proprietaryKeyVals
0 commit comments