When Cryptography Meets Product Engineering

At Holonym, I worked on bringing zero-knowledge proving into mobile applications: Circom witness calculation and rapidsnark proving as native Expo modules, alongside ZoKrates through Rust. The work connected cryptographic libraries to an application written for quite different purposes. Getting a result across that interface leaves a question I want to be able to follow all the way through: what, exactly, may the application conclude from it?

My experience with application architecture and frontend state management gives me a way into that question. I can examine which operation is running, which account it belongs to, and what happens when the user changes something before it finishes. But those questions depend on understanding the result itself. A native function returning successfully does not establish that the circuit expresses the claim the application needs.

Two Circom expressions give me a small example to examine. Change out <== a * b to out <-- a * b, and the generated computation can still multiply the inputs. The second expression, however, does not add the constraint requiring the output to equal their product. Circom’s documentation on constraint generation makes this distinction explicit. It lets me examine two meanings of “the code works.”

With signal values a = 3 and b = 4, an honest witness calculator can produce out = 12 in either case. Testing that result does not demonstrate that the constraint system rejects a witness containing a = 3, b = 4, and out = 13. In a circuit with no other constraint tying these signals together, the assignment alone does not enforce the multiplication. The verifier needs the relation to be constrained; it does not rely on everyone choosing to run my calculator.

Following the executable code only answers part of the question. The computation describes a way to obtain values; the constraints describe the relations a proof must establish. They often appear together. The honest calculator returning twelve gives me evidence about the calculator, while rejecting the inconsistent witness tests a different property. I need to keep both in view.

The toolchain gives those questions separate artifacts. Circom can produce constraints and code for witness calculation; the latter can be generated as WebAssembly or C++. The witness includes the values needed for the circuit’s computation, including intermediate signals. Its witness calculation guide describes this stage separately from proof generation. Exposing a native function to JavaScript crosses a language boundary, but it does not erase the boundary between these artifacts.

The guide also represents its input integers as strings, because JavaScript’s ordinary number type cannot represent all large integers exactly. That detail belongs in the interface contract. If an input is rounded before it reaches the native module, proof generation cannot recover the value originally supplied. A successful call across the boundary is useful only if the two sides agree on the value that crossed it.

For example, the rapidsnark interface takes a proving key file and a witness file, then produces a proof and public signals. That interface is quite concrete. Somewhere upstream, an application has selected the inputs and the artifacts that belong together. Somewhere downstream, a verifier must check the proof against the intended statement. A native wrapper connects parts of this path. It cannot establish, merely by returning successfully, that the whole path represents what the user requested.

ZoKrates presents the same distinction through a different interface. Its introductory example separates compilation, setup, witness computation, proof generation, and verification. The example proves knowledge of a private value whose square equals a public value. That is a precise relationship. It says nothing by itself about the source of the private input, the identity of the person supplying it, or whether the application should grant that person access to anything. Those would require additional statements and checks.

This is where I want the interface to be more descriptive than prove(input). What statement is being proved? Which circuit and proving artifacts define it? Which inputs are public? Which application action is waiting for the result? I would want those relationships visible in the types and in the operation’s state. An opaque byte buffer can be convenient across a native boundary, but convenience does not tell the caller how to interpret it.

Frontend experience matters in an ordinary failure case. Consider an application that starts preparing a proof about one account. Before the native operation finishes, the user switches to another account. The old computation returns successfully. If the interface attaches that completion to whichever account happens to be selected now, the screen can describe the wrong operation even though the proof remains valid for its original inputs.

I would address that as a problem of ownership and state: the operation needs to retain the account, statement, and input version it belongs to; a completion needs to be checked against the action still awaiting it. Cancellation needs an explicit meaning. It might mean that the interface will discard a result, while the native computation continues. If the implementation cannot interrupt proving, displaying “cancelled” must not quietly imply that all computation and private intermediate data have already disappeared.

The example brings state management into the security analysis. The user acts on an application, not on a proof object in isolation. A mathematical guarantee can remain intact while the software associates it with the wrong request. Conversely, a reassuring screen can conceal that proof generation never finished. I want the application’s state to make those differences harder to lose.

The same attention applies when something fails. An invalid witness, incompatible artifacts, and an interrupted native operation do not mean the same thing. I would not want them collapsed into a single rejection that implies the underlying claim was false. Nor would I want debugging to depend on recording private inputs. The useful diagnostic is the stage, artifact version, and failure category that let an engineer investigate without turning a privacy feature into a collection point for its own secrets.

I can make an integration legible and still misunderstand the security assumptions of the construction it uses. Good types do not establish that a circuit expresses the intended claim. A successful collection of examples does not show that an adversary cannot exploit a missing constraint. Reviewing the native interface does not replace examining the circuit with someone who understands its intended claim and assumptions. Those responsibilities can overlap; I need to know which claim each review actually checked.

This is the direction in which I want to deepen the work. I want to follow a claim from its mathematical statement through the circuit, its inputs, the native interface, and the application state that uses the result. At each crossing, I need to establish something different. The native call can finish; the proof can verify; the application can still be waiting on a different request. I want the interface to carry enough context for the application to distinguish those cases, and enough information for another engineer to check that it does.

Back to Blog