@@ -890,7 +890,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
890890 } ;
891891 }
892892
893- public async signECDSA ( data : Uint8Array , opts ?: { hashed ?: boolean ; secp256k1Precompute ?: Secp256k1PrecomputedClient } ) {
893+ public async sign_ECDSA_secp256k1 ( data : Uint8Array , opts ?: { hashed ?: boolean ; secp256k1Precompute ?: Secp256k1PrecomputedClient } ) {
894894 if ( ! this . supportedCurveKeyTypes . has ( KeyType . secp256k1 ) ) {
895895 throw CoreKitError . default ( `secp256k1 KeyTYpe is not supported, please configure secp256k1 curve key type ` ) ;
896896 }
@@ -899,8 +899,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
899899 }
900900 const { hashed = false , secp256k1Precompute } = opts || { } ;
901901
902- // TODO: replace buffer to uint8array
903- const sig = await this . sign_ECDSA_secp256k1 ( Buffer . from ( data ) , hashed , secp256k1Precompute ) ;
902+ const sig = await this . _sign_ECDSA_secp256k1 ( Buffer . from ( data ) , hashed , secp256k1Precompute ) ;
904903 return Buffer . concat ( [ sig . r , sig . s , Buffer . from ( [ sig . v ] ) ] ) ;
905904 }
906905
@@ -946,7 +945,6 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
946945 }
947946
948947 // mutation function
949-
950948 async deleteFactor ( factorPub : Point , factorKey ?: BNString ) : Promise < void > {
951949 if ( ! this . state . factorKey ) {
952950 throw CoreKitError . factorKeyNotPresent ( "factorKey not present in state when deleting a factor." ) ;
@@ -1177,9 +1175,11 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
11771175 if ( keyType === KeyType . ed25519 ) {
11781176 const k = generateEd25519Seed ( ) ;
11791177 importKey . ed25519 = k . toString ( "hex" ) ;
1180- } else if ( keyType === KeyType . secp256k1 && ! ! this . options . useClientGeneratedTSSKey ) {
1181- const k = secp256k1 . genKeyPair ( ) . getPrivate ( ) ;
1182- importKey . secp256k1 = scalarBNToBufferSEC1 ( k ) . toString ( "hex" ) ;
1178+ } else if ( keyType === KeyType . secp256k1 ) {
1179+ if ( this . options . useClientGeneratedTSSKey ) {
1180+ const k = secp256k1 . genKeyPair ( ) . getPrivate ( ) ;
1181+ importKey . secp256k1 = scalarBNToBufferSEC1 ( k ) . toString ( "hex" ) ;
1182+ }
11831183 } else {
11841184 throw CoreKitError . default ( `Unsupported key type and sig type combination ` ) ;
11851185 }
@@ -1648,7 +1648,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
16481648 return this . tkey . computeAccountNonce ( this . state . accountIndex ) ;
16491649 }
16501650
1651- private async sign_ECDSA_secp256k1 ( data : Buffer , hashed : boolean = false , precomputedTssClient ?: Secp256k1PrecomputedClient ) {
1651+ private async _sign_ECDSA_secp256k1 ( data : Buffer , hashed : boolean = false , precomputedTssClient ?: Secp256k1PrecomputedClient ) {
16521652 const executeSign = async ( client : Client , serverCoeffs : Record < string , string > , hashedData : Buffer , signatures : string [ ] ) => {
16531653 const { r, s, recoveryParam } = await client . sign ( hashedData . toString ( "base64" ) , true , "" , "keccak256" , {
16541654 signatures,
0 commit comments