sui-zklogin

Use when implementing zkLogin on SUI — OAuth login (Google, Facebook, Apple, Twitch) with zero-knowledge proofs for privacy-preserving authentication. Triggers on "zkLogin", "social login on SUI", "Google login", "OAuth", "ephemeral keypair", "JWT proof", or any authentication flow that derives a SUI address from an OAuth provider. Also use when the user mentions "login without wallet extension".

Best use case

sui-zklogin is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when implementing zkLogin on SUI — OAuth login (Google, Facebook, Apple, Twitch) with zero-knowledge proofs for privacy-preserving authentication. Triggers on "zkLogin", "social login on SUI", "Google login", "OAuth", "ephemeral keypair", "JWT proof", or any authentication flow that derives a SUI address from an OAuth provider. Also use when the user mentions "login without wallet extension".

Teams using sui-zklogin should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/sui-zklogin/SKILL.md --create-dirs "https://raw.githubusercontent.com/first-mover-tw/sui-dev-agents/main/skills/sui-zklogin/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/sui-zklogin/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How sui-zklogin Compares

Feature / Agentsui-zkloginStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when implementing zkLogin on SUI — OAuth login (Google, Facebook, Apple, Twitch) with zero-knowledge proofs for privacy-preserving authentication. Triggers on "zkLogin", "social login on SUI", "Google login", "OAuth", "ephemeral keypair", "JWT proof", or any authentication flow that derives a SUI address from an OAuth provider. Also use when the user mentions "login without wallet extension".

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# SUI zkLogin Integration

**OAuth-based wallet authentication with zero-knowledge proofs.**

## SDK Versions

Targets: `@mysten/sui` 2.17.0 (^2.0). Tested: 2026-05-21.

**Compatibility notes:** The zklogin API lives at `@mysten/sui/zklogin`. The old `@mysten/zklogin` package is **deprecated and merged into `@mysten/sui`** — if you see `Cannot find module '@mysten/zklogin'`, install only `@mysten/sui@^2`. There is no `ZkLoginProvider` class; the API is functional.

## Overview

zkLogin lets users:
- Log in with Google / Facebook / Twitch / Apple
- No seed phrases — wallet derived from `(iss, aud, sub, salt)`
- ZK proof hides which OAuth user owns which SUI address

## Real API surface (from `@mysten/sui/zklogin`)

```typescript
import {
  generateRandomness,
  generateNonce,
  getExtendedEphemeralPublicKey,
  jwtToAddress,
  computeZkLoginAddress,
  genAddressSeed,
  getZkLoginSignature,
  decodeJwt,
} from '@mysten/sui/zklogin';
```

There is **no** `ZkLoginProvider`, no `.getLoginUrl()`, no `.getProof()`. You drive the OAuth redirect yourself and call Mysten's prover service over HTTP.

## End-to-end flow

```
1. ephemeral keypair (Ed25519) + maxEpoch + randomness  →  nonce
2. redirect to OAuth provider with nonce in `nonce` param
3. receive JWT (id_token)
4. jwt + user salt  →  zkLogin address
5. POST {jwt, extendedEphemeralPublicKey, maxEpoch, jwtRandomness, salt, keyClaimName} → prover → ZK proof
6. sign tx digest with ephemeral keypair
7. getZkLoginSignature({inputs: {...proof, addressSeed}, maxEpoch, userSignature}) → serialized signature
8. submit tx with that signature
```

### Step 1 — nonce + ephemeral keypair

```typescript
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { SuiGrpcClient } from '@mysten/sui/grpc';
import {
  generateNonce,
  generateRandomness,
  getExtendedEphemeralPublicKey,
} from '@mysten/sui/zklogin';

const suiClient = new SuiGrpcClient({
  network: 'devnet',
  baseUrl: 'https://fullnode.devnet.sui.io:443',
});

const ephemeral = Ed25519Keypair.generate();
const { systemState } = await suiClient.core.getCurrentSystemState();
const epoch = systemState.epoch;
const maxEpoch = Number(epoch) + 2;                     // valid for ~2 epochs
const randomness = generateRandomness();                // string
const nonce = generateNonce(ephemeral.getPublicKey(), maxEpoch, randomness);

// Persist these — you need them after the OAuth redirect.
sessionStorage.setItem('zk_ephemeral', ephemeral.getSecretKey());
sessionStorage.setItem('zk_maxEpoch', String(maxEpoch));
sessionStorage.setItem('zk_randomness', randomness);
```

### Step 2 — redirect to OAuth provider

```typescript
// @check:skip
const params = new URLSearchParams({
  client_id: GOOGLE_CLIENT_ID,
  redirect_uri: 'http://localhost:3000/callback',
  response_type: 'id_token',
  scope: 'openid email',
  nonce,                                                 // critical
});
window.location.href =
  `https://accounts.google.com/o/oauth2/v2/auth?${params}`;
```

### Step 3–4 — JWT → address

```typescript
// @check:skip
import { jwtToAddress, decodeJwt } from '@mysten/sui/zklogin';

