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:
proof_a - G1 point A from Groth16 proofproof_b - G2 point B from Groth16 proofproof_c - G1 point C from Groth16 proofrequest - Authorization request with commitment and nullifierAuthorizationResult on successNotInitialized - Contract not initializedNullifierAlreadyUsed - Replay attack preventedInvalidProof - Groth16 verification failedfn 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 that will control admin functions and upgradesconfig - Configuration containing server pubkey and contract addressesAlreadyInitialized - If contract was already initializedfn 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.
commitment - The commitment to checkmerkle_proof - Merkle proof of membershipleaf_index - Index of the leaf in the treetrue 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>