Skip to main content

Register

Create a new privacy-preserving zkID identity.
POST /api/auth/register
Request:
{
  "username": "alice",
  "password": "secure_password_123",
  "identityPublicKey": "base64_public_key",
  "identityPrivateKeyEncrypted": "base64_encrypted",
  "identityPrivateKeyIv": "base64_iv",
  "kdfSalt": "base64_salt",
  "kdfIterations": 200000
}
Response:
{
  "message": "zkID created successfully",
  "user": {
    "id": "uuid",
    "username": "alice",
    "zkId": "did:zk:a7Bk9mX2pQ4r",
    "identityPublicKey": "base64_public_key"
  }
}

Login

Authenticate using zkID credentials.
POST /api/auth/login
Request:
{
  "username": "alice",
  "password": "secure_password_123"
}
Response:
{
  "message": "Login successful",
  "user": {
    "id": "uuid",
    "username": "alice",
    "zkId": "did:zk:a7Bk9mX2pQ4r"
  }
}

Logout

End the current session.
POST /api/auth/logout
Response:
{
  "message": "Logged out successfully"
}

Get Session

Check current authentication status.
GET /api/auth/session
Response (authenticated):
{
  "authenticated": true,
  "user": {
    "id": "uuid",
    "username": "alice",
    "zkId": "did:zk:a7Bk9mX2pQ4r",
    "identityPublicKey": "base64_public_key"
  }
}
Response (not authenticated):
{
  "authenticated": false
}

Upgrade Legacy Account

Upgrade account without zkID to full zkID verification.
POST /api/auth/upgrade-legacy
Request:
{
  "identityPublicKey": "base64_public_key",
  "identityPrivateKeyEncrypted": "base64_encrypted",
  "identityPrivateKeyIv": "base64_iv",
  "kdfSalt": "base64_salt",
  "kdfIterations": 200000
}

Submit Starknet Proof

Submit zkID proof to Starknet for on-chain verification.
POST /api/starknet/submit-proof
Request:
{
  "zkId": "did:zk:a7Bk9mX2pQ4r",
  "publicKey": "base64_public_key",
  "signature": "base64_signature"
}
Response:
{
  "success": true,
  "txHash": "0x123...",
  "contractAddress": "0x456..."
}

Error Codes

CodeDescription
400Username already exists
401Invalid credentials
401Not authenticated
409Proof already exists
500Failed to create zkID