const jwt = new URLSearchParams(window.location.hash.slice(1)).get('id_token')!;

// Salt should be fetched from your salt service (per-user, secret).
// For demos a fixed salt is fine; production needs per-user salts.
const userSalt = await fetchSaltForUser(jwt);            // string or bigint

const address = jwtToAddress(jwt, userSalt, /*legacy*/ false);
```

### Step 5 — fetch ZK proof from prover

```typescript
// @check:skip
const ephemeral = Ed25519Keypair.fromSecretKey(
  sessionStorage.getItem('zk_ephemeral')!,
);
const maxEpoch = Number(sessionStorage.getItem('zk_maxEpoch'));
const randomness = sessionStorage.getItem('zk_randomness')!;

const extendedEphemeralPublicKey = getExtendedEphemeralPublicKey(
  ephemeral.getPublicKey(),
);

const proofRes = await fetch('https://prover-dev.mystenlabs.com/v1', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    jwt,
    extendedEphemeralPublicKey,
    maxEpoch,
    jwtRandomness: randomness,
    salt: userSalt,
    keyClaimName: 'sub',
  }),
});
const partialZkLoginSignature = await proofRes.json();
// → { proofPoints, issBase64Details, headerBase64 }
```

### Step 6–7 — sign + assemble zkLogin signature

```typescript
// @check:skip
import { Transaction } from '@mysten/sui/transactions';
import { genAddressSeed, getZkLoginSignature } from '@mysten/sui/zklogin';
import { decodeJwt } from '@mysten/sui/zklogin';

const tx = new Transaction();
tx.setSender(address);
// ...tx.moveCall(...) etc.

const { bytes, signature: userSignature } =
  await tx.sign({ client: suiClient, signer: ephemeral });

const decoded = decodeJwt(jwt);
const addressSeed = genAddressSeed(
  BigInt(userSalt),
  'sub',
  decoded.sub!,
  decoded.aud as string,
).toString();

const zkLoginSignature = getZkLoginSignature({
  inputs: { ...partialZkLoginSignature, addressSeed },
  maxEpoch,
  userSignature,
});

