moon-zk

    Pure-MoonBit BN254 optimal Ate bilinear pairing, R1CS/QAP/FFT, Groth16 zk-SNARK prover & verifier with snarkjs/EIP-197 interoperability and zero-upload browser studio

    zk
    zk-snark
    groth16
    bn254
    pairing
    cryptography
    Download zip
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    1 hour ago
    Downloads
    3

    #moon-zk

    Pure-MoonBit BN254 (alt_bn128) Optimal Ate bilinear pairing, R1CS / QAP / Radix-2 Coset FFT, and Groth16 zk-SNARK prover & verifier with zero external dependencies in the root library, full bidirectional snarkjs JSON interoperability, Ethereum EIP-196 / EIP-197 precompile compatibility, native SVG visualization, and a zero-upload browser studio.

    • Live Browser Studio: https://sam-hui-dot.github.io/moon-zk/
    • Mooncakes Package: Sam-Hui-dot/moon-zk@0.1.0
    • License: Apache-2.0

    #Architecture

    LayerModulesHighlights
    256-bit Montgomery Field Arithmeticu256.mbt, fp.mbt, fr.mbt4-limb UInt64 CIOS Montgomery multiplication, canonical < p / < r validation, -th primitive roots of unity in
    Tower Extensionsfq2.mbt, fq6.mbt, fq12.mbt Karatsuba arithmetic, sparse mul_by_034, Granger-Scott cyclotomic_square, Frobenius maps
    BN254 Groups & Pairingg1.mbt, g2.mbt, pairing.mbtJacobian projective arithmetic, Pippenger MSM (g1_msm, g2_msm), strict prime-order subgroup check, Optimal Ate pairing with shared final exponentiation, EIP-196/197 wire codecs
    R1CS / QAP / Groth16r1cs.mbt, fft.mbt, groth16.mbt5 built-in circuits (cubic, factor, mimc7, merkle_mimc, range8), Coset FFT quotient , full Groth16 setup / prove / verify
    Interop & Visualizationsnarkjs_codec.mbt, viz.mbt, report.mbtStandard snarkjs verification_key.json / proof.json / public.json codec, native R1CS & Pairing pipeline SVGs

    #Quick Start (Library)

    Add Sam-Hui-dot/moon-zk@0.1.0 to moon.mod, then:

    fn main raise {
    let (r1cs, witness) = @zk.circuit_cubic(@zk.Fr::from_u64(3UL))
    let (pk, vk) = @zk.groth16_setup(r1cs)
    let proof = @zk.groth16_prove(pk, r1cs, witness)
    let ok = @zk.groth16_verify(vk, r1cs.public_inputs(witness), proof)
    println("verified: \{ok}")
    }

    #CLI Usage

    moon build --target native --release cmd/main # Generate standard snarkjs JSON artifacts + SVGs for any built-in circuit ./_build/native/release/build/cmd/main/main prove cubic --x 3 --out-dir out/ # Verify any standard snarkjs BN254 Groth16 proof ./_build/native/release/build/cmd/main/main verify out/verification_key.json out/public.json out/proof.json # Verify an Ethereum EIP-197 hex pairing vector ./_build/native/release/build/cmd/main/main eip197 empty

    #Verification & External Oracles

    # Four-target tests (--deny-warn) for target in wasm wasm-gc js native; do moon check --target "$target" --deny-warn moon test --target "$target" --deny-warn done # External Oracle: Ethereum EIP-197 vectors + Bidirectional official snarkjs@0.7.4 cross-verification python3 demo/verify_zk.py # Zero-upload browser studio build + Node smoke test python3 demo/build_web.py

    ZkError

    pub(all) suberror ZkError {
    InvalidFieldElement(String)
    InvalidCurvePoint(String)
    InvalidSubgroup(String)
    InvalidR1cs(String)
    UnsatisfiedConstraint(String)
    InvalidProof(String)
    InvalidJson(String)
    InvalidInput(String)
    } derive(Eq,
    Debug
    )

    Errors returned by BN254 field/curve/pairing and Groth16 operations.

    ZkError::equal

    fn ZkError::equal(ZkError, ZkError) -> Bool
    automatically derived

    ZkError::not_equal

    fn ZkError::not_equal(x : ZkError, y : ZkError) -> Bool
    automatically derived

    ZkError::to_repr

    automatically derived

    Constraint

    pub struct Constraint {
    a : LinearCombination
    b : LinearCombination
    c : LinearCombination
    label : String
    } derive(Eq,
    Debug
    )

    A single Rank-1 Constraint: A(w) * B(w) = C(w).

    Constraint::equal

    fn Constraint::equal(Constraint, Constraint) -> Bool
    automatically derived

    Constraint::not_equal

    fn Constraint::not_equal(x : Constraint, y : Constraint) -> Bool
    automatically derived

    Constraint::to_repr

    automatically derived
    pub struct Fp {
    v : U256
    } derive(Eq, Hash,
    Debug
    )

    Element of the BN254 base prime field F_p, stored in Montgomery representation.
    impl Add for Fp
    impl Mul for Fp
    impl Neg for Fp
    impl Show for Fp
    impl Sub for Fp

    Fp::add

    fn Fp::add(self : Fp, other : Fp) -> Fp

    Fp::double

    fn Fp::double(self : Fp) -> Fp

    Fp::equal

    fn Fp::equal(Fp, Fp) -> Bool
    automatically derived

    Fp::from_be_bytes

    fn Fp::from_be_bytes(bytes : BytesView) -> Fp raise ZkError

    Fp::from_decimal

    fn Fp::from_decimal(s : String) -> Fp raise ZkError

    Fp::from_hex

    fn Fp::from_hex(s : String) -> Fp raise ZkError

    Fp::from_int

    fn Fp::from_int(x : Int) -> Fp

    Construct Fp from a signed Int (negative values are negated mod p).

    Fp::from_str

    fn Fp::from_str(s : String) -> Fp raise ZkError

    Fp::from_u256

    fn Fp::from_u256(u : U256) -> Fp raise ZkError

    Convert a canonical integer u < p into Fp. Raises InvalidFieldElement if u >= p.

    Fp::from_u64

    fn Fp::from_u64(x : UInt64) -> Fp

    Construct Fp from a UInt64.

    Fp::hash

    fn Fp::hash(self : Fp) -> Int
    automatically derived

    Fp::hash_combine

    fn Fp::hash_combine(Fp, Hasher) -> Unit
    automatically derived

    Fp::inv

    fn Fp::inv(self : Fp) -> Fp?

    Multiplicative inverse in F_p. Returns None for 0.

    Fp::is_zero

    fn Fp::is_zero(self : Fp) -> Bool

    Fp::mul

    fn Fp::mul(self : Fp, other : Fp) -> Fp

    Fp::neg

    fn Fp::neg(self : Fp) -> Fp

    Fp::not_equal

    fn Fp::not_equal(x : Fp, y : Fp) -> Bool
    automatically derived

    Fp::one

    fn Fp::one() -> Fp

    Fp::output

    fn Fp::output(self : Fp, logger : &Logger) -> Unit

    Fp::pow

    fn Fp::pow(self : Fp, exp : U256) -> Fp

    Fp::sqrt

    fn Fp::sqrt(self : Fp) -> Fp?

    Square root in F_p (returns Some(r) with r^2 == self if self is a quadratic residue).

    Fp::square

    fn Fp::square(self : Fp) -> Fp

    Fp::sub

    fn Fp::sub(self : Fp, other : Fp) -> Fp

    Fp::to_be_bytes

    fn Fp::to_be_bytes(self : Fp) -> Bytes

    Fp::to_decimal

    fn Fp::to_decimal(self : Fp) -> String

    Fp::to_hex

    fn Fp::to_hex(self : Fp) -> String

    Fp::to_repr

    automatically derived

    Fp::to_string

    fn Fp::to_string(self : Fp) -> String

    Default implementation for Show::to_string, uses a StringBuilder

    Fp::to_u256

    fn Fp::to_u256(self : Fp) -> U256

    Convert back from Montgomery form to canonical U256 in [0, p-1].

    Fp::zero

    fn Fp::zero() -> Fp

    Fq12

    pub struct Fq12 {
    c0 : Fq6
    c1 : Fq6
    } derive(Eq, Hash,
    Debug
    )

    Degree-12 extension field F_{p^12} = F_{p^6}[w] / (w^2 - v), target group GT of BN254. Elements are represented as c0 + c1*w.
    impl Add for Fq12
    impl Mul for Fq12
    impl Neg for Fq12
    impl Sub for Fq12

    Fq12::add

    fn Fq12::add(self : Fq12, other : Fq12) -> Fq12

    Fq12::conjugate

    fn Fq12::conjugate(self : Fq12) -> Fq12

    Conjugation in F_{p^12} (equal to x^(p^6), and equal to inverse in the cyclotomic subgroup).

    Fq12::cyclotomic_pow_u64

    fn Fq12::cyclotomic_pow_u64(self : Fq12, exp : UInt64) -> Fq12

    Exponentiation by a 64-bit unsigned integer (used in final exponentiation by BN254 parameter x).

    Fq12::cyclotomic_square

    fn Fq12::cyclotomic_square(self : Fq12) -> Fq12

    Fast Granger-Scott squaring for elements in the cyclotomic subgroup G_{Phi_6}(F_{p^2}).

    Fq12::equal

    fn Fq12::equal(Fq12, Fq12) -> Bool
    automatically derived

    Fq12::frobenius_map

    fn Fq12::frobenius_map(self : Fq12, power : Int) -> Fq12

    Frobenius map x -> x^(p^k) in F_{p^12}.

    Fq12::hash

    fn Fq12::hash(self : Fq12) -> Int
    automatically derived

    Fq12::hash_combine

    fn Fq12::hash_combine(Fq12, Hasher) -> Unit
    automatically derived

    Fq12::inv

    fn Fq12::inv(self : Fq12) -> Fq12?

    Multiplicative inverse in F_{p^12}. Returns None for 0.

    Fq12::is_one

    fn Fq12::is_one(self : Fq12) -> Bool

    Fq12::is_zero

    fn Fq12::is_zero(self : Fq12) -> Bool

    Fq12::mul

    fn Fq12::mul(self : Fq12, other : Fq12) -> Fq12

    Karatsuba multiplication in F_{p^12}.

    Fq12::mul_by_034

    fn Fq12::mul_by_034(self : Fq12, c0 : Fq2, c3 : Fq2, c4 : Fq2) -> Fq12

    Sparse multiplication by a Miller-loop line evaluation of the form (c0 + 0v + 0v^2) + (c3 + c4v + 0v^2)*w.

    Fq12::neg

    fn Fq12::neg(self : Fq12) -> Fq12

    Fq12::new

    fn Fq12::new(c0 : Fq6, c1 : Fq6) -> Fq12

    Fq12::not_equal

    fn Fq12::not_equal(x : Fq12, y : Fq12) -> Bool
    automatically derived

    Fq12::one

    fn Fq12::one() -> Fq12

    Fq12::pow

    fn Fq12::pow(self : Fq12, exp : U256) -> Fq12

    General exponentiation by U256.

    Fq12::square

    fn Fq12::square(self : Fq12) -> Fq12

    Complex squaring in F_{p^12}.

    Fq12::sub

    fn Fq12::sub(self : Fq12, other : Fq12) -> Fq12

    Fq12::to_repr

    automatically derived

    Fq12::zero

    fn Fq12::zero() -> Fq12

    Fq2

    pub struct Fq2 {
    c0 : Fp
    c1 : Fp
    } derive(Eq, Hash,
    Debug
    )

    Quadratic extension field F_{p^2} = F_p[u] / (u^2 + 1). Elements are represented as c0 + c1 * u.
    impl Add for Fq2
    impl Mul for Fq2
    impl Neg for Fq2
    impl Show for Fq2
    impl Sub for Fq2

    Fq2::add

    fn Fq2::add(self : Fq2, other : Fq2) -> Fq2

    Fq2::conjugate

    fn Fq2::conjugate(self : Fq2) -> Fq2

    Frobenius endomorphism (conjugation): (c0 + c1u)^p = c0 - c1u.

    Fq2::double

    fn Fq2::double(self : Fq2) -> Fq2

    Fq2::equal

    fn Fq2::equal(Fq2, Fq2) -> Bool
    automatically derived

    Fq2::frobenius_map

    fn Fq2::frobenius_map(self : Fq2, power : Int) -> Fq2

    Frobenius map x -> x^(p^k) in F_{p^2}.

    Fq2::hash

    fn Fq2::hash(self : Fq2) -> Int
    automatically derived

    Fq2::hash_combine

    fn Fq2::hash_combine(Fq2, Hasher) -> Unit
    automatically derived

    Fq2::inv

    fn Fq2::inv(self : Fq2) -> Fq2?

    Multiplicative inverse in F_{p^2}. Returns None for 0.

    Fq2::is_zero

    fn Fq2::is_zero(self : Fq2) -> Bool

    Fq2::mul

    fn Fq2::mul(self : Fq2, other : Fq2) -> Fq2

    Karatsuba multiplication in F_{p^2}: (a0 + a1u)(b0 + b1u) = (a0b0 - a1b1) + ((a0+a1)(b0+b1) - a0b0 - a1b1)*u.

    Fq2::mul_by_nonresidue

    fn Fq2::mul_by_nonresidue(self : Fq2) -> Fq2

    Multiply by the cubic/sextic non-residue xi = 9 + u in F_{p^2}. (c0 + c1u)(9 + u) = (9c0 - c1) + (c0 + 9*c1)*u.

    Fq2::mul_fp

    fn Fq2::mul_fp(self : Fq2, s : Fp) -> Fq2

    Multiply by scalar in F_p.

    Fq2::neg

    fn Fq2::neg(self : Fq2) -> Fq2

    Fq2::new

    fn Fq2::new(c0 : Fp, c1 : Fp) -> Fq2

    Fq2::not_equal

    fn Fq2::not_equal(x : Fq2, y : Fq2) -> Bool
    automatically derived

    Fq2::one

    fn Fq2::one() -> Fq2

    Fq2::output

    fn Fq2::output(self : Fq2, logger : &Logger) -> Unit

    Fq2::square

    fn Fq2::square(self : Fq2) -> Fq2

    Optimized squaring in F_{p^2}: (a0 + a1u)^2 = (a0+a1)(a0-a1) + (2a0*a1)*u.

    Fq2::sub

    fn Fq2::sub(self : Fq2, other : Fq2) -> Fq2

    Fq2::to_repr

    automatically derived

    Fq2::to_string

    fn Fq2::to_string(self : Fq2) -> String

    Default implementation for Show::to_string, uses a StringBuilder

    Fq2::zero

    fn Fq2::zero() -> Fq2

    Fq6

    pub struct Fq6 {
    c0 : Fq2
    c1 : Fq2
    c2 : Fq2
    } derive(Eq, Hash,
    Debug
    )

    Cubic extension field F_{p^6} = F_{p^2}[v] / (v^3 - (9 + u)). Elements are represented as c0 + c1v + c2v^2.
    impl Add for Fq6
    impl Mul for Fq6
    impl Neg for Fq6
    impl Sub for Fq6

    Fq6::add

    fn Fq6::add(self : Fq6, other : Fq6) -> Fq6

    Fq6::double

    fn Fq6::double(self : Fq6) -> Fq6

    Fq6::equal

    fn Fq6::equal(Fq6, Fq6) -> Bool
    automatically derived

    Fq6::frobenius_map

    fn Fq6::frobenius_map(self : Fq6, power : Int) -> Fq6

    Frobenius map x -> x^(p^k) for k in {1, 2, 3}.

    Fq6::hash

    fn Fq6::hash(self : Fq6) -> Int
    automatically derived

    Fq6::hash_combine

    fn Fq6::hash_combine(Fq6, Hasher) -> Unit
    automatically derived

    Fq6::inv

    fn Fq6::inv(self : Fq6) -> Fq6?

    Multiplicative inverse in F_{p^6}. Returns None for 0.

    Fq6::is_zero

    fn Fq6::is_zero(self : Fq6) -> Bool

    Fq6::mul

    fn Fq6::mul(self : Fq6, other : Fq6) -> Fq6

    Karatsuba multiplication in F_{p^6}.

    Fq6::mul_by_01

    fn Fq6::mul_by_01(self : Fq6, b0 : Fq2, b1 : Fq2) -> Fq6

    Sparse multiplication by (b0 + b1*v).

    Fq6::mul_by_1

    fn Fq6::mul_by_1(self : Fq6, b1 : Fq2) -> Fq6

    Sparse multiplication by (b1*v).

    Fq6::mul_by_nonresidue

    fn Fq6::mul_by_nonresidue(self : Fq6) -> Fq6

    Multiply by the non-residue v in F_{p^6}: (c0 + c1v + c2v^2)v = (xic2) + c0v + c1v^2.

    Fq6::neg

    fn Fq6::neg(self : Fq6) -> Fq6

    Fq6::new

    fn Fq6::new(c0 : Fq2, c1 : Fq2, c2 : Fq2) -> Fq6

    Fq6::not_equal

    fn Fq6::not_equal(x : Fq6, y : Fq6) -> Bool
    automatically derived

    Fq6::one

    fn Fq6::one() -> Fq6

    Fq6::square

    fn Fq6::square(self : Fq6) -> Fq6

    Chung-Hasan SQR2 squaring in F_{p^6}.

    Fq6::sub

    fn Fq6::sub(self : Fq6, other : Fq6) -> Fq6

    Fq6::to_repr

    automatically derived

    Fq6::zero

    fn Fq6::zero() -> Fq6

    pub struct Fr {
    v : U256
    } derive(Eq, Hash,
    Debug
    )

    Element of the BN254 scalar prime field F_r, stored in Montgomery representation.
    impl Add for Fr
    impl Mul for Fr
    impl Neg for Fr
    impl Show for Fr
    impl Sub for Fr

    Fr::add

    fn Fr::add(self : Fr, other : Fr) -> Fr

    Fr::double

    fn Fr::double(self : Fr) -> Fr

    Fr::equal

    fn Fr::equal(Fr, Fr) -> Bool
    automatically derived

    Fr::from_be_bytes

    fn Fr::from_be_bytes(bytes : BytesView) -> Fr raise ZkError

    Fr::from_decimal

    fn Fr::from_decimal(s : String) -> Fr raise ZkError

    Fr::from_hex

    fn Fr::from_hex(s : String) -> Fr raise ZkError

    Fr::from_int

    fn Fr::from_int(x : Int) -> Fr

    Fr::from_str

    fn Fr::from_str(s : String) -> Fr raise ZkError

    Fr::from_u256

    fn Fr::from_u256(u : U256) -> Fr raise ZkError

    Convert a canonical integer u < r into Fr. Raises InvalidFieldElement if u >= r.

    Fr::from_u256_mod

    fn Fr::from_u256_mod(u : U256) -> Fr

    Reduce any U256 modulo r into Fr (used for deterministic seeds / hashes).

    Fr::from_u64

    fn Fr::from_u64(x : UInt64) -> Fr

    Fr::hash

    fn Fr::hash(self : Fr) -> Int
    automatically derived

    Fr::hash_combine

    fn Fr::hash_combine(Fr, Hasher) -> Unit
    automatically derived

    Fr::inv

    fn Fr::inv(self : Fr) -> Fr?

    Fr::is_zero

    fn Fr::is_zero(self : Fr) -> Bool

    Fr::mul

    fn Fr::mul(self : Fr, other : Fr) -> Fr

    Fr::multiplicative_generator

    fn Fr::multiplicative_generator() -> Fr

    Multiplicative generator of F_r* (5), also used as coset shift for QAP FFT.

    Fr::neg

    fn Fr::neg(self : Fr) -> Fr

    Fr::not_equal

    fn Fr::not_equal(x : Fr, y : Fr) -> Bool
    automatically derived

    Fr::one

    fn Fr::one() -> Fr

    Fr::output

    fn Fr::output(self : Fr, logger : &Logger) -> Unit

    Fr::pow

    fn Fr::pow(self : Fr, exp : U256) -> Fr

    Fr::root_of_unity

    fn Fr::root_of_unity(log_n : Int) -> Fr raise ZkError

    Primitive 2^log_n-th root of unity in F_r (supports 0 <= log_n <= 28).

    Fr::square

    fn Fr::square(self : Fr) -> Fr

    Fr::sub

    fn Fr::sub(self : Fr, other : Fr) -> Fr

    Fr::to_be_bytes

    fn Fr::to_be_bytes(self : Fr) -> Bytes

    Fr::to_decimal

    fn Fr::to_decimal(self : Fr) -> String

    Fr::to_hex

    fn Fr::to_hex(self : Fr) -> String

    Fr::to_repr

    automatically derived

    Fr::to_string

    fn Fr::to_string(self : Fr) -> String

    Default implementation for Show::to_string, uses a StringBuilder

    Fr::to_u256

    fn Fr::to_u256(self : Fr) -> U256

    Fr::zero

    fn Fr::zero() -> Fr

    G1Affine

    pub struct G1Affine {
    x : Fp
    y : Fp
    infinity : Bool
    } derive(Eq, Hash,
    Debug
    )

    Affine point on BN254 G1 (y^2 = x^3 + 3 over F_p).

    G1Affine::equal

    fn G1Affine::equal(G1Affine, G1Affine) -> Bool
    automatically derived

    G1Affine::from_eip196_bytes

    fn G1Affine::from_eip196_bytes(bytes : BytesView) -> G1Affine raise ZkError

    Decode G1Affine from 64-byte big-endian Ethereum EIP-196/197 format. Enforces canonical F_p (< p) and curve membership (all-zero = identity).

    G1Affine::from_xy

    fn G1Affine::from_xy(x : Fp, y : Fp) -> G1Affine raise ZkError

    Construct a checked G1Affine point from (x, y). Note: (0, 0) is rejected here; use G1Affine::identity() or from_eip196_bytes for infinity.

    G1Affine::from_xy_or_zero

    fn G1Affine::from_xy_or_zero(x : Fp, y : Fp) -> G1Affine raise ZkError

    Construct from coordinates where (0, 0) represents the point at infinity (EIP-196 convention).

    G1Affine::generator

    fn G1Affine::generator() -> G1Affine

    Standard BN254 G1 generator (1, 2).

    G1Affine::hash

    fn G1Affine::hash(self : G1Affine) -> Int
    automatically derived

    G1Affine::hash_combine

    fn G1Affine::hash_combine(G1Affine, Hasher) -> Unit
    automatically derived

    G1Affine::identity

    fn G1Affine::identity() -> G1Affine

    G1Affine::is_identity

    fn G1Affine::is_identity(self : G1Affine) -> Bool

    G1Affine::is_on_curve

    fn G1Affine::is_on_curve(self : G1Affine) -> Bool

    Verify whether the point lies on y^2 = x^3 + 3 (identity is always on curve).

    G1Affine::neg

    fn G1Affine::neg(self : G1Affine) -> G1Affine

    Negate a G1Affine point.

    G1Affine::not_equal

    fn G1Affine::not_equal(x : G1Affine, y : G1Affine) -> Bool
    automatically derived

    G1Affine::scalar_mul

    fn G1Affine::scalar_mul(self : G1Affine, s : Fr) -> G1Projective

    G1Affine::to_eip196_bytes

    fn G1Affine::to_eip196_bytes(self : G1Affine) -> Bytes

    Encode G1Affine as 64-byte big-endian Ethereum EIP-196/197 format (all zeros for infinity).

    G1Affine::to_projective

    fn G1Affine::to_projective(self : G1Affine) -> G1Projective

    G1Affine::to_repr

    automatically derived

    G1Projective

    pub struct G1Projective {
    x : Fp
    y : Fp
    z : Fp
    } derive(Eq, Hash,
    Debug
    )

    Jacobian projective point on BN254 G1 (represents affine (x/z^2, y/z^3), infinity when z == 0).
    impl Add for G1Projective
    impl Sub for G1Projective

    G1Projective::add

    General Jacobian addition (add-2007-bl).

    G1Projective::add_mixed

    fn G1Projective::add_mixed(self : G1Projective, other : G1Affine) -> G1Projective

    Mixed addition: Jacobian + Affine (madd-2007-bl).

    G1Projective::double

    fn G1Projective::double(self : G1Projective) -> G1Projective

    Jacobian doubling for a = 0 curve (dbl-2009-l).

    G1Projective::equal

    automatically derived

    G1Projective::generator

    fn G1Projective::generator() -> G1Projective

    G1Projective::hash

    fn G1Projective::hash(self : G1Projective) -> Int
    automatically derived

    G1Projective::hash_combine

    fn G1Projective::hash_combine(G1Projective, Hasher) -> Unit
    automatically derived

    G1Projective::identity

    fn G1Projective::identity() -> G1Projective

    G1Projective::is_identity

    fn G1Projective::is_identity(self : G1Projective) -> Bool

    G1Projective::neg

    G1Projective::not_equal

    fn G1Projective::not_equal(x : G1Projective, y : G1Projective) -> Bool
    automatically derived

    G1Projective::scalar_mul

    fn G1Projective::scalar_mul(self : G1Projective, s : Fr) -> G1Projective

    G1Projective::scalar_mul_u256

    fn G1Projective::scalar_mul_u256(self : G1Projective, s : U256) -> G1Projective

    Scalar multiplication [s]P using 4-bit fixed window.

    G1Projective::sub

    G1Projective::to_affine

    fn G1Projective::to_affine(self : G1Projective) -> G1Affine

    Convert Jacobian projective point to canonical affine coordinates.

    G1Projective::to_repr

    automatically derived

    G2Affine

    pub struct G2Affine {
    x : Fq2
    y : Fq2
    infinity : Bool
    } derive(Eq, Hash,
    Debug
    )

    Affine point on BN254 G2 (y^2 = x^3 + 3/(9+u) over F_{p^2}).

    G2Affine::equal

    fn G2Affine::equal(G2Affine, G2Affine) -> Bool
    automatically derived

    G2Affine::frobenius_map_1

    fn G2Affine::frobenius_map_1(self : G2Affine) -> G2Affine

    Frobenius endomorphism pi(Q) on G2: (x^p * xi^((p-1)/3), y^p * xi^((p-1)/2)).

    G2Affine::frobenius_map_2

    fn G2Affine::frobenius_map_2(self : G2Affine) -> G2Affine

    Double Frobenius endomorphism pi^2(Q) on G2.

    G2Affine::from_eip197_bytes

    fn G2Affine::from_eip197_bytes(bytes : BytesView) -> G2Affine raise ZkError

    Decode G2Affine from 128-byte Ethereum EIP-197 format (x.c1 || x.c0 || y.c1 || y.c0). Strictly enforces canonical F_p (< p), curve membership, and prime-order subgroup membership.

    G2Affine::from_xy

    fn G2Affine::from_xy(x : Fq2, y : Fq2) -> G2Affine raise ZkError

    Construct a checked G2Affine point on the twist curve and in the prime-order subgroup G2.

    G2Affine::from_xy_or_zero

    fn G2Affine::from_xy_or_zero(x : Fq2, y : Fq2) -> G2Affine raise ZkError

    Construct from coordinates where (0, 0) represents the identity (EIP-197 convention).

    G2Affine::generator

    fn G2Affine::generator() -> G2Affine

    Standard BN254 G2 generator (EIP-197 / snarkjs / arkworks).

    G2Affine::hash

    fn G2Affine::hash(self : G2Affine) -> Int
    automatically derived

    G2Affine::hash_combine

    fn G2Affine::hash_combine(G2Affine, Hasher) -> Unit
    automatically derived

    G2Affine::identity

    fn G2Affine::identity() -> G2Affine

    G2Affine::is_identity

    fn G2Affine::is_identity(self : G2Affine) -> Bool

    G2Affine::is_in_subgroup

    fn G2Affine::is_in_subgroup(self : G2Affine) -> Bool

    Strict prime-order r subgroup check: verifies curve membership AND [r]Q == O. Rejects invalid-curve and small-subgroup attacks (required by EIP-197).

    G2Affine::is_on_curve

    fn G2Affine::is_on_curve(self : G2Affine) -> Bool

    Verify whether the point lies on the twist curve y^2 = x^3 + 3/(9+u).

    G2Affine::neg

    fn G2Affine::neg(self : G2Affine) -> G2Affine

    G2Affine::not_equal

    fn G2Affine::not_equal(x : G2Affine, y : G2Affine) -> Bool
    automatically derived

    G2Affine::scalar_mul

    fn G2Affine::scalar_mul(self : G2Affine, s : Fr) -> G2Projective

    G2Affine::to_eip197_bytes

    fn G2Affine::to_eip197_bytes(self : G2Affine) -> Bytes

    Encode G2Affine in 128-byte Ethereum EIP-197 wire format: x.c1 || x.c0 || y.c1 || y.c0.

    G2Affine::to_projective

    fn G2Affine::to_projective(self : G2Affine) -> G2Projective

    G2Affine::to_repr

    automatically derived

    G2Projective

    pub struct G2Projective {
    x : Fq2
    y : Fq2
    z : Fq2
    } derive(Eq, Hash,
    Debug
    )

    Jacobian projective point on BN254 G2.
    impl Add for G2Projective
    impl Sub for G2Projective

    G2Projective::add

    G2Projective::add_mixed

    fn G2Projective::add_mixed(self : G2Projective, other : G2Affine) -> G2Projective

    G2Projective::double

    fn G2Projective::double(self : G2Projective) -> G2Projective

    G2Projective::equal

    automatically derived

    G2Projective::generator

    fn G2Projective::generator() -> G2Projective

    G2Projective::hash

    fn G2Projective::hash(self : G2Projective) -> Int
    automatically derived

    G2Projective::hash_combine

    fn G2Projective::hash_combine(G2Projective, Hasher) -> Unit
    automatically derived

    G2Projective::identity

    fn G2Projective::identity() -> G2Projective

    G2Projective::is_identity

    fn G2Projective::is_identity(self : G2Projective) -> Bool

    G2Projective::neg

    G2Projective::not_equal

    fn G2Projective::not_equal(x : G2Projective, y : G2Projective) -> Bool
    automatically derived

    G2Projective::scalar_mul

    fn G2Projective::scalar_mul(self : G2Projective, s : Fr) -> G2Projective

    G2Projective::scalar_mul_u256

    fn G2Projective::scalar_mul_u256(self : G2Projective, s : U256) -> G2Projective

    G2Projective::sub

    G2Projective::to_affine

    fn G2Projective::to_affine(self : G2Projective) -> G2Affine

    G2Projective::to_repr

    automatically derived

    LinearCombination

    pub struct LinearCombination {
    terms : Array[(Int, Fr)]
    } derive(Eq,
    Debug
    )

    Linear combination of R1CS wires: sum_i coeff_i * wire[idx_i].

    LinearCombination::add_lc

    LinearCombination::add_term

    fn LinearCombination::add_term(self : LinearCombination, wire : Int, coeff : Fr) -> LinearCombination

    LinearCombination::equal

    automatically derived

    LinearCombination::eval

    fn LinearCombination::eval(self : LinearCombination, witness : Array[Fr]) -> Fr

    LinearCombination::from_const

    fn LinearCombination::from_const(c : Fr) -> LinearCombination

    LinearCombination::from_wire

    fn LinearCombination::from_wire(wire : Int) -> LinearCombination

    LinearCombination::not_equal

    fn LinearCombination::not_equal(x : LinearCombination, y : LinearCombination) -> Bool
    automatically derived

    LinearCombination::scale

    LinearCombination::sub_lc

    LinearCombination::to_repr

    automatically derived

    LinearCombination::zero

    Proof

    pub struct Proof {
    a : G1Affine
    b : G2Affine
    c : G1Affine
    } derive(Eq,
    Debug
    )

    Groth16 Proof (pi_a in G1, pi_b in G2, pi_c in G1).

    Proof::equal

    fn Proof::equal(Proof, Proof) -> Bool
    automatically derived

    Proof::new

    fn Proof::new(a : G1Affine, b : G2Affine, c : G1Affine) -> Proof

    Proof::not_equal

    fn Proof::not_equal(x : Proof, y : Proof) -> Bool
    automatically derived

    Proof::to_repr

    automatically derived

    ProvingKey

    pub struct ProvingKey {
    vk : VerifyingKey
    beta_g1 : G1Affine
    delta_g1 : G1Affine
    a_query : Array[G1Affine]
    b_g1_query : Array[G1Affine]
    b_g2_query : Array[G2Affine]
    l_query : Array[G1Affine]
    h_query : Array[G1Affine]
    } derive(Eq,
    Debug
    )

    Groth16 Proving Key.

    ProvingKey::equal

    fn ProvingKey::equal(ProvingKey, ProvingKey) -> Bool
    automatically derived

    ProvingKey::not_equal

    fn ProvingKey::not_equal(x : ProvingKey, y : ProvingKey) -> Bool
    automatically derived

    ProvingKey::to_repr

    automatically derived

    R1cs

    pub struct R1cs {
    name : String
    num_public : Int
    num_wires : Int
    wire_names : Array[String]
    constraints : Array[Constraint]
    } derive(Eq,
    Debug
    )

    Rank-1 Constraint System (R1CS) following Circom/snarkjs wire layout: wire 0 = constant 1, wires 1..=num_public = public signals, wires (num_public+1)..num_wires = private/intermediate signals.

    R1cs::check_witness

    fn R1cs::check_witness(self : R1cs, witness : Array[Fr]) -> Unit raise ZkError

    Check whether a full witness vector satisfies every constraint in the R1CS.

    R1cs::equal

    fn R1cs::equal(R1cs, R1cs) -> Bool
    automatically derived

    R1cs::is_satisfied

    fn R1cs::is_satisfied(self : R1cs, witness : Array[Fr]) -> Bool

    R1cs::not_equal

    fn R1cs::not_equal(x : R1cs, y : R1cs) -> Bool
    automatically derived

    R1cs::public_inputs

    fn R1cs::public_inputs(self : R1cs, witness : Array[Fr]) -> Array[Fr]

    Extract public inputs (wires 1..=num_public) from a full witness.

    R1cs::to_repr

    automatically derived

    R1csBuilder

    pub struct R1csBuilder {
    name : String
    num_public : Int
    has_private : Bool
    wire_names : Array[String]
    witness : Array[Fr]
    constraints : Array[Constraint]
    }

    Stateful R1CS builder with witness assignment tracking.

    R1csBuilder::alloc_private

    fn R1csBuilder::alloc_private(self : R1csBuilder, name : String, value : Fr) -> Int

    Allocate a private or intermediate witness wire.

    R1csBuilder::alloc_public

    fn R1csBuilder::alloc_public(self : R1csBuilder, name : String, value : Fr) -> Int raise ZkError

    Allocate a public signal wire (must be called before any private/intermediate wire).

    R1csBuilder::build

    fn R1csBuilder::build(self : R1csBuilder) -> (R1cs, Array[Fr])

    Finalize the R1CS and witness pair.

    R1csBuilder::enforce

    fn R1csBuilder::enforce(self : R1csBuilder, a : LinearCombination, b : LinearCombination, c : LinearCombination, label? : String) -> Unit

    Enforce a Rank-1 Constraint A * B = C.

    R1csBuilder::new

    fn R1csBuilder::new(name : String) -> R1csBuilder

    U256

    pub struct U256 {
    l0 : UInt64
    l1 : UInt64
    l2 : UInt64
    l3 : UInt64
    } derive(Eq, Hash,
    Debug
    )

    Fixed-width 256-bit unsigned integer stored as 4 little-endian 64-bit limbs.
    impl Show for U256

    U256::add_carry

    fn U256::add_carry(self : U256, other : U256) -> (U256, UInt64)

    256-bit addition with carry out.

    U256::bit

    fn U256::bit(self : U256, i : Int) -> Bool

    Get bit at index i (0 = LSB, 255 = MSB).

    U256::bit_length

    fn U256::bit_length(self : U256) -> Int

    Number of significant bits (0 for zero).

    U256::cmp

    fn U256::cmp(self : U256, other : U256) -> Int

    Compare two U256 values: -1 if self < other, 0 if equal, 1 if self > other.

    U256::equal

    fn U256::equal(U256, U256) -> Bool
    automatically derived

    U256::from_be_bytes

    fn U256::from_be_bytes(bytes : BytesView) -> U256 raise ZkError

    Decode from 32-byte big-endian slice (Ethereum EIP-196/197 wire format).

    U256::from_decimal

    fn U256::from_decimal(s : String) -> U256 raise ZkError

    Parse an unsigned decimal string into U256.

    U256::from_hex

    fn U256::from_hex(s : String) -> U256 raise ZkError

    Parse an unsigned hexadecimal string (with or without 0x prefix) into U256.

    U256::from_str

    fn U256::from_str(s : String) -> U256 raise ZkError

    Parse either hex (0x...) or decimal string into U256.

    U256::from_u64

    fn U256::from_u64(v : UInt64) -> U256

    U256::hash

    fn U256::hash(self : U256) -> Int
    automatically derived

    U256::hash_combine

    fn U256::hash_combine(U256, Hasher) -> Unit
    automatically derived

    U256::is_zero

    fn U256::is_zero(self : U256) -> Bool

    U256::mul_wide

    fn U256::mul_wide(self : U256, other : U256) -> FixedArray[UInt64]

    512-bit unsigned product (8 little-endian 64-bit limbs).

    U256::new

    fn U256::new(l0 : UInt64, l1 : UInt64, l2 : UInt64, l3 : UInt64) -> U256

    U256::not_equal

    fn U256::not_equal(x : U256, y : U256) -> Bool
    automatically derived

    U256::one

    fn U256::one() -> U256

    U256::output

    fn U256::output(self : U256, logger : &Logger) -> Unit

    U256::shr1

    fn U256::shr1(self : U256) -> U256

    Right-shift by 1 bit.

    U256::sub_borrow

    fn U256::sub_borrow(self : U256, other : U256) -> (UInt64, U256)

    256-bit subtraction with borrow out.

    U256::to_be_bytes

    fn U256::to_be_bytes(self : U256) -> Bytes

    Convert to 32-byte big-endian representation (Ethereum EIP-196/197 wire format).

    U256::to_decimal

    fn U256::to_decimal(self : U256) -> String

    Format as canonical base-10 unsigned decimal string.

    U256::to_hex

    fn U256::to_hex(self : U256) -> String

    Format as canonical lowercase hexadecimal string with 0x prefix (64 hex chars).

    U256::to_repr

    automatically derived

    U256::to_string

    fn U256::to_string(self : U256) -> String

    Default implementation for Show::to_string, uses a StringBuilder

    U256::zero

    fn U256::zero() -> U256

    VerifyingKey

    pub struct VerifyingKey {
    alpha_g1 : G1Affine
    beta_g2 : G2Affine
    gamma_g2 : G2Affine
    delta_g2 : G2Affine
    ic : Array[G1Affine]
    } derive(Eq,
    Debug
    )

    Groth16 Verifying Key (100% compatible with snarkjs BN254 Groth16).

    VerifyingKey::equal

    automatically derived

    VerifyingKey::not_equal

    fn VerifyingKey::not_equal(x : VerifyingKey, y : VerifyingKey) -> Bool
    automatically derived

    VerifyingKey::to_repr

    automatically derived

    ZkRunSummary

    pub struct ZkRunSummary {
    circuit : String
    num_wires : Int
    num_public : Int
    num_constraints : Int
    witness_satisfied : Bool
    proof_verified : Bool
    public_inputs : Array[String]
    } derive(Eq,
    Debug
    )

    Summary report for a Groth16 prove/verify run.

    ZkRunSummary::equal

    automatically derived

    ZkRunSummary::not_equal

    fn ZkRunSummary::not_equal(x : ZkRunSummary, y : ZkRunSummary) -> Bool
    automatically derived

    ZkRunSummary::to_repr

    automatically derived

    build_run_summary

    fn build_run_summary(r1cs : R1cs, witness : Array[Fr], verified : Bool) -> ZkRunSummary

    circuit_cubic

    fn circuit_cubic(x : Fr) -> (R1cs, Array[Fr]) raise ZkError

    Built-in Circuit 1: Vitalik's classic cubic equation x^3 + x + 5 = y. Public: [y]. Private: x.

    circuit_factor

    fn circuit_factor(a : Fr, b_val : Fr) -> (R1cs, Array[Fr]) raise ZkError

    Built-in Circuit 2: Non-trivial integer factorization a * b = n with a != 1 and b != 1. Public: [n]. Private: a, b.

    circuit_merkle_mimc

    fn circuit_merkle_mimc(leaf : Fr, sibling0 : Fr, dir0 : Bool, sibling1 : Fr, dir1 : Bool) -> (R1cs, Array[Fr]) raise ZkError

    Built-in Circuit 4: 2-level MiMC-7 Merkle tree membership proof. Public: [root]. Private: leaf, sibling0, dir0 (0/1), sibling1, dir1 (0/1).

    circuit_mimc7

    fn circuit_mimc7(preimage : Fr, key : Fr) -> (R1cs, Array[Fr]) raise ZkError

    Built-in Circuit 3: MiMC-7 hash preimage proof H(preimage, key) = digest. Public: [digest]. Private: preimage, key.

    circuit_range8

    fn circuit_range8(value : Int, salt : Fr) -> (R1cs, Array[Fr]) raise ZkError

    Built-in Circuit 5: 8-bit binary decomposition range proof (0 <= value < 256) with MiMC-7 commitment commit = H(value, salt). Public: [commit]. Private: value, salt, bits b0..b7.

    compute_qap_h

    fn compute_qap_h(r1cs : R1cs, witness : Array[Fr]) -> Array[Fr] raise ZkError

    Compute the QAP quotient polynomial H(X) = (A(X)*B(X) - C(X)) / (X^n - 1) in O(n log n) via Coset FFT. Returns n-1 coefficients [h_0, ..., h_{n-2}].

    coset_fft_in_place

    fn coset_fft_in_place(a : Array[Fr], omega : Fr, shift : Fr) -> Unit

    Evaluate polynomial coefficients on coset shift * in-place.

    coset_ifft_in_place

    fn coset_ifft_in_place(a : Array[Fr], omega : Fr, shift : Fr) -> Unit raise ZkError

    Interpolate polynomial coefficients from evaluations on coset shift * in-place.

    eip196_ecadd

    fn eip196_ecadd(input : BytesView) -> Bytes raise ZkError

    Ethereum EIP-196 ecAdd precompile (address 0x06): Input: 128 bytes (zero-padded or truncated per EVM semantics) = G1 || G1. Output: 64 bytes = G1.

    eip196_ecmul

    fn eip196_ecmul(input : BytesView) -> Bytes raise ZkError

    Ethereum EIP-196 ecMul precompile (address 0x07): Input: 96 bytes (zero-padded or truncated) = G1 (64B) || scalar (32B big-endian, arbitrary U256). Output: 64 bytes = G1.

    eip197_ecpairing

    fn eip197_ecpairing(input : BytesView) -> Bool raise ZkError

    Ethereum EIP-197 ecPairing precompile (address 0x08): Input: 192*k bytes = k pairs of (G1 (64B) || G2 (128B)). Returns true iff prod_i e(P_i, Q_i) == 1. Rejects non-multiple-of-192 lengths, non-canonical coordinates, off-curve points, and non-subgroup G2 points.

    eip197_encode_pairs

    fn eip197_encode_pairs(pairs : Array[(G1Affine, G2Affine)]) -> Bytes

    Encode a list of (G1, G2) pairs into Ethereum EIP-197 precompile input bytes (192 bytes per pair).

    error_message

    fn error_message(err : Error) -> String

    Render a human-readable error message.

    fft_in_place

    fn fft_in_place(a : Array[Fr], omega : Fr) -> Unit

    In-place Radix-2 Cooley-Tukey NTT/FFT over F_r. a.length() must be a power of 2 and omega a primitive n-th root of unity.

    final_exponentiation

    fn final_exponentiation(f : Fq12) -> Fq12

    Exact BN254 Final Exponentiation: f^((p^12 - 1) / r). Easy part: f^((p^6 - 1)(p^2 + 1)). Hard part: f^((p^4 - p^2 + 1) / r) via Devegili base-p decomposition.

    fp_modulus

    let fp_modulus : U256

    BN254 base field F_p modulus: p = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47

    fr_modulus

    let fr_modulus : U256

    BN254 scalar field F_r modulus (prime subgroup order of G1, G2, GT): r = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001

    g1_from_snarkjs_json

    fn g1_from_snarkjs_json(j :
    Json
    , ctx? : String) -> G1Affine raise ZkError

    Decode a G1Affine point from snarkjs JSON (accepts 2-element affine or 3-element projective). Enforces canonical F_p and curve membership.

    g1_msm

    fn g1_msm(bases : Array[G1Affine], scalars : Array[Fr]) -> G1Projective raise ZkError

    Pippenger multi-scalar multiplication: computes sum_i [scalars[i]] * bases[i].

    g1_to_snarkjs_json

    fn g1_to_snarkjs_json(p : G1Affine) ->
    Json

    Encode a G1Affine point in snarkjs projective JSON format: ["x", "y", "1"] (or ["0", "1", "0"] for identity).

    g2_b

    let g2_b : Fq2

    Twist curve constant b' = 3 / (9 + u) for BN254 G2: y^2 = x^3 + b' over F_{p^2}.

    g2_from_snarkjs_json

    fn g2_from_snarkjs_json(j :
    Json
    , ctx? : String) -> G2Affine raise ZkError

    Decode a G2Affine point from snarkjs JSON (accepts 2-element affine or 3-element projective). Enforces canonical F_p, twist curve membership, and prime-order subgroup membership.

    g2_msm

    fn g2_msm(bases : Array[G2Affine], scalars : Array[Fr]) -> G2Projective raise ZkError

    Pippenger multi-scalar multiplication over G2.

    g2_to_snarkjs_json

    fn g2_to_snarkjs_json(q : G2Affine) ->
    Json

    Encode a G2Affine point in snarkjs projective JSON format: [["x.c0", "x.c1"], ["y.c0", "y.c1"], ["1", "0"]].

    groth16_prove

    fn groth16_prove(pk : ProvingKey, r1cs : R1cs, witness : Array[Fr], r? : Fr?, s? : Fr?, blinding_seed? : UInt64) -> Proof raise ZkError

    Generate a zero-knowledge Groth16 proof (A in G1, B in G2, C in G1) with blinding factors derived from r_seed (or explicit r, s).

    groth16_setup

    fn groth16_setup(r1cs : R1cs, seed? : UInt64) -> (ProvingKey, VerifyingKey) raise ZkError

    Groth16 trusted setup for an R1CS circuit using a deterministic 64-bit seed. Returns (ProvingKey, VerifyingKey).

    groth16_verify

    fn groth16_verify(vk : VerifyingKey, public_inputs : Array[Fr], proof : Proof) -> Bool raise ZkError

    Verify a Groth16 proof using a single 4-term shared final-exponentiation pairing check: e(-A, B) * e(alpha, beta) * e(vk_x, gamma) * e(C, delta) == 1.

    ifft_in_place

    fn ifft_in_place(a : Array[Fr], omega : Fr) -> Unit raise ZkError

    In-place inverse Radix-2 NTT/FFT over F_r.

    miller_loop

    fn miller_loop(pairs : Array[(G1Affine, G2Affine)]) -> Fq12

    Multi-pair Miller loop over non-identity pairs (P_i, Q_i).

    mimc7_hash

    fn mimc7_hash(x_in : Fr, key : Fr) -> Fr

    Native MiMC-7 permutation (10 rounds): x_{i+1} = (x_i + k + c_i)^7, output = x_10 + k.

    mont_mul

    fn mont_mul(a : U256, b : U256, m : U256, inv : UInt64) -> U256

    Montgomery multiplication (CIOS algorithm): returns a * b * R^-1 mod m, where inv = -m^-1 mod 2^64 and m.l3 < 2^63 (true for both BN254 p and r).

    mont_reduce

    fn mont_reduce(t : FixedArray[UInt64], m : U256, inv : UInt64) -> U256

    Montgomery reduction of a 512-bit value t (8 limbs): returns t * R^-1 mod m.

    multi_pairing

    fn multi_pairing(pairs : Array[(G1Affine, G2Affine)]) -> Fq12

    Compute the product of pairings prod_i e(P_i, Q_i) with a single shared final exponentiation.

    multi_pairing_check

    fn multi_pairing_check(pairs : Array[(G1Affine, G2Affine)]) -> Bool

    Check whether prod_i e(P_i, Q_i) == 1 in GT.

    next_power_of_two

    fn next_power_of_two(n : Int) -> (Int, Int)

    Return the smallest power of two >= n (minimum 1) along with its log2.

    pairing

    fn pairing(p : G1Affine, q : G2Affine) -> Fq12

    Compute the Optimal Ate pairing e(P, Q) in GT subset F_{p^12}*.

    proof_from_snarkjs_str

    fn proof_from_snarkjs_str(raw : String) -> Proof raise ZkError

    Parse a snarkjs proof.json string into a validated Proof.

    proof_to_snarkjs_json

    fn proof_to_snarkjs_json(proof : Proof) ->
    Json

    Export a Proof to standard snarkjs proof.json.

    public_inputs_from_snarkjs_str

    fn public_inputs_from_snarkjs_str(raw : String) -> Array[Fr] raise ZkError

    Parse a snarkjs public.json string (array of decimal strings) into Array[Fr].

    public_inputs_to_snarkjs_json

    fn public_inputs_to_snarkjs_json(inputs : Array[Fr]) ->
    Json

    Export public inputs to standard snarkjs public.json (array of decimal strings).

    render_pairing_svg

    fn render_pairing_svg(circuit_name : String, num_constraints : Int, num_wires : Int, num_public : Int, verified : Bool, proof : Proof) -> String

    Render a native SVG summary of the 4-term Groth16 Optimal Ate Pairing check.

    render_r1cs_svg

    fn render_r1cs_svg(r1cs : R1cs, witness? : Array[Fr]?) -> String

    Render a native SVG diagram of the R1CS constraint network (wires and multiplication gates).

    render_report_json

    fn render_report_json(s : ZkRunSummary) ->
    Json

    render_report_markdown

    fn render_report_markdown(s : ZkRunSummary) -> String

    render_report_text

    fn render_report_text(s : ZkRunSummary) -> String

    verify_snarkjs_json

    fn verify_snarkjs_json(vk_json : String, public_json : String, proof_json : String) -> Bool raise ZkError

    Convenience one-shot snarkjs JSON verification: returns true iff the proof is valid.

    vk_from_snarkjs_str

    fn vk_from_snarkjs_str(raw : String) -> VerifyingKey raise ZkError

    Parse a snarkjs verification_key.json string into a validated VerifyingKey.

    vk_to_snarkjs_json

    fn vk_to_snarkjs_json(vk : VerifyingKey) ->
    Json

    Export a VerifyingKey to standard snarkjs verification_key.json.