Contract 25a8feed629782213d9faf537c211e87a9ca51612cc54bf1d2c0716b9968da0e

← Back to Index 📥 Download WASM

Meta

rssdkver 25.1.0#86c50a1ea4f87b40add3064ff9df95c7553565c5
rsver 1.91.1

Instances

  • CAU7NET7FXSFBBRMLM6X7CJMVAIHMG7RC4YPCXG6G4YOYG6C3CVGR25M

Interface

Upgrade the contract to a new WASM hash. Only callable by admin.

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

Change the admin address. Admin only.

fn set_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), TierVerifierError>

Initialize the contract with an admin address and verification key.

fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    vkey: VerificationKey,
) -> Result<(), TierVerifierError>

Legacy attestation for backwards compatibility during migration. Stores attestation with proof hash for off-chain verification. Will be deprecated once all clients upgrade to verify_and_attest.

fn attest_tier(
    env: soroban_sdk::Env,
    farmer: soroban_sdk::Address,
    tier: u32,
    commitment: soroban_sdk::BytesN<32>,
    proof_hash: soroban_sdk::BytesN<32>,
) -> Result

Update the verification key. Admin only. This allows changing the circuit parameters without redeploying.

fn update_vkey(
    env: soroban_sdk::Env,
    vkey: VerificationKey,
) -> Result<(), TierVerifierError>

Generic Groth16 verification logic. Can be used by other contracts or callers to verify ANY BN254 proof.

fn verify_groth16(
    env: soroban_sdk::Env,
    public_inputs: soroban_sdk::Vec>,
    proof: Groth16Proof,
) -> Result

Lookup a farmer's tier attestation.

fn get_attestation(
    env: soroban_sdk::Env,
    farmer: soroban_sdk::Address,
) -> Option

Verify a Groth16 proof and store the tier attestation on-chain.

This performs the full Groth16 pairing check: e(pi_a, pi_b) == e(alpha, beta) * e(vk_x, gamma) * e(pi_c, delta)

Which is equivalent to checking: e(-pi_a, pi_b) * e(alpha, beta) * e(vk_x, gamma) * e(pi_c, delta) == 1

Where vk_x = IC[0] + sum(pub_input[i] * IC[i+1])

Arguments

  • farmer - Address of the farmer (requires auth)
  • tier - Claimed tier (0-3, public input to circuit)
  • commitment - Poseidon commitment (public input to circuit)
  • proof - The Groth16 proof (pi_a, pi_b, pi_c)
fn verify_and_attest(
    env: soroban_sdk::Env,
    farmer: soroban_sdk::Address,
    tier: u32,
    commitment: soroban_sdk::BytesN<32>,
    proof: Groth16Proof,
) -> Result

Imports

WebAssembly Text (WAT) ▶