Contract 34e19cdaad68669489e8f3e9c5e7b469f8448d3dddd2a7d130c30c926eee30af

← Back to Index 📥 Download WASM

Meta

rssdkver 25.1.0#86c50a1ea4f87b40add3064ff9df95c7553565c5
rsver 1.91.1

Instances

  • CA2FI6WKXIENCZIX7ZFQ5SN3HXKONZLK6E35C6I2ZOUPVAYBCJXKUHLF
  • CAKRQVMFPV5OIZCH47ZCNVOVWGSDYFGY5HUWXPIN3OGJLIK7OFYCJDMR
  • CAU7NET7FXSFBBRMLM6X7CJMVAIHMG7RC4YPCXG6G4YOYG6C3CVGR25M
  • CDUZM6OICZDLHZY6PHBEGFD4VOMIACY7DTTDKV3XYW6AZZGTY7DTSS2S

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>

Update the verification key (e.g. after circuit changes). Admin only.

fn set_vkey(
    env: soroban_sdk::Env,
    vkey: VerificationKey,
) -> 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

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) ▶