Contract a51e7e68062ead67c3517d4010807b32f431a07fdae52de25bf9bdd748f80843

← Back to Index 📥 Download WASM

Meta

rssdkver 25.1.1#94c2a3b3a5ded6b9cf9cef0c207bf8804f3eb294
rsver 1.91.1

Instances

  • CBL56YT4DIIY76OHBT5DOJMGSH67ZA3Y2RKP43UDXA6QAWHEMQZTSHTB

Interface

Upgrade this contract to a new WASM (admin only).

fn upgrade(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), GmailAuthError>

Authorize a user with a Gmail ZK proof.

This is the main entry point for proving Gmail ownership. The user provides a Groth16 proof that demonstrates:

  1. They have a valid server attestation (semi-trusted mode)
  2. The attestation is recent (within 24 hours)
  3. The commitment correctly hides their gmail hash
  4. The nullifier is correctly derived

Arguments

  • proof_a - G1 point A from Groth16 proof
  • proof_b - G2 point B from Groth16 proof
  • proof_c - G1 point C from Groth16 proof
  • request - Authorization request with commitment and nullifier

Returns

  • AuthorizationResult on success

Errors

  • NotInitialized - Contract not initialized
  • NullifierAlreadyUsed - Replay attack prevented
  • InvalidProof - Groth16 verification failed
fn authorize(
    env: soroban_sdk::Env,
    proof_a: soroban_sdk::BytesN<64>,
    proof_b: soroban_sdk::BytesN<128>,
    proof_c: soroban_sdk::BytesN<64>,
    request: AuthorizationRequest,
) -> Result

Get the current configuration.

fn get_config(env: soroban_sdk::Env) -> Result

Initialize the Gmail Auth contract.

Must be called once after deployment to set up:

  • Admin address (the deployer/owner)
  • Server's EdDSA public key for attestation verification
  • References to groth16-verifier and merkle-tree contracts

Arguments

  • admin - Address that will control admin functions and upgrades
  • config - Configuration containing server pubkey and contract addresses

Errors

  • AlreadyInitialized - If contract was already initialized
fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    config: GmailAuthConfig,
) -> Result<(), GmailAuthError>

Authorize with raw proof bytes (alternative interface).

Some clients may prefer to pass the proof as a single blob.

fn authorize_raw(
    env: soroban_sdk::Env,
    proof_bytes: soroban_sdk::BytesN<256>,
    commitment: soroban_sdk::U256,
    nullifier_hash: soroban_sdk::U256,
    timestamp: u64,
    max_attestation_age: u64,
    server_pub_commitment: soroban_sdk::U256,
) -> Result

Check if a commitment is authorized (exists in merkle tree).

This is used by dApps to verify a user's Gmail authorization status.

Arguments

  • commitment - The commitment to check
  • merkle_proof - Merkle proof of membership
  • leaf_index - Index of the leaf in the tree

Returns

true if the commitment is in the authorized set

fn is_authorized(
    env: soroban_sdk::Env,
    commitment: soroban_sdk::U256,
    merkle_proof: soroban_sdk::Vec,
    leaf_index: u32,
) -> Result

Get the total number of successful authorizations.

fn get_auth_count(env: soroban_sdk::Env) -> u64

Check if contract is initialized.

fn is_initialized(env: soroban_sdk::Env) -> bool

Transfer admin role to a new address.

fn transfer_admin(
    env: soroban_sdk::Env,
    current_admin: soroban_sdk::Address,
    new_admin: soroban_sdk::Address,
) -> Result<(), GmailAuthError>

Get the server's public key.

fn get_server_pubkey(
    env: soroban_sdk::Env,
) -> Result, GmailAuthError>

Check if a nullifier has already been used.

Returns true if the nullifier was used in a previous authorization, preventing replay attacks.

fn is_nullifier_used(env: soroban_sdk::Env, nullifier_hash: soroban_sdk::U256) -> bool

Get the current merkle root of authorized commitments.

fn get_authorized_root(
    env: soroban_sdk::Env,
) -> Result

Mark a nullifier as used (admin only, for recovery scenarios).

This should only be used in exceptional circumstances.

fn mark_nullifier_used(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    nullifier_hash: soroban_sdk::U256,
) -> Result<(), GmailAuthError>

Update the server's EdDSA public key (admin only).

Use this to rotate the attestation signing key.

fn update_server_pubkey(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    new_pubkey: soroban_sdk::BytesN<64>,
) -> Result<(), GmailAuthError>

Imports

WebAssembly Text (WAT) ▶