Skip to content

Commit 75b2f86

Browse files
chore(utxo-core): renamed files and moved helper to own file
TICKET: BTC-2047
1 parent e933da1 commit 75b2f86

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export const NILL_UUID = '00000000-0000-0000-0000-000000000000';
2+
3+
/** This function reconstructs the proof <ENTROPY><ADDRESS><UUID>
4+
* given the address and entropy.
5+
*
6+
* @param address
7+
* @param entropy
8+
* @returns
9+
*/
10+
export function createPayGoAttestationBuffer(address: string, entropy: Buffer): Buffer {
11+
const addressBuffer = Buffer.from(address);
12+
return Buffer.concat([entropy, addressBuffer, Buffer.from(NILL_UUID)]);
13+
}

modules/utxo-core/src/paygo/psbt/PayGoUtils.ts renamed to modules/utxo-core/src/paygo/psbt/payGoAddressProof.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as utxolib from '@bitgo/utxo-lib';
22
import { checkForOutput } from 'bip174/src/lib/utils';
33

44
import { verifyMessage } from '../../bip32utils';
5+
import { createPayGoAttestationBuffer } from '../attestation';
56

67
import {
78
ErrorMultiplePayGoProof,
@@ -11,8 +12,6 @@ import {
1112
ErrorPayGoAddressProofFailedVerification,
1213
} from './Errors';
1314

14-
const NILLUUID = '00000000-0000-0000-0000-000000000000';
15-
1615
/** This function adds the entropy and signature into the PSBT output unknown key vals.
1716
* We store the entropy so that we reconstruct the message <ENTROPY><ADDRESS><UUID>
1817
* to later verify.
@@ -109,15 +108,3 @@ export function getPayGoAddressProofOutputIndex(psbt: utxolib.bitgo.UtxoPsbt): n
109108
export function psbtOutputIncludesPaygoAddressProof(psbt: utxolib.bitgo.UtxoPsbt): boolean {
110109
return getPayGoAddressProofOutputIndex(psbt) !== undefined;
111110
}
112-
113-
/** This function reconstructs the proof <ENTROPY><ADDRESS><UUID>
114-
* given the address and entropy.
115-
*
116-
* @param address
117-
* @param entropy
118-
* @returns
119-
*/
120-
export function createPayGoAttestationBuffer(address: string, entropy: Buffer): Buffer {
121-
const addressBuffer = Buffer.from(address);
122-
return Buffer.concat([entropy, addressBuffer, Buffer.from(NILLUUID)]);
123-
}

modules/utxo-core/test/paygo/psbt/PayGoUtils.ts renamed to modules/utxo-core/test/paygo/psbt/payGoAddressProof.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import { checkForOutput } from 'bip174/src/lib/utils';
88

99
import {
1010
addPayGoAddressProof,
11-
createPayGoAttestationBuffer,
1211
getPayGoAddressProofOutputIndex,
1312
psbtOutputIncludesPaygoAddressProof,
1413
verifyPayGoAddressProof,
15-
} from '../../../src/paygo/psbt/PayGoUtils';
14+
} from '../../../src/paygo/psbt/payGoAddressProof';
1615
import { generatePayGoAttestationProof } from '../../../src/testutil/generatePayGoAttestationProof.utils';
1716
import { parseVaspProof } from '../../../src/testutil/parseVaspProof';
1817
import { signMessage } from '../../../src/bip32utils';
18+
import { createPayGoAttestationBuffer, NILL_UUID } from '../../../src/paygo/attestation';
1919

2020
// To construct our PSBTs
2121
const network = utxolib.networks.bitcoin;
@@ -37,9 +37,6 @@ const dummyPub1 = rootWalletKeys.deriveForChainAndIndex(50, 200);
3737
const attestationPubKey = dummyPub1.user.publicKey;
3838
const attestationPrvKey = dummyPub1.user.privateKey!;
3939

40-
// UUID structure
41-
const nillUUID = '00000000-0000-0000-0000-000000000000';
42-
4340
// our xpub converted to base58 address
4441
const addressToVerify = utxolib.address.toBase58Check(
4542
utxolib.crypto.hash160(Buffer.from(dummyPub1.backup.publicKey)),
@@ -48,7 +45,7 @@ const addressToVerify = utxolib.address.toBase58Check(
4845
);
4946

5047
// this should be retuning a Buffer
51-
const addressProofBuffer = generatePayGoAttestationProof(nillUUID, Buffer.from(addressToVerify));
48+
const addressProofBuffer = generatePayGoAttestationProof(NILL_UUID, Buffer.from(addressToVerify));
5249
const addressProofMsgBuffer = parseVaspProof(addressProofBuffer);
5350
// We know that that the entropy is a set 64 bytes.
5451
const addressProofEntropy = addressProofMsgBuffer.subarray(0, 65);

0 commit comments

Comments
 (0)