@@ -2,7 +2,7 @@ import * as assert from 'assert';
22import * as sinon from 'sinon' ;
33import * as pgp from 'openpgp' ;
44import { randomBytes } from 'crypto' ;
5- import { deriveUnhardenedMps , EddsaMPSDsg , MPSComms , MPSTypes , MPSUtil } from '@bitgo/sdk-lib-mpc' ;
5+ import { EddsaMPSDsg , MPSComms , MPSTypes , MPSUtil } from '@bitgo/sdk-lib-mpc' ;
66import { ed25519 } from '@noble/curves/ed25519' ;
77import * as sjcl from '@bitgo/sjcl' ;
88import {
@@ -34,6 +34,7 @@ import {
3434 verifyPeerMessageRoundOne ,
3535 verifyPeerMessageRoundTwo ,
3636} from '../../../../../../src/bitgo/tss/eddsa/eddsaMPCv2' ;
37+ import { getInitializedMpcInstance } from '../../../../../../src/bitgo/tss/eddsa/eddsa' ;
3738import { getBitgoSignatureShare } from '../../../../../../src/bitgo/tss/common' ;
3839import { decodeWithCodec } from '../../../../../../src/bitgo/utils/codecs' ;
3940import { generateGPGKeyPair } from '../../../../../../src/bitgo/utils/opengpgUtils' ;
@@ -1792,13 +1793,14 @@ describe('signRecoveryEddsaMPCv2', () => {
17921793
17931794 assert . strictEqual ( signature . length , 64 ) ;
17941795
1795- const derivedKeychain = deriveUnhardenedMps ( commonKeyChain , derivationPath ) ;
1796+ const mpc = await getInitializedMpcInstance ( ) ;
1797+ const derivedKeychain = mpc . deriveUnhardened ( commonKeyChain , derivationPath ) ;
17961798 const publicKeyBytes = Buffer . from ( derivedKeychain . slice ( 0 , 64 ) , 'hex' ) ;
17971799 const ok = ed25519 . verify ( new Uint8Array ( signature ) , new Uint8Array ( message ) , new Uint8Array ( publicKeyBytes ) ) ;
17981800 assert . strictEqual ( ok , true ) ;
17991801 } ) ;
18001802
1801- it ( 'should throw when the signed message is different from the verified message' , async ( ) => {
1803+ it ( 'should return false when verifying the signature against a different message' , async ( ) => {
18021804 const [ userDkg , backupDkg ] = await MPSUtil . generateEdDsaDKGKeyShares ( ) ;
18031805 const message = Buffer . from ( 'deadbeef' , 'hex' ) ;
18041806 const commonKeyChain = userDkg . getCommonKeychain ( ) ;
@@ -1812,7 +1814,8 @@ describe('signRecoveryEddsaMPCv2', () => {
18121814 ) ;
18131815
18141816 const differentMessage = Buffer . from ( 'cafebabe' , 'hex' ) ;
1815- const derivedKeychain = deriveUnhardenedMps ( commonKeyChain , derivationPath ) ;
1817+ const mpc = await getInitializedMpcInstance ( ) ;
1818+ const derivedKeychain = mpc . deriveUnhardened ( commonKeyChain , derivationPath ) ;
18161819 const publicKeyBytes = Buffer . from ( derivedKeychain . slice ( 0 , 64 ) , 'hex' ) ;
18171820 const ok = ed25519 . verify (
18181821 new Uint8Array ( signature ) ,
@@ -1828,13 +1831,14 @@ describe('signRecoveryEddsaMPCv2', () => {
18281831 const message = Buffer . from ( 'deadbeef' , 'hex' ) ;
18291832
18301833 await assert . rejects (
1831- EDDSAUtils . signRecoveryEddsaMPCv2 (
1832- message ,
1833- derivationPath ,
1834- userDkg . getKeyShare ( ) ,
1835- backupDkg . getKeyShare ( ) ,
1836- wrongDkg . getCommonKeychain ( ) // key chain from a different wallet
1837- ) ,
1834+ ( ) =>
1835+ EDDSAUtils . signRecoveryEddsaMPCv2 (
1836+ message ,
1837+ derivationPath ,
1838+ userDkg . getKeyShare ( ) ,
1839+ backupDkg . getKeyShare ( ) ,
1840+ wrongDkg . getCommonKeychain ( ) // key chain from a different wallet
1841+ ) ,
18381842 / E d D S A M P C v 2 r e c o v e r y s i g n a t u r e v e r i f i c a t i o n f a i l e d /
18391843 ) ;
18401844 } ) ;
0 commit comments