|
1 | 1 | import * as utxolib from '@bitgo/utxo-lib';
|
2 | 2 | import * as utxocore from '@bitgo/utxo-core';
|
3 |
| -import { bufferutils } from '@bitgo/utxo-lib'; |
4 |
| -// import * as transactionModule from '@bitgo/abstract-utxo/src/transaction'; |
5 | 3 | import * as should from 'should';
|
6 | 4 | import * as sinon from 'sinon';
|
7 | 5 | import { Wallet, UnexpectedAddressError, VerificationOptions } from '@bitgo/sdk-core';
|
@@ -590,23 +588,19 @@ describe('Abstract UTXO Coin:', () => {
|
590 | 588 | describe('Verify paygo output when explaining psbt transaction', function () {
|
591 | 589 | const bitgo: BitGo = TestBitGo.decorate(BitGo, { env: 'mock' });
|
592 | 590 | let coin: AbstractUtxoCoin;
|
593 |
| - const NIL_UUID = '00000000-0000-0000-0000-000000000000'; |
594 | 591 |
|
595 | 592 | // let getPayGoVerificationPubkeyStub: sinon.SinonStub;
|
596 | 593 | let verifyPayGoAddressProofStub: sinon.SinonStub;
|
597 |
| - let psbtOutputIncludesPaygoAddressProofStub: sinon.SinonStub; |
598 | 594 |
|
599 | 595 | before(() => {
|
600 | 596 | coin = bitgo.coin('tbtc4') as AbstractUtxoCoin;
|
601 | 597 | // getPayGoVerificationPubkeyStub = sinon.stub(transactionModule, 'getPayGoVerificationPubkey').returns(xpub);
|
602 | 598 | verifyPayGoAddressProofStub = sinon.stub(utxocore.paygo, 'verifyPayGoAddressProof');
|
603 |
| - psbtOutputIncludesPaygoAddressProofStub = sinon.stub(utxocore.paygo, 'psbtOutputIncludesPaygoAddressProof'); |
604 | 599 | });
|
605 | 600 |
|
606 | 601 | after(() => {
|
607 | 602 | // getPayGoVerificationPubkeyStub.restore();
|
608 | 603 | verifyPayGoAddressProofStub.restore();
|
609 |
| - psbtOutputIncludesPaygoAddressProofStub.restore(); |
610 | 604 | });
|
611 | 605 |
|
612 | 606 | it('should detect and verify paygo address proof in PSBT', async function () {
|
@@ -644,84 +638,7 @@ describe('Abstract UTXO Coin:', () => {
|
644 | 638 | // Call explainTransaction
|
645 | 639 | const res = await coin.explainTransaction(mockParams);
|
646 | 640 | console.log(res);
|
647 |
| - // verifyPayGoAddressProofStub.called.should.be.true(); |
| 641 | + verifyPayGoAddressProofStub.called.should.be.true(); |
648 | 642 | });
|
649 | 643 | });
|
650 | 644 | });
|
651 |
| - |
652 |
| -// describe('test', function () { |
653 |
| -// it('should parse path', function () { |
654 |
| -// function parsePath(path: string): string { |
655 |
| -// if (path.startsWith('/')) { |
656 |
| -// console.log('parsing'); |
657 |
| -// return path.slice(1); |
658 |
| -// } |
659 |
| -// return path; |
660 |
| -// } |
661 |
| -// const path = '/0/0'; |
662 |
| -// const parsedPath = parsePath(path); |
663 |
| -// console.log(`parsed path: ${parsedPath}`); |
664 |
| -// console.log(`og path: ${path}`); |
665 |
| -// console.log(path ?? 'no path'); |
666 |
| -// console.log(path === undefined ? 'no path' : parsedPath); |
667 |
| -// }); |
668 |
| - |
669 |
| -// it('should verify', function () { |
670 |
| -// // Proof core verification components |
671 |
| -// const proof = |
672 |
| -// '18426974636f696e205369676e6564204d6573736167653a0aa24e5058323943377469546f687346734c7932646265516e4d6567505a6a6b356b38684d6f616748537441653953596632756e796252516e334c664c3669383739746231706b3936636a683770336578656a323038713763367663757261797564663472397961673239376e6a356d377a32786730676d667371367733677830303030303030302d303030302d303030302d303030302d303030303030303030303030'; |
673 |
| -// const { entropy, address, uuid } = utxocore.paygo.parsePayGoAttestation(Buffer.from(proof, 'hex')); |
674 |
| -// const msg = Buffer.concat([entropy, address, uuid]); |
675 |
| -// const sig = 'ICIe6pgTP1oU+CsoKwOgXKs4WrhtRejpapx+TAQEcPc2M3sXYgJaKOK4fHbE7Atto52/VTf6iMAk5hWjZY1NlCY='; |
676 |
| -// // const sig2 = Buffer.from(sig, 'base64').slice(1).toString('base64'); |
677 |
| -// const xpub = |
678 |
| -// 'xpub661MyMwAqRbcFU2Qx7pvGmmiQpVj8NcR7dSVpgqNChMkQyobpVWWERcrTb47WicmXwkhAY2VrC3hb29s18FDQWJf5pLm3saN6uLXAXpw1GV'; |
679 |
| -// const pubkey = utxolib.bip32.fromBase58(xpub, utxolib.networks.bitcoin).derivePath('0/0').publicKey; |
680 |
| -// // we are reconstructing this proof for verification purposes to see if we can deconstruct our proof properly |
681 |
| -// const prefixString = '\u0018Bitcoin Signed Message:\n'; |
682 |
| -// const varuint = utxolib.bufferutils.varuint.encode(msg.length); |
683 |
| -// const prefixBuff = Buffer.from(prefixString, 'utf-8'); |
684 |
| -// const reconstructedProof = Buffer.concat([prefixBuff, varuint, entropy, address, uuid]); |
685 |
| -// console.log(`reconstructed proof equals regular proof: ${reconstructedProof.toString('hex') === proof}`); |
686 |
| - |
687 |
| -// const msgWithVaruint = Buffer.concat([varuint, msg]); |
688 |
| -// // also tried to verify msg without varuint, also returns false. |
689 |
| -// const verify = utxocore.bip32utils.verifyMessage(msg, pubkey, Buffer.from(sig, 'base64'), utxolib.networks.bitcoin); |
690 |
| -// console.log(`verified proof: ${verify}`); // false |
691 |
| -// }); |
692 |
| -// }); |
693 |
| - |
694 |
| -// describe('test og', () => { |
695 |
| -// it('should ver #2', () => { |
696 |
| -// const xpub = |
697 |
| -// 'xpub661MyMwAqRbcFhYdi7qRCuHyYvBjnGQ9RuXoogM6iry2V6RoE8Cvq6yinrLsZQvjZQK8MKSsB5qzHpyGeKcnSZrtLkLYytaNRPR3TXtdfwY'; |
698 |
| -// const vaspProof = { |
699 |
| -// proof: |
700 |
| -// '18426974636f696e205369676e6564204d6573736167653a0a85574a69503774774e7a46787251444231555578527636436d6b6d593142444d4d37683257395037447658765864726e677a336572534155566469553738477147316b6e52735266733958335772484433775461726f6236687565764e4c5933647930303030303030302d303030302d303030302d303030302d303030303030303030303030', |
701 |
| -// signature: 'IE7YQyLyrv0lFBo/0601EC3pvkXUIp/bN1V7gbyuLdkVciCZOa7HwMNKre+cAUWKPZ5Y59QBktt5x2gO6HS03Ww=', |
702 |
| -// }; |
703 |
| -// console.log( |
704 |
| -// '====================================================================================================================================' |
705 |
| -// ); |
706 |
| -// const { entropy, address, uuid } = utxocore.paygo.parsePayGoAttestation(Buffer.from(vaspProof.proof, 'hex')); |
707 |
| -// const msg = Buffer.concat([entropy, address, uuid]); |
708 |
| -// const verify = utxocore.bip32utils.verifyMessage( |
709 |
| -// msg, |
710 |
| -// utxolib.bip32.fromBase58(xpub).derivePath('/').publicKey, |
711 |
| -// Buffer.from(vaspProof.signature, 'base64'), |
712 |
| -// utxolib.networks.bitcoin |
713 |
| -// ); |
714 |
| -// console.log(entropy.toString('hex')); |
715 |
| -// console.log(address.toString('hex')); |
716 |
| -// console.log(uuid.toString('hex')); |
717 |
| -// console.log( |
718 |
| -// '====================================================================================================================================' |
719 |
| -// ); |
720 |
| -// console.log(verify); |
721 |
| -// }); |
722 |
| -// }); |
723 |
| - |
724 |
| -// 70736274ff0100b4010000000176e65d40a648da1a3b9412d5b49cc309a37a6a7f3c9cd8b8f1f41a2fbbfd479f0100000000fdffffff03204e000000000000225120f7d56f65c3d028dc75a00bdd3c75cd3d4563f051d4f1fe4db8b925a7113df689eb0d1e0000000000225120a7dae2a654772a7b8fc760547e52eaa0224c152bd36c64d45d07d552f284544600127a000000000022002037f34405b83128e4cdecb64f44bff64d0d1b6188d2d656782b136e3488eab1f2000000004f010488b21e00000000000000000067b8325a2303718652d085e2bb65e4c84e8a51eaa4f4ea56e11542290bd27875037cb4cea965ae9d7846addc2a534318a377436864f90a38e2619ca51513cf7a7b0488f255714f010488b21e000000000000000000a5d5ff1d68596719baad5a209925b5edfdc7899ca460a071b3c84bd5bc76b99303f9dc3f6f974f2c90c6d0b7b7c50bc4de49bb8105bfa27223babc909720c6191a043d4b2b964f010488b21e000000000000000000dd32781f8dff65567d76ba1c9485014f7eb07d9527a502cbe0dafb64c20961cd028a55ce3f0c98964dfc6814b1b55b2b77cc31d33a5ae1a994476ce8b20b1618530435eabe8d0001012bd36e980000000000225120866e64ab95028afde6e42cd0dcbd6b38f8dec74d3f3a7648e11259f64075321b0103040000000021163024116333a45124af6141080383eea1b756c1983a07d71d50a2c62d774b7b64150088f25571000000000000000029000000000000002116e5a56ea96f692990ef584ebecaa55acf8d7d4e186db4c489e5498210cc2162df15003d4b2b96000000000000000029000000000000000117201263360542e6b356eaf5c4f03b4af4e0693e169ca7c44207209d3bcc2a3b8f620118208dca1a18f7db9002face5d00d8ebe62ecd0b557a6590b6a2f5686890926bdde548fc05424954474f01866e64ab95028afde6e42cd0dcbd6b38f8dec74d3f3a7648e11259f64075321b1263360542e6b356eaf5c4f03b4af4e0693e169ca7c44207209d3bcc2a3b8f6242033024116333a45124af6141080383eea1b756c1983a07d71d50a2c62d774b7b6402e5a56ea96f692990ef584ebecaa55acf8d7d4e186db4c489e5498210cc2162df0048fc05424954474f044b626348564c484a694557323978546b565a504b325a556e364b51733734445538416657387138595a70776e3736626359557255506b45774c5a724343765275411f4e27998b3b35db81b658d4fed87733b824f0179034b2648930bccf6618dfbb0168cce5776830545cd795ec958961a2ebd68c01ed51db23361b2de15a2aa6ce6300010520bc453383fa08ed074e185e7f5fb0c7ab71e70cf5098b27ca2dceff79288522f901068e01c04420905e79ce4a7441da4424d63a868c3ddae6a7aec1ba844bc357fa5b4e0d5ace34ad20c855c47419e53bc5f4f9a0164e19d1482b982e524508f9b1698afdf98e7a09b4ac01c04420c855c47419e53bc5f4f9a0164e19d1482b982e524508f9b1698afdf98e7a09b4ad20d5ff496ab0be92d7d746e5984e373aba59814638cddf8f5be41d9500f7bbf297ac2107905e79ce4a7441da4424d63a868c3ddae6a7aec1ba844bc357fa5b4e0d5ace343501aab282e9d0bb6d0c715da5290c9aec9f2e9ca2818d7c6a113e9a6a868a67d42088f255710000000000000000290000000c0000002107c855c47419e53bc5f4f9a0164e19d1482b982e524508f9b1698afdf98e7a09b45502aab282e9d0bb6d0c715da5290c9aec9f2e9ca2818d7c6a113e9a6a868a67d4207f5749648c8670cfe3928ef560a5c431054668468924d6ac0253bb34f3cac4f135eabe8d0000000000000000290000000c0000002107d5ff496ab0be92d7d746e5984e373aba59814638cddf8f5be41d9500f7bbf29735017f5749648c8670cfe3928ef560a5c431054668468924d6ac0253bb34f3cac4f13d4b2b960000000000000000290000000c0000000000 |
725 |
| - |
726 |
| -// new with log on path |
727 |
| -// 70736274ff0100b4010000000176e65d40a648da1a3b9412d5b49cc309a37a6a7f3c9cd8b8f1f41a2fbbfd479f0100000000fdffffff03204e000000000000225120e6e15f7f38c5fe23ae03a15c63298578be23466d5e0e85f43aff010cb029c0f7eb0d1e0000000000225120f66953aa201d3318db72c0660a7823a63f487f6610dd31eb3670b8e1c6cae66f00127a000000000022002037f34405b83128e4cdecb64f44bff64d0d1b6188d2d656782b136e3488eab1f2000000004f010488b21e00000000000000000067b8325a2303718652d085e2bb65e4c84e8a51eaa4f4ea56e11542290bd27875037cb4cea965ae9d7846addc2a534318a377436864f90a38e2619ca51513cf7a7b0488f255714f010488b21e000000000000000000a5d5ff1d68596719baad5a209925b5edfdc7899ca460a071b3c84bd5bc76b99303f9dc3f6f974f2c90c6d0b7b7c50bc4de49bb8105bfa27223babc909720c6191a043d4b2b964f010488b21e000000000000000000dd32781f8dff65567d76ba1c9485014f7eb07d9527a502cbe0dafb64c20961cd028a55ce3f0c98964dfc6814b1b55b2b77cc31d33a5ae1a994476ce8b20b1618530435eabe8d0001012bd36e980000000000225120866e64ab95028afde6e42cd0dcbd6b38f8dec74d3f3a7648e11259f64075321b0103040000000021163024116333a45124af6141080383eea1b756c1983a07d71d50a2c62d774b7b64150088f25571000000000000000029000000000000002116e5a56ea96f692990ef584ebecaa55acf8d7d4e186db4c489e5498210cc2162df15003d4b2b96000000000000000029000000000000000117201263360542e6b356eaf5c4f03b4af4e0693e169ca7c44207209d3bcc2a3b8f620118208dca1a18f7db9002face5d00d8ebe62ecd0b557a6590b6a2f5686890926bdde548fc05424954474f01866e64ab95028afde6e42cd0dcbd6b38f8dec74d3f3a7648e11259f64075321b1263360542e6b356eaf5c4f03b4af4e0693e169ca7c44207209d3bcc2a3b8f6242033024116333a45124af6141080383eea1b756c1983a07d71d50a2c62d774b7b6402e5a56ea96f692990ef584ebecaa55acf8d7d4e186db4c489e5498210cc2162df0048fc05424954474f0437313172754d43724a316a7a417445386353315839657a555a716459464c64356467344565516a4777584c37793261554435737a6659617252777a43586461564120ed892c3b8a6e7435639fadbbfe8753dd23775c7f74c3fe74526c2cd45eefb482580c6632d09e9ce41e0fa1f7cc09ea987684bf1178aad7443b3ac13797122f7e00010520a9acc8f054da7655049fa7d7d0c3edfddc87b51f324c35faa4b1499b3c2a561501068e01c04420cf402ab2e24d3d2e4c64c22be565df5fe0bba1b043ef4d839720bc6e19a83c5dad208e96301de69dd563d9698e847893a15f081328e6514c369b68569798c1f00432ac01c044208e96301de69dd563d9698e847893a15f081328e6514c369b68569798c1f00432ad20a89b6f2100e9c8e328774ce4d4aed2a880aaa4008baa67d8b3e602adf3aa820eac21078e96301de69dd563d9698e847893a15f081328e6514c369b68569798c1f004325502c8549519917a1fe7f2886e89c8b0cf98918dd8c0af661f840489495e509f381858d3b4ae16258aa28955fbe79a158211e7673fb1d0b096b9b5adbbdc5dddaba135eabe8d0000000000000000290000000d0000002107a89b6f2100e9c8e328774ce4d4aed2a880aaa4008baa67d8b3e602adf3aa820e350158d3b4ae16258aa28955fbe79a158211e7673fb1d0b096b9b5adbbdc5dddaba13d4b2b960000000000000000290000000d0000002107cf402ab2e24d3d2e4c64c22be565df5fe0bba1b043ef4d839720bc6e19a83c5d3501c8549519917a1fe7f2886e89c8b0cf98918dd8c0af661f840489495e509f381888f255710000000000000000290000000d0000000000 |
0 commit comments