@@ -482,12 +482,12 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
482482 throw CoreKitError . invalidConfig ( "Cannot import TSS key and register SFA key at the same time." ) ;
483483 }
484484
485- const fisrtKeyType = this . getSupportedCurveKeyTypes ( ) [ 0 ] ;
485+ const firstKeyType = this . getSupportedCurveKeyTypes ( ) [ 0 ] ;
486486 try {
487487 // prefetch tss pub keys.
488488 const prefetchTssPubs = [ ] ;
489489 for ( let i = 0 ; i < prefetchTssPublicKeys ; i ++ ) {
490- prefetchTssPubs . push ( this . torusSp . getTSSPubKey ( this . tkey . tssTag , i , fisrtKeyType ) ) ;
490+ prefetchTssPubs . push ( this . torusSp . getTSSPubKey ( this . tkey . tssTag , i , firstKeyType ) ) ;
491491 }
492492
493493 // get postbox key.
@@ -519,7 +519,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
519519 const existingSFAKey = loginResponse . finalKeyData . privKey . padStart ( 64 , "0" ) ;
520520
521521 await this . setupTkey ( {
522- providedImportKey : { [ fisrtKeyType ] : existingSFAKey } ,
522+ providedImportKey : { [ firstKeyType ] : existingSFAKey } ,
523523 importingSFAKey : true ,
524524 sfaLoginResponse : loginResponse ,
525525 userInfo : { ...parseToken ( idToken ) , verifier, verifierId } ,
@@ -778,7 +778,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
778778 }
779779
780780 const tssCurve = getKeyCurve ( KeyType . ed25519 ) ;
781- // ed25519 only support account index 0 ?
781+ if ( this . state . accountIndex !== 0 ) throw CoreKitError . default ( "Ed25519 only support account index 0" ) ;
782782 const p = this . getPubKeyPoint ( KeyType . ed25519 , 0 ) . toEllipticPoint ( tssCurve ) ;
783783 return ed25519 ( ) . keyFromPublic ( p ) . getPublic ( ) ;
784784 }
@@ -1084,9 +1084,10 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
10841084 *
10851085 * Exports the private key scalar for the current account index.
10861086 *
1087+ * @param keyType - export final tsskey of designated keyType
1088+ *
10871089 * For signature type ed25519, consider using _UNSAFE_exportTssEd25519Seed.
10881090 */
1089- // TODO : should return all keyType final keys?
10901091 public async _UNSAFE_exportTssKey ( keyType : KeyType ) : Promise < string > {
10911092 if ( ! this . state . factorKey ) {
10921093 throw CoreKitError . factorKeyNotPresent ( "factorKey not present in state when exporting tss key." ) ;
@@ -1170,14 +1171,13 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
11701171 const existingUser = await this . isMetadataPresent ( this . state . postBoxKey ) ;
11711172 const importKey = providedImportKey ?? { } ;
11721173 if ( ! existingUser ) {
1173- // if (!importKey && this.useClientGeneratedTSSKey) {
11741174 const keyTypes = this . getSupportedCurveKeyTypes ( ) ;
11751175 for ( const keyType of keyTypes ) {
11761176 if ( ! importKey [ keyType ] ) {
11771177 if ( keyType === KeyType . ed25519 ) {
11781178 const k = generateEd25519Seed ( ) ;
11791179 importKey . ed25519 = k . toString ( "hex" ) ;
1180- } else if ( keyType === KeyType . secp256k1 ) {
1180+ } else if ( keyType === KeyType . secp256k1 && ! ! this . options . useClientGeneratedTSSKey ) {
11811181 const k = secp256k1 . genKeyPair ( ) . getPrivate ( ) ;
11821182 importKey . secp256k1 = scalarBNToBufferSEC1 ( k ) . toString ( "hex" ) ;
11831183 } else {
0 commit comments