Skip to main content

Using Core Kit SFA iOS SDK

After successfully installing and initializing SingleFactorAuth, you can use it to authenticate your users and obtain their private and public keys.

The SingleFactorAuth instance natively provides the following functions:

  • getKey() - Returns the torus key using the verifier, verifierId & idToken.



To obtain a user's Torus key using the Web3Auth SFA iOS SDK, you can call the getKey() function.

loginParamsParameters for the login. It takes LoginParams as the value.


public func getKey(loginParams: LoginParams) async throws -> TorusSFAKey


getKey(loginParams: LoginParams)

verifierThe verifier obtained from the Web3Auth Dashboard. It's a mandatory field and takes String as a value.
verifierIdThe verifierId used for the verification. It takes String as a value.
idTokenThe idToken of the user obtained from login provider. It takes String as a value.
subVerifierInfoArray?Sub verifier info. Usually used during aggregate verifier. It takes Array<TorusSubVerifierInfo> as a value.
let loginParams = LoginParams(verifier: "YOUR_VERIFIER_NAME", verifierId: "YOUR_VERIFIER_ID", idToken: "YOUR_ID_TOKEN")
let torusKey = try await singleFactoreAuth.getKey(loginParams: loginParams)

Web3Auth SFA iOS SDK only works for users who have not enabled MFA.

MFA enabled users

For MFA enabled users, you'll see an Error message.


import SingleFactorAuth
import JWTDecode

let jwt = try decode(jwt: id_token)
let result = try await SingleFactorAuth(singleFactorAuthArgs: .init(network: .CYAN)).getKey(loginParams: .init(verifier: "web3auth-firebase-examples", verifierId: jwt.subject ?? "YOUR_VERIFIER_ID", idToken: id_token))

await {
privateKey = result.getPrivateKey()
publicAddress = result.getPublicAddress()

Session Management

We have also included Session Management in this SDK, so calling the initialize function to get the TorusSFAKey value without re-logging in the user if a user has an active session will return the TorusSFAKey struct; otherwise, it will return nil.

if let savedKey = try await singleFactoreAuth.initialize() {