Skip to main content

Crate curvy_witness

Crate curvy_witness 

Source
Expand description

§curvy-witness

Authenticated parser and evaluator for Curvy’s offline-compiled curvy-graph-v1 Circom witness artifacts.

Use this crate when an integration needs the full BN254 witness assignment but will perform proving elsewhere. Use curvy-prover when witness evaluation and local Groth16 proving should be one operation.

§Install

[dependencies]
curvy-witness = "=0.1.0-rc.3"

§Evaluate a graph

use curvy_witness::WitnessGraph;

let graph_bytes = std::fs::read("circuit.graph.bin")?;
let graph = WitnessGraph::from_bytes(
    &graph_bytes,
    "0000000000000000000000000000000000000000000000000000000000000000",
)?;
let assignment = graph.calculate_json(r#"{"amount":"42"}"#)?;

assert_eq!(assignment.len(), graph.assignment_size());

The expected SHA-256 is mandatory and is checked before graph parsing. For a compressed artifact it authenticates the zstd frame bytes, before decoding. Parsing also enforces graph/input size limits, canonical BN254 field values, valid node references, and strict input names and shapes. The crate does not depend on another Circom witness runtime.

§Accepted artifacts

A default build reads the SIGNET01 and CVYWIT01 envelopes at body version 1, raw or zstd-compressed.

featureadds
signet-v2the version-2 body encoding: varint distances and ZigZag output deltas. Not stable; no published artifact uses it.
sagesage::SageGraph, a second evaluator over the same artifacts.

See the workspace guide for artifact and build-target guidance.

§Security model

Graph bytes are deployment artifacts, not executable code. The parser hashes the complete artifact before decoding and validates every size and reference. Use this crate when an integration needs a full BN254 witness assignment but performs proving elsewhere. curvy-prover builds on this evaluator when local Groth16 proving is required.

§Resource budget

Ceilings are per-consumer, not global - see Limits. The default is Limits::client, which covers every published profile (largest: pending(5,30), 1,106,576 nodes) and projects to roughly 280 MiB of structural memory at its maxima. A batch prover that deliberately proves pending(50) opts into Limits::batch_prover at the call site, taking 8,000,000 nodes and a ~799 MiB projection with it.

Every allocation derived from artifact-declared counts is fallible, so an over-large graph is a typed error rather than an abort.

§Optional features

A default build accepts the CVYWIT01 and SIGNET01 envelopes at version 1, raw or zstd-compressed.

  • signet-v2 - additionally accept the version-2 body encoding. Off by default: the encoding is not stable and no published artifact uses it.
  • sage - add sage::SageGraph, a second evaluator over the same artifacts.

Modules§

sage
SAGE - the Slot-Allocated Graph Evaluator.
wire
Stable SIGNET operation tags shared by graph producers and consumers.

Structs§

Limits
Resource ceilings for one graph load.
WitnessGraph
Parsed, reusable graph for one circuit revision.

Enums§

WitnessError