diff --git a/Sources/TorusUtils/Helpers/NodeUtils.swift b/Sources/TorusUtils/Helpers/NodeUtils.swift index c72d51dd..00bd8fb6 100644 --- a/Sources/TorusUtils/Helpers/NodeUtils.swift +++ b/Sources/TorusUtils/Helpers/NodeUtils.swift @@ -534,12 +534,14 @@ internal class NodeUtils { } else { typeOfUser = .v2 let oAuthPubKey = KeyUtils.getPublicKeyFromCoords(pubKeyX: oAuthPublicKeyX, pubKeyY: oAuthPublicKeyY) + finalPubKey = oAuthPubKey if thresholdNonceData!.pubNonce != nil { - let publicNonce = KeyUtils.getPublicKeyFromCoords(pubKeyX: thresholdNonceData!.pubNonce!.x, pubKeyY: thresholdNonceData!.pubNonce!.y) - finalPubKey = try KeyUtils.combinePublicKeys(keys: [oAuthPubKey, publicNonce]) - pubNonce = PubNonce(x: thresholdNonceData!.pubNonce!.x, y: thresholdNonceData!.pubNonce!.y) - } else { - finalPubKey = oAuthPubKey + let pubNonceKey = thresholdNonceData!.pubNonce! + if !(pubNonceKey.x.isEmpty || pubNonceKey.y.isEmpty) { + let publicNonce = KeyUtils.getPublicKeyFromCoords(pubKeyX: pubNonceKey.x, pubKeyY: pubNonceKey.y) + finalPubKey = try KeyUtils.combinePublicKeys(keys: [oAuthPubKey, publicNonce]) + pubNonce = PubNonce(x: thresholdNonceData!.pubNonce!.x, y: thresholdNonceData!.pubNonce!.y) + } } } diff --git a/Sources/TorusUtils/TorusUtils.swift b/Sources/TorusUtils/TorusUtils.swift index 0e3201e6..80cdbbd9 100644 --- a/Sources/TorusUtils/TorusUtils.swift +++ b/Sources/TorusUtils/TorusUtils.swift @@ -242,12 +242,17 @@ public class TorusUtils { let legacyResult = LegacyVerifierLookupResponse(keys: legacyKeysResult, serverTimeOffset: String(finalServerTimeOffset)) return try await formatLegacyPublicKeyData(finalKeyResult: legacyResult, enableOneKey: enableOneKey, isNewKey: keyAssignResult.keyResult!.is_new_key, serverTimeOffset: finalServerTimeOffset) } else { - let pubNonceResult = keyAssignResult.nonceResult!.pubNonce! let (X, Y) = try KeyUtils.getPublicKeyCoords(pubKey: pubKey) oAuthPubKey = KeyUtils.getPublicKeyFromCoords(pubKeyX: X, pubKeyY: Y) - let pubNonceKey = KeyUtils.getPublicKeyFromCoords(pubKeyX: pubNonceResult.x, pubKeyY: pubNonceResult.y) - finalPubKey = try KeyUtils.combinePublicKeys(keys: [oAuthPubKey!, pubNonceKey]) - pubNonce = pubNonceResult + finalPubKey = oAuthPubKey! + if keyAssignResult.nonceResult!.pubNonce != nil { + let pubNonceResult = keyAssignResult.nonceResult!.pubNonce! + if !(pubNonceResult.x.isEmpty || pubNonceResult.y.isEmpty) { + let pubNonceKey = KeyUtils.getPublicKeyFromCoords(pubKeyX: pubNonceResult.x, pubKeyY: pubNonceResult.y) + finalPubKey = try KeyUtils.combinePublicKeys(keys: [oAuthPubKey!, pubNonceKey]) + pubNonce = pubNonceResult + } + } } if oAuthPubKey == nil || finalPubKey == nil {