Skip to content

Commit 4cde66c

Browse files
chore(utxo-core): bip32utils to sign and verify message
TICKET: BTC-2047
1 parent 7976863 commit 4cde66c

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

modules/utxo-core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"@bitgo/utxo-lib": "^11.5.0",
5656
"@bitgo/wasm-miniscript": "2.0.0-beta.7",
5757
"bip174": "npm:@bitgo-forks/bip174@3.1.0-master.4",
58-
"bitcoinjs-message": "npm:@bitgo-forks/bitcoinjs-message@1.0.0-master.3",
5958
"lodash": "^4.17.15"
6059
},
6160
"devDependencies": {

modules/utxo-core/src/paygo/psbt/PayGoUtils.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as utxolib from '@bitgo/utxo-lib';
2-
import * as bitcoinMessage from 'bitcoinjs-message';
32
import { checkForOutput } from 'bip174/src/lib/utils';
43

54
import { extractAddressBufferFromPayGoAttestationProof } from '../ExtractAddressPayGoAttestation';
5+
import { verifyMessage } from '../../bip32utils';
66

77
import {
88
ErrorMultiplePayGoProof,
@@ -75,15 +75,10 @@ export function verifyPayGoAddressProof(
7575

7676
// It doesn't matter that this is bitcoin or not, we just need to convert the public key buffer into an address format
7777
// for the verification
78-
const messageToVerify = utxolib.address.toBase58Check(
79-
utxolib.crypto.hash160(pub),
80-
utxolib.networks.bitcoin.pubKeyHash,
81-
utxolib.networks.bitcoin
82-
);
83-
84-
if (!bitcoinMessage.verify(message, messageToVerify, signature, utxolib.networks.bitcoin.messagePrefix)) {
78+
if (!verifyMessage(message.toString(), pub, signature, utxolib.networks.bitcoin)) {
8579
throw new ErrorPayGoAddressProofFailedVerification();
8680
}
81+
8782
// We should be verifying the address that was encoded into our message.
8883
const addressFromProof = extractAddressBufferFromPayGoAttestationProof(message).toString();
8984

modules/utxo-core/test/paygo/psbt/PayGoUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import assert from 'assert';
22

33
import * as utxolib from '@bitgo/utxo-lib';
4-
import * as bitcoinMessage from 'bitcoinjs-message';
54
import { decodeProprietaryKey } from 'bip174/src/lib/proprietaryKeyVal';
65
import { KeyValue } from 'bip174/src/lib/interfaces';
76
import { checkForOutput } from 'bip174/src/lib/utils';
@@ -13,6 +12,7 @@ import {
1312
verifyPayGoAddressProof,
1413
} from '../../../src/paygo/psbt/PayGoUtils';
1514
import { generatePayGoAttestationProof } from '../../../src/testutil/generatePayGoAttestationProof.utils';
15+
import { signMessage } from '../../../src/bip32utils';
1616

1717
// To construct our PSBTs
1818
const network = utxolib.networks.bitcoin;
@@ -47,7 +47,7 @@ const addressToVerify = utxolib.address.toBase58Check(
4747
// this should be retuning a Buffer
4848
const addressProofBuffer = generatePayGoAttestationProof(nilUUID, Buffer.from(addressToVerify));
4949
// signature with the given msg addressProofBuffer
50-
const sig = bitcoinMessage.sign(addressProofBuffer, attestationPrvKey!, true, network.messagePrefix);
50+
const sig = signMessage(addressProofBuffer.toString(), attestationPrvKey!, network);
5151

5252
function getTestPsbt() {
5353
return utxolib.testutil.constructPsbt(psbtInputs, psbtOutputs, network, rootWalletKeys, 'unsigned');

0 commit comments

Comments
 (0)