const result = await suiClient.core.executeTransaction({
  transaction: bytes,
  signature: zkLoginSignature,
});
```

## Move contract support

No special Move code is needed. zkLogin addresses are regular SUI addresses — `tx_context::sender(ctx)` returns them like any other.

```move
public fun create_profile(name: String, ctx: &mut TxContext) {
    let user = tx_context::sender(ctx);  // works with zkLogin
    // ...
}
```

## Security considerations

- Keep OAuth client secrets server-side; use PKCE / implicit flow for SPAs.
- Always validate JWT signature server-side before trusting it for high-value ops.
- Generate a fresh `randomness` (and therefore nonce) per login attempt.
- Persist the ephemeral key only for its short lifetime; rotate when `maxEpoch` passes.
- User salt is sensitive — leaking it links the OAuth identity to the on-chain address. Store server-side per user.

## Common Mistakes

**`import { ZkLoginProvider } from '@mysten/zklogin'` — both the symbol and the package are wrong.**
- Install `@mysten/sui@^2`, import from `@mysten/sui/zklogin`, use the functional API above.

**Skipping `extendedEphemeralPublicKey` when calling the prover.**
- The prover requires the *extended* public key; pass `getExtendedEphemeralPublicKey(ephemeral.getPublicKey())`, not the raw key.

**Using `jwt.sub` directly as `addressSeed`.**
- The seed is `genAddressSeed(salt, 'sub', sub, aud)` — a Poseidon hash. Using the raw sub gives the wrong address.

**Forgetting to call `tx.setSender(address)` before signing.**
- The ephemeral keypair signs *for* the zkLogin address. If sender isn't set to the zkLogin address, the signature won't verify on-chain.

**Reusing `maxEpoch` past expiry.**
- Once the current epoch exceeds `maxEpoch`, every signature fails. Refresh the ephemeral key + nonce + JWT.

## Resources

- [zkLogin docs (Sui)](https://docs.sui.io/concepts/cryptography/zklogin)
- [Mysten Prover service](https://docs.sui.io/guides/developer/cryptography/zklogin-integration)
- API source: `@mysten/sui/zklogin`

Related Skills

sui-walrus

7
from first-mover-tw/sui-dev-agents

Use when storing or retrieving files using Walrus — SUI's decentralized blob storage. Triggers on "Walrus", "blob storage", "upload file to chain", "decentralized storage", "store NFT image", "IPFS alternative on SUI", "where to store NFT metadata", "host a site on-chain", or any off-chain data storage needs on SUI. Also use for Walrus Sites (decentralized web hosting), storing game assets, media files, or when the user asks "where do I put large files on SUI".

sui-wallet

7
from first-mover-tw/sui-dev-agents

Use when performing on-chain transactions (transfer, Move call, publish) through the agent's CLI wallet via MCP tools. Triggers on "transfer SUI", "call Move function", "publish package", "wallet status", "sign transaction", or any agent-driven on-chain operation. This is for headless/backend wallet operations — for browser wallet UI (React/Vue), use sui-frontend instead.

sui-tester

7
from first-mover-tw/sui-dev-agents

Use when writing Move tests, setting up test suites, running gas benchmarks, or planning test strategy for SUI contracts. Triggers on "write tests", "test this module", "#[test]", "test coverage", "gas benchmark", "property-based test", or any Move testing task. Use even for simple "how do I test this function" questions.

sui-suins

7
from first-mover-tw/sui-dev-agents

Use when integrating SuiNS (SUI Name Service) — resolving .sui names to addresses, reverse lookups, or registering names. Triggers on "SuiNS", ".sui name", "name resolution", "reverse lookup", "human-readable address", or any name service integration. Also use when the user wants to display user-friendly names instead of hex addresses.

sui-security-guard

7
from first-mover-tw/sui-dev-agents

Use when setting up security scanning, detecting leaked secrets/API keys, implementing pre-commit hooks, or auditing a Sui Move contract for security/architecture/quality issues. Triggers on "security scan", "detect secrets", "pre-commit hook", "security audit setup", "API key leaked", and on contract-level review requests like "audit this contract", "review access control", "is this Move safe", "check for vulnerabilities", "Move security review" — these load the SEC/DES/PAT/TST/QA/CFG finding registry in references/move-security-findings.md. For offensive/adversarial testing (attack vector discovery, writing exploits/PoCs), use sui-red-team instead. For Move style/idiom quality (non-security), use move-code-quality.

sui-seal

7
from first-mover-tw/sui-dev-agents

Use when implementing data encryption, access control, or secrets management on SUI using the Seal protocol. Triggers on threshold encryption, data privacy, token-gated content, encrypted storage, decryption policies, paywall, gated access, encrypted NFT metadata, private data sharing, or any scenario requiring on-chain access control for off-chain data. Also use when the user mentions Seal, pay-to-decrypt, "only NFT holders can see", or subscriber-only content on SUI.

sui-red-team

7
from first-mover-tw/sui-dev-agents

Use when performing adversarial security testing on SUI Move contracts — generating attack tests for access control bypass, integer overflow, object manipulation, economic exploits, reentrancy, and DoS vectors. Triggers on "red team", "attack test", "find vulnerabilities", "exploit", "pentest", "security test", or when the user wants to stress-test their contract's security. For defensive security setup (scanning, hooks, checklists), use sui-security-guard instead.

sui-passkey

7
from first-mover-tw/sui-dev-agents

Use when implementing WebAuthn passkeys or biometric authentication (Face ID, fingerprint, hardware keys) on SUI. Triggers on "passkey", "WebAuthn", "biometric login", "Face ID", "fingerprint auth", "FIDO2", or passwordless auth that uses device authenticators instead of seed phrases. Different from zkLogin (which uses OAuth providers).

sui-nautilus

7
from first-mover-tw/sui-dev-agents

Use when building verifiable off-chain computation, integrating external APIs with on-chain proof, or running trusted execution environments on SUI. Triggers on Nautilus, off-chain oracle, "verify API data on-chain", "connect external API to Move", "prove off-chain result", trusted compute, AWS Nitro Enclave, attestation, price feed, weather data on-chain, or any scenario requiring cryptographically verified external data. Also use when the user asks "how do I get real-world data into my SUI contract" or needs an oracle-like pattern.

sui-kiosk

7
from first-mover-tw/sui-dev-agents

Use when building NFT marketplaces, enforcing royalties, or managing transfer policies using SUI's Kiosk standard. Triggers on "Kiosk", "NFT marketplace", "transfer policy", "royalty enforcement", "list NFT for sale", "purchase rules", or any NFT commerce on SUI. Also use when the user asks about listing, delisting, or trading NFTs with enforced rules.

sui-install

7
from first-mover-tw/sui-dev-agents

Use when installing or updating the Sui CLI, managing CLI versions with suiup, or resolving environment/setup problems — "install sui", "update sui", "command not found", "sui not found", "client/server api version mismatch", build errors about "old dependencies", switching CLI versions per network, or installing toolchain components (Walrus, MVR, Move Analyzer, site-builder). Also use for first-time client setup, getting faucet tokens, recovering keys from a phrase, or "Cannot find gas coin for signer address". For deploying/upgrading packages use sui-deployer; for on-chain data queries use sui-ts-sdk.

sui-indexer

7
from first-mover-tw/sui-dev-agents

Use when building custom indexers, data pipelines, or event processors for the SUI blockchain. Triggers on "indexer", "data pipeline", "backfill", "event processor", "index transactions", "analytics dashboard", "aggregate on-chain data", "historical query", "track all trades", or any custom data extraction from SUI chain history. Also use when the user needs to build dashboards from on-chain data, process historical transactions, or set up real-time event streams.