ZKAuth is a zero-knowledge proof-based crypto wallet, controlled by your google, apple, twitter or facebook account, using ZK-Snarks to verify your identity without revealing any personal information on-chain.
npm install @cryptokass/zkauth-sdk
import { ZKAuth } from "@cryptokass/zkauth-sdk";
const zkauth = new ZKAuth({
name: "My Awesome App",
url: "https://example.com",
icon: "https://example.com/icon.png",
});
zkauth.connect()
will open a popup displaying login options. Upon successful login, it will return the wallet address.
const walletAddress = await zkauth.connect();
zkauth.reconnect()
will attempt to use the same wallet as the last connection. If the user is not connected, it will prompt the user to connect.
Alternatively, you can connect directly with a given provider:
const walletAddress = await zkauth.reconnect("google");
zkauth.disconnect();
Will disconnect the currently connected user.
const txHash = await zkauth.sendTransaction({
to: "0x123...",
value: 1000000000000000000, // value in wei
});
zkauth.connected()
will return true if the user is connected, false otherwise.
const isConnected = zkauth.connected();
zkauth.currentUser()
will return the currently connected user, or null if the user is not connected.
const walletAddress = zkauth.currentUser();
The SDK interacts with the ZKAuth gateway, which prompts users to login with their provider of choice, produces required ZK proofs, and creates/retrieves a users ZKAuth smart contract wallet, on all supported networks.
The SDK requires popup windows to be enabled for the domain of the DApp, as it communicates with the gateway via the PostMessage API.
- The user clicks the connect button, which calls
zkauth.connect()
. - The SDK opens a popup prompting the user to select their login method. The gateway also creates/loads a local ephemeral key for temporary use with the smart wallet. It forwards the user to the OUAuth login page.
- The Gateway receives the users OAuth JWT from the trusted provider for processing.
- The Gateway infers the users smart wallet address from the JWT and returns it instantly to the SDK for display/use.
- The Gateway service triggers the wallet setup, if the smart wallet does not exist or the ephemeral key is not registered. The background service manages this setup, handling any failures and retries.
- The background runner service forwards the request to a high-performance, secure zk-SNARK proving system which generates proofs for our Zero Knowledge Proof Circuits.
- With the proofs generated, the background service creates the smart wallet on the desired network, and registers the ephemeral key.
- ✅ ZK Auth Login with Google – Basic implementation.
- ❌ Viem Bindings – We need to create a wrapper that works with viem.
- ❌ Ethers Bindings – We need to create a wrapper that works with ethers.