<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by The Blockhouse Technology Ltd on Medium]]></title>
        <description><![CDATA[Stories by The Blockhouse Technology Ltd on Medium]]></description>
        <link>https://medium.com/@tbtl?source=rss-fe5f088b5c5d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*m7Js-kKe3JyBkxUPpXtP2w.png</url>
            <title>Stories by The Blockhouse Technology Ltd on Medium</title>
            <link>https://medium.com/@tbtl?source=rss-fe5f088b5c5d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 04:10:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tbtl/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Zero-Knowledge Selective Disclosure for the EU Digital Identity Wallet]]></title>
            <link>https://medium.com/@tbtl/zero-knowledge-selective-disclosure-for-the-eu-digital-identity-wallet-a27030fdf159?source=rss-fe5f088b5c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a27030fdf159</guid>
            <dc:creator><![CDATA[The Blockhouse Technology Ltd]]></dc:creator>
            <pubDate>Fri, 20 Nov 2026 08:39:16 GMT</pubDate>
            <atom:updated>2026-11-20T08:39:16.776Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building a Noir circuit that proves facts about your ID without disclosing it</h4><p><strong>TL;DR:</strong> The EU Digital Identity (EUDI) Wallet already lets you disclose only <em>some</em> of your identity attributes from a credential, but it still leaks more than it should. We built <strong>zk-pid</strong>, a <a href="https://noir-lang.org/">Noir</a> circuit that adds a zero-knowledge layer on top of the EUDI spec’s existing selective-disclosure format. A wallet can use it to prove that a credential attribute has a specific value, like “my nationality is DE”, without revealing the rest of the credential, the issuer, or anything that links one presentation to another. This post covers the design and why it is useful. A second post covers how we made the circuit fast and how we checked parts of it with a formal verifier.</p><h3>Background: the EUDI ecosystem, in three roles</h3><p>The EU Digital Identity framework lets citizens store official credentials in a mobile wallet and present them to services without going through the original issuer every time. The <a href="https://github.com/eu-digital-identity-wallet/eudi-doc-architecture-and-reference-framework">EUDI Architecture and Reference Framework</a> defines three roles: an <strong>issuer</strong> (a government agency or other authorized body) issues credentials; the <strong>wallet</strong> (or holder — held by the citizen) stores and presents them; and a <strong>verifier</strong> (a relying party — a bank, an airport or an online platform) checks a presented credential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hy0sRwKyLajYNAxeFhKxJA.jpeg" /></figure><p>Issuance itself is straightforward: the wallet holder requests a document (say, a Person Identification Data record, or <strong>PID</strong>), the issuer authenticates the user and verifies their data, generates the digital document, and sends it to the wallet. From then on, the user can present that document directly from their wallet to any relying party, without the issuer being involved in every transaction. The length of time a wallet can store and use a credential before needing to communicate with the issuer again depends entirely on the ‘Credential Reuse Policy’ and validity metadata embedded within that specific credential.</p><h3>From an ID card to an SD-JWT: how a credential is packaged</h3><p>Let’s start with a concrete situation. Jane is booking a rental car online. Many rental companies price by driver age: insurance is included by default for drivers over a certain age (21 for some companies, 24 or 25 for others), and younger drivers pay a surcharge or get different cover. So at booking time, before anyone looks at a driving licence, the company needs to know one thing about her: is she over the age threshold, yes or no?</p><p>The traditional way to prove this is to upload a scan of an ID card, and the company then sees her full name, exact birth date, nationality, document number and more. That is <strong>full disclosure</strong>: to prove one fact, you hand over everything. <strong>Selective disclosure</strong> is the idea that Jane should be able to reveal only what the company needs.</p><p>The following figure shows how an issuer turns raw claims into a credential that Jane can present selectively, in four stages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VlIfJFs3GGnyUivuTYaLMQ.jpeg" /></figure><p><strong>1. PID.</strong> A <strong>claim</strong> is a single fact about a person, written as a name and a value: given_name: Jane, birthdate: 1992-03-28, nationality: FR. A <strong>PID</strong> (Person Identification Data) is simply a set of such claims, the raw identity data collected by the issuer before any packaging.</p><p><strong>2. Disclosure.</strong> For each claim that can be revealed on its own, the issuer builds a <strong>Disclosure</strong>: an array of [salt, claim_name, claim_value], where the salt is a random value. This array is written in <strong>base64url</strong>, a way of encoding arbitrary bytes as plain letters and digits so they fit inside text formats (<a href="https://datatracker.ietf.org/doc/html/rfc4648#section-5">RFC 4648, section 5</a>). The result is the string WyIyR0xD... in the figure. It is not JSON and not a hash, and it is an encoding, not encryption: anyone who has it can decode it. Think of each Disclosure as a sealed envelope holding one claim. The issuer then computes a <strong>hash</strong> (SHA-256) of that string: a fingerprint that is easy to compute from the envelope but impossible to turn back into its contents. Only the fingerprint goes into the signed credential.</p><p><strong>3. Issuer-signed JWT.</strong> The fingerprints are placed in a <strong>JWT</strong> (<a href="https://datatracker.ietf.org/doc/html/rfc7519">JSON Web Token, RFC 7519</a>), which has three dot-separated parts: a <strong>header</strong> (the signing algorithm and type), a <strong>payload</strong> (the visible data, including the <strong>_sd array</strong> that lists the fingerprints), and a <strong>signature</strong>, the issuer&#39;s digital signature over the header and payload together. Anyone can use it to check that the credential came from the issuer and was not changed. The payload also carries a <strong>cnf</strong> (confirmation) claim that embeds the holder&#39;s device public key, present whenever key binding is used. The claims themselves are not in the payload, only their fingerprints.</p><p><strong>4. SD-JWT.</strong> The issuer hands Jane the signed JWT with all the Disclosures appended, separated by ~: &lt;Issuer JWT&gt;~&lt;Disclosure 1&gt;~&lt;Disclosure 2&gt;~...~. This bundle is an <strong>SD-JWT</strong> (<a href="https://www.rfc-editor.org/rfc/rfc9901">Selective Disclosure for JWTs, RFC 9901</a>), the format EUDI credentials use.</p><p>A plain JWT, by contrast, would put every claim in the payload, so presenting it shows everything. With an SD-JWT, Jane decides at presentation time which envelopes to hand over. The verifier recomputes the fingerprint of each Disclosure it receives and checks that it appears in the signed _sd array. A claim whose envelope was never handed over stays hidden. A <strong>KB-JWT</strong> (Key-Binding JWT), a short JWT signed by the holder&#39;s own device key, is typically sent alongside the Disclosures to prove that the person presenting the credential really holds it.</p><p>In practice, the payload of a PID’s issuer-signed JWT looks roughly like this (the fingerprints stand in for the claims):</p><pre>{<br>  &quot;iss&quot;: &quot;https://issuer.example.eu&quot;,<br>  &quot;vct&quot;: &quot;urn:eudi:pid:1&quot;,<br>  &quot;_sd&quot;: [<br>    &quot;9wpNVPWuD7RRbNQFwZeYm9DEyPd8...&quot;,<br>    &quot;yb4rgHplU3PYRp2b3rl9Sw...&quot;<br>  ],<br>  &quot;_sd_alg&quot;: &quot;sha-256&quot;,<br>  &quot;cnf&quot;: { &quot;jwk&quot;: { &quot;kty&quot;: &quot;EC&quot;, &quot;crv&quot;: &quot;P-256&quot;, &quot;x&quot;: &quot;...&quot;, &quot;y&quot;: &quot;...&quot; } },<br>  &quot;nbf&quot;: 1735689600,<br>  &quot;exp&quot;: 1893456000<br>}</pre><p>and a corresponding Disclosure the holder can choose to reveal (here, for the birthdate claim, before base64url encoding) looks like:</p><pre>[&quot;2GLC42sKQveCfGfryNRN9w&quot;, &quot;birthdate&quot;, &quot;1992-03-28&quot;]</pre><p>Whoever receives this Disclosure learns Jane’s exact date of birth, even though the rental company only needed to know “is this person at least 21, yes or no.”</p><p>PID issuers do pre-compute a few common predicates as claims of their own, such as an “age over 18” flag (Germany’s PID adds 21 and 65). But that only covers thresholds the issuer anticipated. A rental company asking “at least 24?”, another asking “at least 25?” or a service asking “born before 1960?” gets nothing from it, and the holder falls back to disclosing birthdate in full. That gap between what SD-JWT can disclose (a whole claim, or a predicate the issuer chose in advance) and what a verifier actually needs (an arbitrary predicate over that claim) is the gap zk-pid is built to close. Today it supports equality checks only, which still disclose the attribute value in full (though not the issuer, the other claims or anything linkable), so they are a first step towards predicates that disclose less, such as &quot;at least 21&quot;.</p><h3>What SD-JWT still leaks</h3><p>SD-JWT is a real privacy improvement over a plain JWT, but it isn’t a full answer. Even with selective disclosure, three things still leak to the verifier. Here is each one in Jane’s car-rental scenario:</p><ul><li><strong>The issuer’s public key reveals where you are from.</strong> To check the signature, the verifier must see the issuer’s public key (or a certificate containing it), and those keys are published. Suppose the key beginning MFkwEwYH... is the well-known key of France&#39;s PID issuer (an illustrative value). A verifier that sees it in a presentation knows the credential is French, even if Jane only proved she is over 21 and never disclosed her nationality. The same holds for every other member state&#39;s issuer.</li><li><strong>The full disclosed claim value is shown.</strong> If the company asks for the birthdate claim, it gets Jane&#39;s exact date of birth, not a &quot;yes&quot; for the threshold that mattered.</li><li><strong>Every verifier sees the same signature.</strong> The issuer’s signature is the same bytes every time the credential is presented. If Jane shows the credential to the rental company on Monday and to an online shop on Tuesday, both see identical signature bytes. They can compare notes and conclude it was the same person, even though the disclosed claims differed.</li></ul><p>The goal of zk-pid is to close these gaps: use a zero-knowledge proof to hide what SD-JWT alone can&#39;t hide, while still cryptographically proving the credential is genuine. The target use cases are predicate checks - confirming nationality matches what the verifier asks for, without revealing the issuer or anything linkable, or confirming a credential is currently valid as a plain yes/no where the proof itself carries no reusable, linkable information.</p><h3>The spec: EUDI’s TS13</h3><p><a href="https://github.com/eu-digital-identity-wallet/eudi-doc-standards-and-technical-specifications/blob/main/docs/technical-specifications/ts13-zksnarks.md">TS13</a>, the relevant EUDI technical specification, describes how to layer zero-knowledge proofs on top of an SD-JWT presentation. The core idea is to represent the proof as an arithmetic circuit with two kinds of input: a secret <strong>witness</strong> (the credential itself, plus supporting material) and a public <strong>statement</strong> (the condition being checked, plus any public key material needed to verify it). The circuit outputs true only if the stated condition holds: say, “the credential’s birthdate is on or before the date exactly 21 years before today&quot; (the holder is at least 21), and the wallet generates a zero-knowledge proof that it holds <em>some</em> witness making the circuit output true, without revealing that witness.</p><p>TS13 isn’t yet a finalized, stable standard. It’s still expected to be revised, so part of our motivation in building zk-pid was to actually exercise the spec: understand Noir as an implementation language, measure real performance, and build a working reference application rather than reasoning about the design on paper alone.</p><h3>What zk-pid proves</h3><p>Concretely, zk-pid is a Noir circuit built to prove the following, from a single SD-JWT presentation:</p><ol><li>A well-formed SD-JWT was issued by a legitimate issuer (via hash computation and a signature check).</li><li>The credential is currently valid (its validity window covers the current time).</li><li>The credential is bound to a specific device key.</li><li>The holder controls that device key, via a signed KB-JWT (hash + signature check).</li><li>A specific attribute matches the verifier’s query, via a disclosure the issuer actually signed (via hash).</li><li>The issuer’s own key is certified by a certificate authority (CA).</li></ol><p>Put together, the verifier only learns: the CA’s public key, the attribute name and value being queried, and the fact that everything else holds.</p><p>Today the attribute check is an equality: the disclosed value must match the expected value the verifier supplies. Range predicates are future work (see above).</p><h4>What goes in: public and private inputs</h4><p>The circuit takes roughly 25 inputs. The public inputs are the CA’s public key, a nonce, the current timestamp, and the queried attribute name and expected value — these are the <em>question</em>, not the secret answer, so there’s no privacy cost to making them public. Everything else — the issuer’s public key and signature, the SD-JWT itself, the CA’s signature over the issuer key, the device public key and its signature, and the KB-JWT — is private, supplied by the wallet as witness data. Notably, anything that stays <em>constant</em> across multiple presentations (the issuer key, the device key, the signatures) has to stay private too, or a verifier could link separate presentations together by that constant value alone. The queried value is public, but because many holders share it, it links far less than a key would.</p><p>The soundness argument in the walk-through below rests on one design rule: everything the verifier relies on is <strong>recomputed inside the circuit</strong> from the private data. The verifier trusts only the public inputs it supplied itself and the proof. If any step fails, no valid proof can be produced, so the verifier rejects.</p><h4>Step 1: The credential was issued by a legitimate issuer</h4><p>The circuit hashes the SD-JWT header and payload and verifies the issuer’s ECDSA P-256 signature over that hash, using the issuer public key supplied as private witness.</p><p><em>What it proves:</em> the credential contains exactly what a legitimate issuer signed, unchanged.</p><p><em>If it fails:</em> an edited claim, or a credential the holder made up, changes the hash, so the signature check fails and no valid proof can be produced.</p><h4>Step 2: The credential is currently valid</h4><p>The circuit checks nbf &lt;= now &lt; exp on the payload&#39;s validity window, where now is the public timestamp the verifier supplied.</p><p><em>What it proves:</em> the credential is valid right now, at the time the verifier named.</p><p><em>If it fails:</em> an expired or not-yet-valid credential fails the comparison. Because now is a public input, a proof made for a different time does not match what the verifier asked for.</p><h4>Step 3: The credential is bound to a device key</h4><p>The circuit reads the cnf claim from the signed payload and extracts the device public key it contains.</p><p><em>What it proves:</em> the credential is tied to one specific device key, and that key is the one the issuer signed.</p><p><em>If it fails:</em> swapping in a different key changes the payload, so the signature check in Step 1 fails.</p><h4>Step 4: The holder controls the device key</h4><p>The circuit hashes the KB-JWT and verifies its signature against the device key from Step 3. The KB-JWT includes the verifier’s nonce.</p><p><em>What it proves:</em> the person presenting the credential holds the device private key, and the proof was made for this session.</p><p><em>If it fails:</em> someone who copied the credential but doesn’t hold the device key cannot produce a KB-JWT signature that verifies, and an old proof made for a different nonce is rejected.</p><h4>Step 5: The attribute matches the verifier’s query</h4><p>The circuit takes the disclosure for the queried attribute, hashes it, checks that the hash appears in the signed payload’s _sd array, and checks that the claim name and value equal the public query.</p><p><em>What it proves:</em> the attribute the verifier asked about has exactly the value in the query, and it comes from a Disclosure the issuer signed.</p><p><em>If it fails:</em> a made-up Disclosure hashes to a value that is not in the signed _sd array, and a genuine Disclosure with a different value fails the equality check.</p><h4>Step 6: The issuer’s key is certified by a CA</h4><p>The circuit verifies a CA signature over the issuer public key, using the CA public key supplied as a public input.</p><p><em>What it proves:</em> the issuer is one that the CA vouches for, without revealing which issuer it is. The issuer key stays private, so the verifier learns only which CA is behind it. In our setup, one CA certifies every member state’s issuer, so the verifier can’t tell which country issued the credential.</p><p><em>If it fails:</em> an issuer the CA has not certified cannot produce a CA signature that verifies, so a self-made issuer is rejected.</p><h4>Where this leaves things</h4><p>zk-pid is a reference implementation, not a finished product. TS13 itself is expected to evolve, the attribute check is equality only, and some computationally expensive functions (ECDSA verification, SHA-256 compression, Keccak-256&#39;s permutation) aren&#39;t implemented in every proving backend. But the design does what we set out for it to do: it shows that adding a genuine zero-knowledge layer on top of EUDI&#39;s existing SD-JWT format is practical. It closes two of the three leaks described above, the issuer and the linkable signature. The third, the disclosed value itself, waits on range predicates. Revocation is also out of scope: checking a status list would reveal the credential’s index, which identifies it, so that needs its own privacy-preserving design.</p><p>In the second post we cover what made this circuit expensive to prove, how we brought proving time from 48 seconds to about 9, and how we used a formal verifier, <a href="https://github.com/blockhouse-sec/nave">NAVe</a>, to check parts of it.</p><p>We help teams bring zero-knowledge proofs into their own systems and processes. If that’s on your list,<a href="https://security.tbtl.com/contact/"> get in touch</a>. And if you’re working on digital identity more broadly, have a look at <a href="https://fortid.com/">FortID</a>, our EUDI-compliant identity product.</p><p><em>Tags: zero-knowledge, eudi-wallet, noir, digital-identity, cryptography</em></p><p><strong>Sources:</strong></p><ul><li><a href="https://github.com/eu-digital-identity-wallet/eudi-doc-standards-and-technical-specifications/blob/main/docs/technical-specifications/ts13-zksnarks.md">TS13 — Implementation of ZKP based on arithmetic circuits in the EUDI Wallet</a> — the EUDI technical specification this circuit implements</li><li><a href="https://github.com/eu-digital-identity-wallet/eudi-doc-architecture-and-reference-framework">EUDI Wallet Architecture and Reference Framework</a> — the roles and credential model</li><li><a href="https://www.rfc-editor.org/rfc/rfc9901">RFC 9901: Selective Disclosure for JSON Web Tokens</a> — SD-JWT, disclosures and key binding</li><li><a href="https://datatracker.ietf.org/doc/html/rfc7519">RFC 7519: JSON Web Token</a></li><li><a href="https://datatracker.ietf.org/doc/html/rfc4648#section-5">RFC 4648, section 5: base64url</a></li><li><a href="https://noir-lang.org/">Noir</a> — the language the circuit is written in</li><li><a href="https://tbtl.com/products/fortid/">FortID — EUDI/eIDAS-compliant digital identity</a> — TBTL’s EUDI/eIDAS-compliant digital identity product</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a27030fdf159" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Catching Zero-Knowledge Bugs Before They Ship]]></title>
            <link>https://medium.com/@tbtl/catching-zero-knowledge-bugs-before-they-ship-5ecac75a7b44?source=rss-fe5f088b5c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ecac75a7b44</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <category><![CDATA[formal-methods]]></category>
            <category><![CDATA[web3]]></category>
            <dc:creator><![CDATA[The Blockhouse Technology Ltd]]></dc:creator>
            <pubDate>Wed, 28 Oct 2026 10:19:54 GMT</pubDate>
            <atom:updated>2026-10-28T10:19:54.227Z</atom:updated>
            <content:encoded><![CDATA[<h3>How NAVe formally verifies Noir programs and catches the underconstrained bugs that testing can’t see</h3><p><strong>TL;DR:</strong> Zero-knowledge circuits fail silently: a missing constraint doesn’t crash your program, it just lets a dishonest prover produce a “valid” proof for what should be a false statement. In the context of Web3, this false statement can lead, for instance, to the misappropriation of funds. We built NAVe, a formal verifier for <a href="https://noir-lang.org/">Noir</a> programs, to catch exactly this: underconstrained circuits that ordinary tests are poorly placed to catch. To do it, we formalised Noir’s intermediate representation, called ACIR, in <a href="https://smt-lib.org/">SMT-LIB</a> over finite fields and integers. As a further test of the tool’s reach, we also reproduced four real, previously fixed Noir compiler bugs by reverting their patches; we walk through two of them below.</p><p>This post is based on our paper <a href="https://arxiv.org/abs/2601.09372">Formally Verifying Noir Zero Knowledge Programs with NAVe</a> accepted at <a href="https://sefm-conference.github.io/2026/acceptedpapers/">SEFM’26</a>.</p><h3>A quick primer: ZK proofs and Noir</h3><p>If you’re new to <a href="https://en.wikipedia.org/wiki/Zero-knowledge_proof">zero-knowledge proofs</a>, the core idea is: a <strong>prover</strong> convinces a <strong>verifier</strong> that some statement is true, without revealing anything beyond the fact that it’s true. A <a href="https://en.wikipedia.org/wiki/Zero-knowledge_proof#The_red_card_proof">simple example from Wikipedia</a>: Peggy (the prover) draws a card from a shuffled deck, with the usual 26 black and 26 red cards, and keeps it face down. To prove it is red to Victor (the verifier) without revealing which card it is, she shows Victor all 26 black cards from the rest of the deck. Victor now knows her card is red, but nothing more; and if it were black, she couldn’t produce all 26 black cards, so she can’t cheat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-VoBwdL9c9IPHQ1U5zkcQ.jpeg" /><figcaption>Peggy proving it has a red card to Victor.</figcaption></figure><p>A useful proof system needs three properties: <strong>completeness</strong> (an honest prover with a true statement can always convince the verifier), <strong>soundness</strong> (a dishonest prover cannot convince the verifier of a false statement, except with negligible probability), and <strong>zero-knowledge</strong> (the verifier learns nothing beyond the statement’s truth). In the formal version, the prover convinces the verifier that a pair (X, W) satisfies a relation R, where X is an input both sides know and W is the prover&#39;s private input (the <strong>witness</strong>) and nothing about W leaks beyond the fact that R(X, W) holds.</p><p>In practice, R is captured by an <strong>arithmetic circuit</strong>: a set of polynomial equations (constraints) over a finite field. Writing those by hand is difficult, which is where <strong>Noir</strong> comes in. Noir is a <a href="https://www.rust-lang.org/">Rust</a>-inspired domain-specific language, proposed by the Aztec community, for writing zero-knowledge programs at a much higher level of abstraction. You write ordinary-looking functions with types, control flow and structs; if R(X, W) holds, the program runs successfully on (X, W). Noir&#39;s built-in Field type is a finite-field element, for the default backend, a 254-bit element of the BN254 scalar field (also the base field of the Grumpkin curve). Loops must have bounds known at compile time, because they get unrolled into the circuit. Noir is designed to be proving backend agnostic, which means you can choose to use different proving backends to prove and verify your Noir programs. By default it uses <a href="https://barretenberg.aztec.network/docs/">Barretenberg</a> (bb) which is an optimized elliptic curve library for the bn128 curve, and a <a href="https://eprint.iacr.org/2019/953">PLONK</a>-style SNARK prover.</p><p>The Noir compiler turns programs into <strong>ACIR</strong> (Abstract Circuit Intermediate Representation), a lower-level format that sits between the language and whichever proof system is used underneath. A key feature of Noir, and ZK-programming languages more broadly, is the split between constrained and <strong>unconstrained</strong> code. Constrained code generates circuit constraints. Unconstrained code is used for computation but it contributes <strong>no constraints at all</strong>. That’s genuinely useful. Some computations are expensive to express as constraints but cheap to compute normally. But it comes with an obligation: if you compute something in unconstrained code, you must add the matching constraint yourself, typically with an assert statement. Noir makes you wrap calls to unconstrained functions from constrained code in an unsafe block, as a reminder. Forgetting that obligation is exactly the bug we&#39;ll walk through next.</p><h3>The bug you can’t see</h3><p>Zero-knowledge programs fail in a few distinct ways:</p><p>Bug class What goes wrong <strong>Underconstrained</strong> The constraints are satisfiable by inputs that shouldn’t be valid, so the circuit doesn’t capture the relation it was meant to. Often caused by unconstrained code whose result is never checked. <strong>Non-determinism</strong> The relation was meant to be a function (one valid output per input), but it isn’t. <strong>Compiler bug</strong> The constraints the compiler generates don’t correctly capture the behaviour of the high-level code, even when the programmer did everything right.</p><p>The first kind has already caused serious real-world vulnerabilities. The Tornado Cash team published their own write-up of one, titled “Tornado Cash got hacked. By us.” and with ZK programs now guarding private data and large sums of digital assets, these bugs are a perfect target for formal verification. Before discussing underconstrained bugs, we discuss the peculiarity of ZK-programming language and the constrained vs unconstrained code dichotomy.</p><h3>Constrained vs unconstrained code</h3><p>Unconstrained code is a tool primarily used to optimise the size of the underlying arithmetic circuit. There are some operations for which verifying if an output is correct is much simpler than computing the output value. For these operations, unconstrained code can be used to compute the output and constrained code to verify it is correct. The following example illustrates the mechanics of this idea. It is not a realistic piece of Noir code as this operation is implemented natively in Noir, nor is it really zero-knowledge as it can be inverted simply, but it provides a good didactic tool to explain this code dichotomy.</p><p>The following Noir program computes the multiplicative inverse of a private input x, so a prover can show they know an x whose inverse is the public value invx. In a finite field of prime order p, the inverse is x^(p-2) (Fermat&#39;s little theorem), which can be computed by iterated squaring. The first version does this entirely in constrained code:</p><pre>fn main(x: Field) -&gt; pub Field {<br>    let invx: Field = inv(x);<br>    invx<br>}</pre><pre>fn inv(x: Field) -&gt; Field {<br>    let mut cur = x;<br>    let mut y = 1;<br>    let rep: [u1; 253] = [1, 1, /* ... bits of p - 2, omitted ... */];<br>    for i in 0..253 {<br>        if (rep[i] == 0) {<br>            cur = cur * cur;<br>        } else {<br>            y = y * cur;<br>            cur = cur * cur;<br>        }<br>    }<br>    y * cur<br>}</pre><p>This version generates <strong>379 arithmetic constraints</strong>: the circuit spells out <em>how</em> the inverse is computed. The second version below computes the inverse in unconstrained code, then simply checks that the answer is right:</p><pre>fn main(x: Field) -&gt; pub Field {<br>    let mut invx = 0;<br>    unsafe {<br>        invx = invu(x);<br>    }<br>    assert(invx * x == 1);<br>    invx<br>}</pre><pre>unconstrained fn invu(x: Field) -&gt; Field {<br>    inv(x)<br>}</pre><p>This generates just <strong>2 constraints</strong>. The verifier of the proof only cares that invx is the right inverse, not how the prover found it. As mentioned, Noir has built-in code for computing 1/x, which behaves similarly to this unconstrained version. The two programs agree for every non-zero x; at x = 0 the first returns 0, while the second has no valid witness, because zero has no inverse.</p><p>A bug can be introduced if you forget that assert. Without it, the program produces genuine proofs for <em>any</em> value of invx. This is not a flaw in the underlying ZK proof system but a flaw in the circuit design as it simply doesn&#39;t capture the requirement that invx be the inverse of x, and a malicious prover doesn&#39;t have to satisfy the missing requirement. That&#39;s an <strong>underconstrained bug</strong>: code with a hole in its proof obligations.</p><p>Noir’s compiler has a heuristic check that catches this obvious case: by default it reports a bug when the result of an unconstrained call isn’t involved in any later constraint (this can be turned off with --skip-brillig-constraints-check). The dangerous case is a constraint that is present but too weak. Take integer division, captured by function div_mod below, another operation that is cheap to verify but expensive to compute in constraints:</p><pre>unconstrained fn divide_hint(a: u64, b: u64) -&gt; (u64, u64) {<br>    (a / b, a % b)<br>}</pre><pre>fn div_mod(a: u64, b: u64) -&gt; (u64, u64) {<br>    let (q, r) = unsafe { divide_hint(a, b) };<br>    assert(a == q * b + r);<br>    // forgotten: assert(r &lt; b);<br>    (q, r)<br>}</pre><p>Both q and r appear in a constraint, so the compiler&#39;s check is satisfied, and every <em>honest</em> run returns the right answer. But for a = 10, b = 3, the pair q = 2, r = 4 also satisfies the constraint (so does q = 0, r = 10): a prover can pick among many &quot;valid&quot; quotients. For div_mod, the obligation can be captured by the verification function verify_assert(r &lt; b), and NAVe returns a counterexample such as a = 10, b = 3, q = 0, r = 10.</p><p>It’s worth being clear on why ordinary testing could miss this. <a href="https://noir-lang.org/docs/tooling/tests">nargo test</a> runs #[test] functions on concrete inputs, and a test passes if the program executes while satisfying all of its constraints. When our program runs, the unconstrained divide_hint or invu functions are executed the way an <em>honest prover</em> would execute them: they return the expected value. So every such test passes whether or not the assert is there. The missing constraint only matters to a dishonest prover, and a test doesn&#39;t play that role unless you make it.</p><p>A test can expose the gap, but only if you plan for it. You would need to refactor the code so the claimed inverse, or quotient and remainder are parameters rather than the output of unconstrained code, then write a #[test(should_fail)] that feeds in wrong values and check that the program rejects them. That takes three things: knowing which unconstrained result needs to be distrusted, restructuring the code so bad values can be injected, and picking bad values that hit the hole. For a completely missing assert, almost any wrong value would do. But for subtler gaps, where a constraint is weaker than intended only for particular inputs, hand-written tests and even the <a href="https://noir-lang.org/docs/tooling/fuzzer">fuzzer</a> (coverage-guided, mutating inputs) sample the space rather than cover it. Noir&#39;s compiler checks, like the one above, are syntactic: being involved in a constraint is not the same as being pinned down by it. NAVe treats the result of unconstrained code as unknown, any value at all, and asks whether the constraints still force the property you care about.</p><h3>Enter NAVe</h3><p>NAVe (Noir ACIR formal Verifier) closes that gap. Rather than testing a circuit on sample inputs, NAVe asks an SMT solver whether the circuit’s constraints satisfy a given property for <em>all</em> possible inputs. It’s <a href="https://github.com/blockhouse-sec/nave">open source</a>, and it builds on the existing Noir compiler to produce ACIR, then translates that ACIR into constraints for the SMT solver cvc5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DjwsW_gYyHtXoPJM3l6iOA.jpeg" /><figcaption>NAVe architecture</figcaption></figure><p>We’ll follow one small program through each stage of this pipeline.</p><h3>Step 1: A Noir program with a proof obligation</h3><pre>fn main(x: Field) {<br>    assert(x * (x - 1) == 0);<br>    unsafe { verify_assert((x == 0) | (x == 1)); }<br>}</pre><p>The assert is supposed to force x to be 0 or 1 (a product is zero only if one of its factors is). The second line states what we want to be true. To state a property, NAVe users write verify_assert(cond). Unlike Noir&#39;s built-in assert, which creates a constraint, verify_assert creates a proof obligation: cond must hold in every execution of the program that satisfies its constraints.</p><p>verify_assert is declared by the user as an ordinary unconstrained function, so as far as Noir is concerned it changes nothing: no new language constructs, parsing or compilation are needed. In the inverse example from earlier, the corresponding obligation would be verify_assert(invx * x == 1), which is exactly the check that catches the missing assert.</p><h3>Step 2: Compiling to ACIR</h3><p>The Noir compiler turns this program into ACIR. An ACIR program is a list of opcodes over field variables called <strong>witnesses</strong> (inputs, and intermediate values), each opcode constrains the values the witnesses can take, and a valid assignment to the witnesses represents an execution of the program. ACIR has six opcodes:</p><p>Opcode What it does NAVe’s treatment AssertZero A polynomial expression (degree at most 2) must be equal to zero Encoded as an equality with 0 BlackBoxFuncCall Calls one of 14 functions the proof system provides natively, from range checks to hashes Only Range is formalised so far MemoryInit, MemoryOp Create, read and write arrays Encoded with versioned variables BrilligCall Runs unconstrained code Translated as the always-true constraint Call Calls another ACIR function Not formalised</p><p>The opcode that matters most is AssertZero. It says that a polynomial expression over the witnesses must be equal to zero. An expression is captured by a list of products of the form r·a·b, a list of terms of the form s·c, and a constant q, where r,s, and q are literals (i.e. field values), and a, b, and c are witnesses (i.e. variables in the field). These elements encode the polynomial Σ rᵢ·aᵢ·bᵢ + Σ sⱼ·cⱼ + q, and assert zero constrains it to be zero. Our program compiles to two opcodes (shown in the paper&#39;s notation):</p><pre>AssertZero( ⟨(1, x, x)⟩, ⟨(−1, x)⟩, 0 )   // 1·x·x + (−1)·x + 0 = 0<br>BrilligCall( verify_assert, … )           // the proof obligation</pre><p>The assert became an AssertZero capturing x² − x = 0. The verify_assert call is unconstrained code, so it shows up as a BrilligCall, and NAVe intercepts it at the ACIR level to recover the condition. (Likewise, the assert(invx * x == 1) from the inverse example becomes AssertZero(⟨(1, w1, w2)⟩, ⟨⟩, −1), that is w1·w2 − 1 = 0.)</p><h3>A short detour: SMT, SMT-LIB, and cvc5</h3><p><strong>Satisfiability Modulo Theories (SMT)</strong> generalises boolean satisfiability to richer theories such as integer arithmetic. An SMT formula combines predicates in those theories using boolean operators, and an <strong>SMT solver</strong> tells you whether such a formula is satisfiable: <strong>SAT</strong> (here is a concrete model that satisfies it) or <strong>UNSAT</strong> (no model exists). For undecidable theories, or when a problem is too hard, a solver may also answer <strong>UNKNOWN</strong> (or run out of time/memory).</p><p><a href="https://smt-lib.org/"><strong>SMT-LIB</strong></a> is the de-facto standard for writing these formulas down. It standardises both the theories and the syntax, and even non-standard theories borrow its syntax. For instance, (declare-const x Int) declares an integer, and (assert (or (= x 0) (= x 1))) says x is either 0 or 1.</p><p><a href="https://cvc5.github.io/"><strong>cvc5</strong></a> is an open-source SMT solver. Beyond the standard theories, it implements a non-standard <strong>theory of finite fields of prime order</strong>, with operators such as ff.add (field addition), ff.mul (field multiplication) and ff.bitsum (rebuilds a number from its bits: x1 + 2·x2 + 4·x3 + …). That&#39;s what lets NAVe talk about Noir&#39;s Field type natively.</p><h3>Step 3: Translating ACIR to SMT-LIB</h3><p>An encoding is a way to translate an ACIR program into SMT-LIB constraints. The translation goes opcode by opcode, and the result is the conjunction of the constraints each opcode produces. For AssertZero(exp), the rule is simple: translate the polynomial exp and assert that it equals zero. NAVe supports two encodings of this rule: one using the non-standard theory of finite fields and another using the standard theory of integers. For our example, the finite-field encoding is, roughly:</p><pre>(set-logic QF_FF)<br>(define-sort FF () (_ FiniteField 21888242871839275222246405745257275088548364400416034343698204186575808495617))<br>(declare-const x FF)<br>; AssertZero:  x·x + (-1)·x + 0 = 0<br>(assert (= (ff.add (ff.mul x x) (ff.mul (as ff-1 FF) x)) (as ff0 FF)))</pre><p>and the integer encoding is the same polynomial computed with ordinary integers, taken modulo the field’s prime p, with the witness restricted to [0, p-1]:</p><pre>(declare-const x Int)<br>(assert (and (&gt;= x 0) (&lt; x p)))<br>(assert (= (mod (+ (* x x) (* (- 1) x)) p) 0))</pre><p>Why two encodings? A finite field of prime order p is isomorphic to the integers modulo p, so both are faithful descriptions of the same arithmetic. They differ in how well a solver can handle them:</p><ol><li><strong>The finite-field encoding</strong> uses cvc5’s native finite-field theory directly. Its satisfiability problem is <strong>decidable</strong>.</li><li><strong>The integer encoding</strong> turns each field term into a non-linear integer-arithmetic term and uses a solver’s standard integer theory. Non-linear integer arithmetic is <strong>undecidable</strong> in general, so a solver is not guaranteed to terminate.</li></ol><p>Even though decidability seems to make the finite-field encoding the undisputed winner, in practice, as the evaluation below shows, the two are <em>complementary</em>: some programs are analysed faster with one, some with the other.</p><p>AssertZero is not all there is to translate. ACIR has features that traditional languages don&#39;t, and NAVe handles them too:</p><ul><li><strong>Range checks</strong> (Range(x, n), a BlackBoxFuncCall) say that x fits in n bits. A field element has no notion of size, so the finite-field encoding introduces n fresh variables, constrains each to be 0 or 1, and requires that x be the number those bits spell out (a <strong>bitsum</strong>). The integer encoding can simply say x &lt; 2ⁿ. Cheap to write, but not always cheap to solve.</li><li><strong>Memory operations</strong> (MemoryInit, MemoryOp) are how ACIR represents arrays. Intuitively, NAVe gives each array element a fresh variable every time the array is written, and links consecutive versions: the element written takes the new value, and every other element keeps its old one. A read simply picks out the element at the given index. The paper has the details.</li><li><strong>Unconstrained code</strong> (BrilligCall) is translated as the always-satisfied constraint true. Since we want to know what the <em>constrained</em> code actually pins down, the results of unconstrained code are left completely free. This choice is what allows NAVe to reason about unconstrained code that is not properly constrained.</li></ul><h3>Step 4: Verified, or a counterexample</h3><p>verify_assert is declared as an ordinary unconstrained function, thus the Noir compiler treats it like any other unconstrained call, and it appears in the ACIR as a BrilligCall. NAVe intercepts these calls at the ACIR level (unlike other Brillig calls) and recovers the condition passed to each one, so Noir itself needs no changes.</p><p>For each verify_assert, NAVe builds the formula F = ⟦ACIR program⟧ ∧ ¬cond: the program’s constraints plus the negation of the condition we want to hold. F is satisfiable exactly when some execution of the program violates the condition. The condition is therefore the proof obligation: if the solver finds no such execution, the property holds.</p><p>NAVe hands the encoded program to cvc5. If cvc5 says <strong>UNSAT</strong>, no execution can falsify the condition, so it returns “Verified”. If it says <strong>SAT</strong>, there’s an execution that falsifies it, and cvc5 returns a model, a concrete assignment to the witnesses (including the program’s inputs) that NAVe hands back to the developer as a <strong>counterexample</strong>, which is a powerful debugging device helping the developer identify what is the program behaviour leading to the verify_assert violations. If the solver answers UNKNOWN or times out, the result is inconclusive.</p><p>For our example, the negated obligation is (assert (not (or (= x (as ff0 FF)) (= x (as ff1 FF))))), and cvc5 answers UNSAT: no field element other than 0 and 1 satisfies the constraint. Remove one disjunct, say (x == 1), and NAVe returns a counterexample with x = 1, showing exactly which value the check no longer covers.</p><h3>Why target ACIR instead of Noir?</h3><p>We chose to formalise ACIR rather than Noir directly, for three reasons. First, we benefit from the existing infrastructure that compiles Noir to ACIR, and ACIR’s lower-level nature makes its semantics simpler to capture. Second, for as long as ACIR stays stable (it should be more stable than the language on top of it), NAVe stays compatible as Noir evolves. Third, ACIR is designed to be front-end agnostic, so our formalisation could in future be used to verify other high-level ZK languages that target it.</p><h3>How far does this reach? Testing NAVe against real compiler bugs</h3><p>Underconstrained circuits are the bug class NAVe was designed around, and they’re the main reason to reach for it. But we wanted to show that it can perform analyses that go beyond that. We looked into <strong>compiler bugs</strong>, where the generated constraints don’t match what the code says, independent of anyone misusing unconstrained code. To be clear about what we’re claiming: NAVe didn’t discover these bugs. They were real bugs that Noir’s maintainers had already found, documented and fixed. We picked four from Noir’s public security bug list, reverted the fixes, and checked whether NAVe would have flagged the reintroduced bug.</p><p>For these bugs, we use a different analysis technique. We use assertions to demonstrate that a specific program point is not reachable. This sort of <strong>unreachability</strong> analysis demonstrates another type of useful program reasoning technique that tests cannot practically replicate. A program point annotated with verify_assert(false) act as a <strong>reachability probe</strong>. A &quot;Verified&quot; NAVe output for such a program indicates that this program point cannot be reached. The underlying UNSAT verdict of the SMT solver means that there are <em>no</em> inputs (and more generally combination of witness values) that can drive the program to that point. Tests could mimic this type of analysis if a test case was created for each possible input of the function, clearly impractical in practice.</p><p><strong>NoirVD-SSA-004 (improper field truncation).</strong> The program, with the probe already in place:</p><pre>fn main(v3: u8) -&gt; pub u8 {<br>    let v8 = v3 - 1;<br>    let result = v8 &amp; 1;<br>    unsafe {<br>        verify_assert(false);<br>    }<br>    result<br>}</pre><p>During ACIR compilation, the compiler tries to decompose v8 + 256 into 2x + y, where x is a 7-bit unsigned integer and y is a single bit. The + 256 is a compiler trick to avoid underflow in the subtraction. But the trick breaks the decomposition: 8 bits only cover [0, 255], while 256 + z for any z &gt;= 0 needs 9 bits. The decomposition is <em>impossible</em> to satisfy for any input at all, so the generated constraints are contradictory. This contradiction is what prevents this function from reaching the verify_assert(false) reachability probe. To sum up, a compiler bug (creating an impossible decomposition) is translated into inconsistent constraints which can be detected by this type of unreachability probe with NAVe. In the fixed compiler, x is 8 bits wide, so the 9-bit value v8 + 256 can be decomposed and the probe is reachable, as it should be.</p><p><strong>NoirVD-SSA-002 (inconsistent right shift).</strong> The program:</p><pre>fn main(x: u8) -&gt; pub u8 {<br>    let value = 1 &gt;&gt; x;<br>    assert(x == 8);<br>    unsafe {<br>        verify_assert(false);<br>    }<br>    value<br>}</pre><p>When this bug was originally reported, lhs &gt;&gt; rhs was defined to produce zero whenever rhs was at least the bit width of lhs, so 1_u8 &gt;&gt; 8 should be 0; the language has since changed that behaviour. The program pins x to 8 to prevent a compiler optimisation from hiding the bug. NAVe exposes the inconsistency in the generated constraints by returning &quot;Verified&quot; for the always-false probe, even though x = 8 is a perfectly valid input. With assert(x == 7) instead, NAVe returns &quot;Falsified&quot; for verify_assert(false) – a valid input exists – and &quot;Verified&quot; for verify_assert(value == 0).</p><p>Both bugs make the circuit unsatisfiable, so an honest prover can’t produce a proof, and running a valid input through nargo execute would fail too. What the probe adds is an answer for all inputs at once, at any input size. The more dangerous compiler bugs go the other way, dropping a constraint so that a malicious prover can prove a false statement. Those are underconstrained circuits by another route, and they are what the property checks above are for.</p><h3>How it holds up</h3><p><strong>Is the translation correct?</strong> We derived the formalisation from the informal ACIR specification, and then tested it against Noir’s own test infrastructure. We selected two sets of test programs with concrete inputs, within the ACIR subset we cover: one set whose executions fail, one whose executions succeed. With the inputs fixed, a failing execution should translate to an <em>unsatisfiable</em> formula and a succeeding one to a <em>satisfiable</em> formula. Across 331 programs — 218 with range checks, 113 without — NAVe reported <strong>no wrong results</strong>. Results were either conclusive and as expected, or inconclusive because the program exhausted its time or memory budget:</p><p>Backend Conclusive (of 331) With range checks (of 218) Without (of 113) Integer encoding 275 166 109 Finite field, --ff=split 230 119 111 Finite field, --ff=gb (default) 179 68 111</p><p>The two finite-field rows use two different cvc5 solvers for the same theory. gb is based on Gröbner bases, the standard algebraic technique for deciding polynomial systems; split is a more recent technique that <em>approximates</em> it by splitting the problem, and can be very effective on certain combinations of bitsum constraints. The table shows why they matter: without range checks they tie (111 each), while on range-check programs split is conclusive on 119 programs to gb&#39;s 68.</p><p><strong>How fast is it?</strong> We then annotated a selection of these programs with verification conditions — both ones that hold (“Verified”) and ones that don’t (“Falsified”) — and timed each backend with a 120-second timeout. The result: <strong>there is no clear winner</strong> between the three backends. There are programs where the integer encoding is the quickest and others where it alone times out; the two finite-field solvers behave almost identically on programs without range checks, and split significantly outperforms gb on several programs with them.</p><p><strong>Why are range checks the hard case?</strong> A range check pins a value to an interval. Enforcing that in the field encoding means decomposing the value into individual bits, constraining each to 0 or 1, and reconstituting the value as a sum (a <strong>bitsum</strong>) — at least one constraint per bit. A 32-bit range check is already dozens of constraints, and our benchmarks include checks of up to 238 bits. For a solver, that is a large conjunction to reason about jointly: the finite-field theory is decidable, but the sheer size and structure of these bitsum formulas drives up solve time, and larger bit widths are where we see timeouts.</p><p><strong>cvc5 bug</strong>. Testing NAVe also turned up something we didn’t expect: a soundness bug in cvc5’s finite-field split solver. On a satisfiable formula, as small as 2·w0 + w1 = 4 over the field (where w0 = 0, w1 = 4 is an obvious solution), the solver answered UNSAT. The cause was a misplaced overflow check: the solver rewrites that constraint as bitsum(w1, w0) = 4, then reasons that a bitsum of two bits can only reach values below 2² (that is, at most 3), so it can&#39;t equal 4, and returns UNSAT. That reasoning is only valid if the summands are known to be bits, and here nothing constrained them to be. This is the dangerous direction for a verifier: UNSAT means &quot;Verified&quot;, so NAVe, or any other tool relying on that solver, could in principle have reported a flawed circuit as safe. The full story is in our separate post: <a href="https://hackmd.io/@pedrotbtl/r1RTazmYZl">A Soundness Bug in cvc5&#39;s Finite Field Split Solver.</a></p><h3>What NAVe covers today</h3><p>NAVe formalises a subset of ACIR: arithmetic constraints, memory operations, unconstrained calls and the Range black box. The other black-box functions (hash functions such as SHA-256, Keccak and Poseidon2, and signature checks such as ECDSA) and the Call opcode aren&#39;t supported yet, so circuits that rely on them can&#39;t be fully analysed today. Large range checks can also push the solver into timeouts. Real Noir applications use hashes and signatures everywhere, so this is the main limitation to keep in mind when trying NAVe on a production circuit.</p><h3>Try it</h3><p><a href="https://github.com/blockhouse-sec/nave">NAVe</a> is open source and works from ordinary Noir programs: annotate with verify_assert, run the verifier, and read back either &quot;Verified&quot; or a counterexample. If you&#39;re maintaining Noir circuits, the main failure mode worth watching for is the one we&#39;ve walked through: a missing constraint that lets underconstrained inputs slip through a circuit that looks, and even tests, perfectly fine. Ordinary tests are poorly placed to see it, and it&#39;s exactly what a solver-backed check is built to find. And whatever you verify, add a verify_assert(false) probe too – so you know your properties aren&#39;t vacuously true.</p><h3>About TBTL Security</h3><p>TBTL’s security division specialises in smart contract and zero-knowledge program audits, built on formal methods expertise. Our team combines decades of academic research in formal verification with deep practical experience in Web3 security — bringing the discipline of formal reasoning to every engagement. If you are building a DeFi protocol and want an audit that goes beyond pattern-matching, <a href="https://security.tbtl.com/">get in touch</a>.</p><p><em>Tags: zero-knowledge, formal-verification, noir, cryptography, rust</em></p><p><strong>Sources and further reading:</strong></p><ul><li><a href="https://arxiv.org/pdf/2601.09372">Formally Verifying Noir Zero Knowledge Programs with NAVe</a> — Antonino and Jain, the paper this post is based on</li><li><a href="https://github.com/blockhouse-sec/nave">NAVe repository</a> — the verifier, the example programs, and instructions to reproduce the evaluation</li><li><a href="https://aztec.network/noir">Aztec Network — Noir</a> — the community behind the Noir language; see also the <a href="https://noir-lang.org/">Noir language site</a></li><li><a href="https://www.researchgate.net/publication/221355016_How_to_Explain_Zero-Knowledge_Protocols_to_Your_Children">Quisquater et al., “How to Explain Zero-Knowledge Protocols to Your Children”</a> — the original Ali Baba’s Cave illustration</li><li><a href="https://cvc5.github.io/docs/cvc5-1.3.1/theories/finite_field.html">cvc5 finite fields theory reference</a>, plus the papers behind it: Ozdemir et al., <em>Satisfiability Modulo Finite Fields</em> (CAV 2023) and <em>Split Gröbner Bases for Satisfiability Modulo Finite Fields</em> (CAV 2024)</li><li><a href="https://github.com/noir-lang/noir/blob/master/security/entomotaxy/Security%20Bug%20List.md">Noir security bug list</a> — source of NoirVD-SSA-004 and NoirVD-SSA-002</li><li><a href="https://tornado-cash.medium.com/tornado-cash-got-hacked-by-us-b1e012a3c9a8">Tornado Cash got hacked. By us.</a> and the <a href="https://github.com/0xPARC/zk-bug-tracker">0xPARC ZK bug tracker</a> — real-world ZK circuit vulnerabilities</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ecac75a7b44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Property-Driven AI-Assisted Security Reviews]]></title>
            <link>https://medium.com/@tbtl/property-driven-ai-assisted-security-reviews-a835d17c11fd?source=rss-fe5f088b5c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a835d17c11fd</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[The Blockhouse Technology Ltd]]></dc:creator>
            <pubDate>Fri, 11 Sep 2026 08:58:58 GMT</pubDate>
            <atom:updated>2026-09-11T08:58:58.628Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IWR5Gtv6ogy5fShqyDu9pA.png" /></figure><p>Security teams now use LLMs to review real codebases, sometimes before or even instead of a human audit. And the most recent work on making that effective focuses on orchestration. For instance, the harness described in Cloudflare’s public write-up runs hundreds of separate investigations against 128 repositories continuously, each one persisted, deduplicated, and cross-checked rather than living inside one throwaway context window. Academic work on smart-contract auditing specifically has gone in the same direction: multi-agent systems where one model hunts, another validates, another argues the first two out of a false positive, and self-evolving auditor teams that refine their own coverage over repeated passes. This is clearly where the field’s energy is going.</p><p>All that infrastructure depends on a simpler, more important decision: what you actually tell each agent to look for. If you run a thousand investigations, each one follows the instructions you give it. If those instructions are flawed, persistence and deduplication won’t fix the problem. They just repeat the same mistake many times.</p><blockquote><em>More agents don’t fix a bad decision about what to look for. <br>They just run it at scale.</em></blockquote><p>So we ran a much smaller experiment: three related vulnerabilities and repeated audits with only the framing of the instructions changing. We varied how much information the model was given and how the task was presented: from no guidance, through increasingly specific descriptions of the vulnerability, to the property that had to hold, the same property paired with a verification procedure, and finally the attack enabled by the violated property.</p><h3>A single property</h3><p>To make the comparison as clean as possible, we wanted real vulnerabilities that shared the same underlying property violation. We found three: <strong>Sonne Finance</strong>, <strong>Pareto’s sUSP vault</strong>, and <strong>Napier’s </strong><strong>BaseLSTAdapter</strong>. They are different protocols and use different implementations. Still, in each case the exchange rate between an underlying asset and its receipt token can be changed by an asset balance that the protocol merely <em>observes</em>, rather than by an accounted change in the number of shares.</p><p>We capture this common requirement as the following “Exchange-Rate Integrity” property:</p><blockquote><strong><em>The exchange rate between the underlying token and a pool share can only be modified by accounted minting, burning, or yield-accrual operations; any other transaction must preserve the exchange rate.</em></strong></blockquote><p>Formally, let <strong><em>r(s)</em></strong> denote the exchange rate between the underlying asset and a pool share in contract state <strong><em>s</em></strong>. We require that, for every state transition <strong><em>t : s → s′</em></strong>, the exchange rate remains invariant unless <strong><em>t</em></strong> performs an operation that is explicitly intended to modify the pool’s asset/share ratio. That is,</p><p><strong><em>r(s′) ≠ r(s) ⟹ t ∈ T</em></strong></p><p>Here, <strong><em>T </em></strong>denotes the set of operations that can legitimately modify the pool’s asset/share ratio and whose effects are explicitly accounted for by the protocol’s state or accounting mechanisms. Thus, any change in <strong><em>r</em></strong> must be attributable to a protocol-recognised operation in <strong><em>T</em></strong>, rather than to an unaccounted change in the underlying asset balance.</p><p>The three cases differ in what happens when this property is violated. <strong>Sonne Finance</strong> is the one in which the violation was actually exploited: a Compound V2 fork on Optimism, drained of roughly $20M on 14 May 2024. <strong>Pareto sUSP</strong> and <strong>Napier’s </strong><strong>BaseLSTAdapter</strong> were caught in Sherlock contests before exploitation.</p><h4>Sonne Finance</h4><p>Sonne Finance operates as a Compound V2-style lending protocol. In this architecture, users deposit underlying assets (e.g., VELO) into a shared pool and receive yield-bearing receipt tokens (e.g., soVELO) representing their claim on the pool. In Sonne, the exchange rate is derived directly from the market’s observed underlying balance:</p><pre>// CToken.sol :: exchangeRateStoredInternal()<br>uint256 totalCash = getCashPrior();   // the market&#39;s own balance of the underlying<br>uint256 exchangeRate =<br>    ((totalCash + totalBorrows - totalReserves) * expScale) / _totalSupply;</pre><p>In standard lending operations (<strong><em>t ∈ T</em></strong>), depositing the underlying asset (VELO) triggers a protocol mint function. This increases totalCash while simultaneously issuing new receipt tokens (soVELO) to the depositor, expanding _totalSupply proportionally to keep the exchange rate invariant.</p><p>However, getCashPrior() relies on an unmanaged ERC-20 query (balanceOf(address(this))) rather than an internal accounting ledger. A direct transfer of the underlying asset increases totalCash (the numerator) without executing the minting routine that updates _totalSupply (the denominator). This unaccounted donation forces an immediate, unbacked shift in the exchange rate <strong><em>r(s)</em></strong> outside of <strong><em>T</em></strong>, breaking exchange-rate integrity. The redemption path then converts an underlying amount back into receipt tokens using truncating integer division. Together, these two conditions made the known Compound V2 precision-loss attack possible.</p><p>The attacker exploited this structural vulnerability against the newly listed market through the following steps:</p><ol><li><strong>Market Front-Running.</strong> Permissionless execution of unbatched timelock transactions allowed the attacker to activate the new soVELO market before the protocol could mint the intended initial safety shares.</li><li><strong>Dust Minting.</strong> The attacker deposited 400,000,001 wei of VELO to mint just 2 wei of soVELO, leaving _totalSupply minimal and the exchange rate r(s) extremely sensitive to cash additions.</li><li><strong>Unaccounted Donation.</strong> The attacker flash-borrowed ~35.47M VELO and transferred it directly to the contract. Because this transfer (<strong><em>t ∉ T</em></strong>) altered totalCash without updating _totalSupply, it violated exchange-rate integrity and artificially inflated 1 wei of soVELO to ~17.75M VELO.</li><li><strong>Collateralised Borrow.</strong> Using the 2 wei of artificially inflated soVELO as collateral, the attacker borrowed ~265 WETH from the protocol.</li><li><strong>Precision-Loss Exit &amp; Exploitation Loop.</strong> Redeeming ~35.47M VELO required burning 35.47M/17.75M ≈ 1.99 wei of soVELO. Integer division truncated this to 1 wei, allowing the attacker to reclaim their VELO while burning half their shares. The attacker then repeated this donation-borrow-redemption cycle to drain other listed markets.</li></ol><h4>Pareto and Napier</h4><p>The other two cases have the same structural violation, but a different outcome. <strong>Pareto’s sUSP vault</strong> and <strong>Napier’s </strong><strong>BaseLSTAdapter</strong> use ERC-4626 accounting in which totalAssets() depends on balances that can be increased by a plain transfer. Napier’s stETH adapter returns withdrawalQueueEth + bufferEth + STETH.balanceOf(address(this)); Pareto’s returns the vault’s own USP balance less the unvested portion of rewards. A direct transfer can therefore move the share price without minting corresponding shares.</p><p>Here the effect surfaces on the way in rather than on the way out. Neither vault overrides _decimalsOffset(), so both fall back to OpenZeppelin 4.9.3’s default ERC-4626 conversion. An unsolicited transfer can still increase totalAssets() without increasing totalSupply(), causing the next depositor’s conversion to round their shares down, with the rounding loss borne by the depositor rather than the existing shareholders. The property is violated even though the same mechanism does not provide the attacker with a profitable exploit.</p><h3>The evaluation</h3><p>Today’s large language models can analyse unfamiliar codebases, connect behaviours across contracts, and explain vulnerabilities in detail. It might seem like finding a known bug should be easy: just give the model the code, ask for an audit, and let it figure things out. But prompt engineering suggests that the way we instruct the model can change what it finds. The real question may not be how much instruction we give, but what we ask the model to focus on and reason about. Does it help to describe the bug or explain how to search for it? Or is it better to state a property the system must maintain and let the model find where that property fails? We ran a small experiment to test this.</p><h4>The setup</h4><p>We kept the code, models, and audit procedure fixed, and changed only the instructions. We pinned each case to the vulnerable commit, and each run was a fresh, full-repository audit with no conversation or follow-up. We tested Fable 5, Opus 5, Sonnet 5, and Haiku 4.5 at the same reasoning effort, with at least three repetitions. To answer our leading question, we compared a blind audit, four increasingly specific bug hints, the shared property, the property plus a verification procedure, the same idea framed as an attack, and a sanity test with the full bug description. Everything else stayed the same.<br> We scored a finding only when it identified the real mechanism. A deterministic file/line overlap check first filtered candidates; then an independent model compared the finding’s reasoning with a ground-truth description written from the fix diff, and borderline cases were decided by majority vote.</p><p>To keep Claude restricted, the models only had access to the code — no internet, no shell, and read-only access limited to the target checkout. Everything else was blocked and logged. The answer key and hints were stored in a separate directory the models couldn’t access. We confirmed this setup worked because some runs tried to use git log -p to read future changes, and others tried to fetch the fixed version of the file from GitHub.</p><p>All the input files used in the evaluation — including prompts, ground-truth descriptions, vulnerable commits, properties, and other materials — are available in the accompanying repository. This lets anyone inspect and reproduce the exact instructions for each run: <a href="https://github.com/blockhouse-sec/blog-property-llm-security-review">https://github.com/blockhouse-sec/blog-property-llm-security-review</a>.</p><h4>The instructions</h4><p>Each condition uses the same prompt, with one paragraph swapped. The fixed part sets the role and the reporting contract — name the category, the file, the function, and the exact line range, quote the code verbatim, walk through the exploitation step by step, rate severity and your own confidence, and report nothing you can’t ground in code you actually read:</p><blockquote><em>You are a senior Web3 security auditor. Audit this repository and report any security vulnerabilities you find.</em></blockquote><p>That blind condition serves as the baseline against which every other configuration is measured. Each of the others drops one paragraph into the same slot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*09yalCZGN0E6sWhbnOyB5Q.png" /><figcaption>Table 1: task variations.</figcaption></figure><p>The conditions separate two ways of directing an audit: describing the suspected bug and stating what the system must preserve. The <strong>hints</strong> condition describes the vulnerability and its consequences, while the <strong>property</strong> condition gives the model a semantic requirement and leaves it to identify where the implementation violates it. The <strong>property + procedure</strong> condition tests whether explicitly specifying how to verify the property provides additional benefit. <strong>Attack framing</strong> expresses essentially the same information as the property, but as an adversarial scenario rather than a system requirement.</p><p>The <strong>hints</strong> condition represents the natural approach of telling the model what kind of vulnerability to look for. It provides information about the attacker’s gain, the affected surface, the underlying flaw, and the circumstances that trigger it:</p><blockquote><em>An attacker can come away with more of the underlying token than their share of the pool is worth, at the expense of the other participants. The weakness sits in the everyday path that converts underlying tokens into pool shares and shares back into tokens. What is broken there is the exchange rate itself — how many shares a given amount of the underlying buys — not the access control and not the token transfers. That rate is not sound under every sequence of operations: whether it is right turns on the circumstances in which a deposit or redemption happens, not on the amounts supplied.</em></blockquote><p>The <strong>property</strong> condition takes the opposite approach. Rather than describing the vulnerability, it states the relationship that the implementation is required to preserve:</p><blockquote><em>The exchange rate between the underlying token and a pool share can only be modified by accounted minting, burning, or yield-accrual operations; any other transaction must preserve the exchange rate.</em></blockquote><p>This contains substantially less information about the specific vulnerabilities: it mentions no donations, no rounding, no empty markets, no ERC-4626, and no particular contract or function. The model must instead connect the system-level requirement to the implementation and determine where that requirement can be violated.</p><p>The <strong>property + procedure</strong> condition tests whether that reasoning benefits from an explicit verification procedure. If it performs better than the property alone, the procedure provides useful additional guidance; if not, the property may already give the model enough structure to carry out the relevant checks itself.</p><p><strong>Attack framing</strong> tests a different presentation of essentially the same underlying relationship. Instead of saying what the system must preserve, it describes an attacker manipulating that relationship to the detriment of another participant. Comparing the two therefore helps distinguish the effect of expressing the guidance as a system property from the effect of giving a concrete adversarial narrative.</p><p>Finally, the <strong>full bug description</strong> gives the answer away and is used only as a sanity check. It is not included in the main comparison; its purpose is to verify that the models and evaluation procedure can recognise the vulnerabilities when the relevant mechanism is explicitly described.</p><h4>The results</h4><p>The evaluation results give a fairly direct answer to the question we started with: <strong>what should we give an LLM when we want it to find a particular class of vulnerability?</strong> Across the three cases, however, the results do not show a smooth relationship between more guidance and better detection. Instead, they show a noticeable difference between <em>describing a bug</em> and <em>declaring a property the code must preserve</em>.</p><p>The first figure shows the detection rate for each model and instruction condition. The pattern is not uniform across models, but the property condition is among the strongest-performing configurations for the models that detect these cases most reliably. For Opus, the property reaches the highest detection rate shown in the experiment, while attack framing and property + procedure also perform strongly. Sonnet shows a different ordering, with attack framing performing particularly well and the property remaining clearly above the blind condition. Haiku performs substantially worse overall and does not benefit from the property condition in these cases. Fable, for which we evaluated the blind and property conditions, also shows a considerable improvement under the property framing.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2Fi390z%2F2%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2Fi390z%2F2%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2Fi390z%2Fplain-s.png%3Fv%3D2&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="383" frameborder="0" scrolling="no"><a href="https://medium.com/media/3251eb14a6727aabdd1da7672037bfe4/href">https://medium.com/media/3251eb14a6727aabdd1da7672037bfe4/href</a></iframe><p>The important comparison is therefore not simply whether more information helps. In this experiment, the property framing appears to be a more effective form of guidance than the progressively detailed bug hints for the stronger models. The property contains less information about the specific vulnerability, yet it gives the model a semantic condition against which it can examine the implementation. The hints, by contrast, describe characteristics of the suspected bug and ask the model to locate an instance of that description.<br> The result is also not explained by a simple monotonic effect of adding instructions. The property + procedure condition does not consistently improve on the bare property. For Opus, the two conditions perform similarly, while for Sonnet the additional procedure is associated with a noticeably lower detection rate. Haiku remains weak under both. This suggests, as an interpretation of the transcripts rather than a conclusion established by the aggregate rates alone, that the models may already be capable of carrying out much of the relevant verification procedure once the property has identified what should be preserved. Adding an explicit checklist can therefore add structure without necessarily adding useful information.<br> Attack framing provides another useful comparison. It expresses essentially the same underlying information as the property, but as an attack involving an agent and a victim rather than as a rule the system must preserve. Across the three cases, attack framing performs strongly for Opus and Sonnet and substantially better than the blind condition for all three models. Its performance is close to the property for Opus and Sonnet, although the relative ordering differs between them. This suggests an alternative interpretation: the useful ingredient may not be the word property itself, but identifying a specific system-level relationship and the circumstances under which that relationship may legitimately change.</p><p>The hints provide a weaker and less consistent signal. Opus and Sonnet both improve substantially over the blind condition with hints, but their detection levels remain below their strongest property- or attack-based configurations. Haiku provides a useful counterexample: its performance remains poor regardless of whether it receives the hints, attack framing, or the property. Thus, the experiment does not support the stronger claim that a property is universally superior to a bug description. Rather, for the models and cases evaluated here, property-based framing appears to be especially effective at directing the reasoning of the stronger models.</p><p>There is also an important case-level distinction behind the pooled results. Sonne Finance is substantially easier for the models than Pareto and Napier, regardless of framing. The Sonne vulnerability was exploited in practice and follows the familiar Compound V2 donation/precision-loss pattern. In contrast, Pareto and Napier involve the subtler effect of an unsolicited asset transfer changing an ERC-4626 share price and shifting rounding loss onto a subsequent depositor. The pooled results should therefore not be read as showing that every case responds in the same way to every instruction. Rather, they capture the aggregate behaviour across vulnerabilities that share the same underlying property but differ considerably in implementation and exploitability.</p><p>This distinction also helps explain why the property result is interesting. The same property was reused unchanged across all three codebases, even though the cases differed in protocol, implementation, and consequence. The instruction did not identify a contract, function, transfer pattern, rounding operation, or known attack. It instead specified the relationship that should stay invariant. The models then had to connect that requirement to the particular implementation they were auditing.</p><h4>What it cost</h4><p>There was another interesting result: the property wasn’t just more accurate; it was cheaper too. The second figure reports US dollars per confirmed finding, rather than cost per audit run, so it combines output volume with the effectiveness of each condition.</p><p>The property conditions are among the least expensive configurations for the models that successfully detect the vulnerabilities. For Opus, the property and property + procedure have substantially lower cost per confirmed finding than the blind, hint, and attack-framing conditions. Sonnet shows a similar pattern, with the property and attack framing at the lowest end of the comparison and the blind condition substantially more expensive.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2FCum4U%2F1%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2FCum4U%2F1%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2FCum4U%2Fplain-s.png%3Fv%3D1&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="461" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5a991ae0d28b175657beaff4d649ad6/href">https://medium.com/media/b5a991ae0d28b175657beaff4d649ad6/href</a></iframe><p>In this experiment, property framing often gave the best mix of detection and cost. The clearest example is Opus, where the property approach had both the highest detection rate and a much lower cost per confirmed finding compared to using hints.</p><p>A possible explanation is that a property gives the model a relatively precise stopping criterion: once it has identified the quantity that should be preserved, it can trace the relevant state changes and test whether the implementation permits an illegitimate change. A bug description instead leaves the model with a more open-ended search for an instance matching the description, while attack framing requires it to construct a concrete narrative involving an attacker, victim, sequence of actions, and resulting gain. These differences could affect how much output the model produces before reaching a confirmed finding, but the present experiment does not isolate the mechanism directly.</p><p>One thing to note: our evaluation measures recall, not precision. We check if the model finds the known vulnerability, but we don’t count false positives. So, the cost results show how efficient each approach is at finding these vulnerabilities, not their overall cost-effectiveness.</p><h3>The takeaway</h3><p>This was a small evaluation, but the result stood out: giving LLMs the property the system must preserve worked better than giving detailed hints, a search procedure, or an attack scenario. While three cases can’t prove everything, this finding points to a useful principle for LLM-assisted security reviews.</p><p>This changes what we should focus on in AI-assisted security reviews. Instead of longer instructions or better bug descriptions, we should highlight the <strong>properties the protocol needs to preserve</strong>. These are already common in formal specs and invariant tests. Our finding is that they can also guide an LLM’s reasoning, even if there’s no formal specification for the code.</p><p>This doesn’t make the harness less important. Instead, it highlights a key decision: when setting up each investigation, start by defining a property to check, not just a suspected bug.</p><h3>About TBTL Security</h3><p>TBTL’s security division specialises in smart contract and zero-knowledge program audits, built on formal methods expertise. Our team combines decades of academic research in formal verification with deep practical experience in Web3 security — bringing the discipline of formal reasoning to every engagement. If you are building a DeFi protocol and want an audit that goes beyond pattern-matching, <a href="https://security.tbtl.com/">get in touch</a>.</p><p><strong>Sources</strong></p><ul><li><a href="https://blog.cloudflare.com/build-your-own-vulnerability-harness/">Build your own vulnerability harness</a> (Cloudflare)</li><li><a href="https://arxiv.org/abs/2604.20801">AgentFlow: Multi-Agent Harness Synthesis for Vulnerability Discovery</a> (ten zero-days found in Chromium, two CVE-confirmed critical)</li><li><a href="https://arxiv.org/pdf/2410.09381">LLM-SmartAudit: Advanced Smart Contract Vulnerability Detection</a> (multi-agent conversational auditing for smart contracts)</li><li><a href="https://www.anthropic.com/research/property-based-testing">Finding bugs with Claude and property-based testing</a> (Anthropic)</li><li><a href="https://arxiv.org/html/2606.22936">When Agents Commit Too Soon: Diagnosing Premature Commitment in LLM Agents</a> and <a href="https://arxiv.org/pdf/2601.22208">Stalled, Biased, and Confused</a> (early fixation as a known agent failure mode)</li><li>Sonne Finance post-mortems: <a href="https://medium.com/@SonneFinance/post-mortem-sonne-finance-exploit-12f3daa82b06">Sonne Finance</a>, <a href="https://blog.verichains.io/p/compound-v2-forked-vulnerability">Verichains</a>, <a href="https://www.certik.com/blog/sonne-finance-incident-analysis">Certik</a></li><li>Sherlock judging issues: <a href="https://github.com/sherlock-audit/2024-01-napier-judging/issues/94">Napier #94</a>, <a href="https://github.com/sherlock-audit/2024-01-napier-judging/issues/125">#125</a>, <a href="https://github.com/sherlock-audit/2025-04-pareto-contest-judging/issues/16">Pareto #16</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a835d17c11fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond Standard Audits: Why DeFi Needs Formal Reasoning Before Every Deploy]]></title>
            <link>https://medium.com/@tbtl/beyond-standard-audits-why-defi-needs-formal-reasoning-before-every-deploy-7fa362fb42ac?source=rss-fe5f088b5c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fa362fb42ac</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[formal-reasoning]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[formal-verification]]></category>
            <dc:creator><![CDATA[The Blockhouse Technology Ltd]]></dc:creator>
            <pubDate>Mon, 25 May 2026 12:55:05 GMT</pubDate>
            <atom:updated>2026-05-25T13:05:50.278Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>A forgotten burn and a lack of access control: two real exploits, each caused by a single line of code, worth millions. Yet, thinking precisely about what each function must guarantee would have prevented both.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tfGSyvkWaADiT32ojbj3OQ.png" /></figure><p>Smart contracts are fast to exploit but slow to fix. Even with upgradeable proxies, admin roles, and emergency multisigs, the response window is never fast enough. A fix needs someone to notice the drain, diagnose the root cause, write a patch, coordinate signers, and broadcast… all while funds keep moving. When there’s a governance timelock, the gap is even wider.</p><p>To mitigate those risks, most teams rely on audits and test suites. Tests, by design, only cover the scenarios someone thought to write. They can typically demonstrate the existence of bugs but not their absence. Without formal reasoning, auditors rely on their expertise and judgment to check the executions they can think of and bad code patterns they are aware of. Neither attempts to systematically establish whether <em>a bad state can be reached</em>, i.e. there exists an input in a reachable state that breaks your protocol. Ensuring that no bad state is reachable amounts to establishing that the protocol is safe.</p><p>Formal reasoning starts with a discipline: before (writing or) reviewing a function, ask what it must always guarantee. Not “does this function look right?”, but “what is the expected behaviour of this function?” Writing down this (function) <em>specification</em> precisely — as a logical property rather than a comment or a test — is the core of the practice. A formal verifier then takes that specification/property and checks it exhaustively. We’ll return to the mechanics of how a verifier checks those properties after the two bugs. For now, the intuition is enough. If you don’t want to take our word for it, you can check out what <a href="https://vitalik.eth.limo/general/2026/05/18/fv.html">Vitalik has to say about formal reasoning and verification and their role in the future of Ethereum and software development more generally</a>.</p><p>This article walks through two real DeFi bugs, each one tracing back to a single line of code. Millions were at stake, but a short formal property could have caught each one: a specification (or spec, for short) described in a few lines stating what the function must guarantee.</p><p>These two bugs happen at two different moments in a protocol’s life. One was there from day one. The other was introduced by an upgrade. Together, they make the case for applying formal reasoning at every stage of development, and using verification tooling to back it up where the stakes are highest.</p><blockquote>The artefacts and instructions to run the formal verification are on our <a href="https://github.com/blockhouse-sec/blog-formal-audit-demo">GitHub</a>.</blockquote><h3>Bug #1: The Forgotten Burn</h3><p><strong>Eleven Finance — June 2021, ~$4.5M lost</strong> (<a href="https://peckshield.medium.com/eleven-finance-incident-root-cause-analysis-123b5675fa76">source</a>)</p><p>Eleven Finance was a yield aggregator on BSC. Users deposited LP (Liquidity Provider) tokens into a vault and received share tokens in return. When withdrawing, shares get burned, and LP tokens come back. Simple enough.</p><p>The vault had two ways to get your tokens out:</p><p><strong>withdraw() </strong>: Burns the user’s shares, sends LP tokens back. Accounting stays balanced.</p><p><strong>emergencyBurn()</strong> : Sends LP tokens back, <strong>forgets to burn shares</strong>. User keeps their claim.</p><p>The attack was fairly simple: deposit, call emergencyBurn() to get tokens back while keeping shares, then call withdraw() to use those shares again and drain other people’s tokens. Repeat.</p><p>PeckShield, the security firm that analysed it, confirmed the function had been in the codebase since launch. The kind of subtle, single-line omission that’s easy to miss in a manual review of a large codebase, especially when the function superficially resembles correct code nearby.</p><p>This is the kind of bug that sits in plain sight. The reasoning question is simple: what must emergencyBurn always guarantee? Any answer that takes the function seriously has to include: the caller’s claim on the vault is settled. Writing that down as a property makes the missing burn obvious, before you think about attacks, before you trace execution paths. The withdraw() function had the right logic. Someone likely wrote emergencyBurn() in a hurry, copied the withdrawal flow, and dropped one line. No test caught it because no test called emergencyBurn() followed by withdraw(). Asking “what must this function always guarantee?” would have.</p><h4>The property that catches it</h4><blockquote><strong>Postcondition:</strong> After emergencyBurn is called, the caller’s share balance must be zero.</blockquote><p>emergencyBurn() violates this immediately. Tokens leave, shares stay. A formal verifier flags it before deployment, no need to imagine the attack sequence.</p><p>The <a href="https://github.com/Certora/CertoraProver">Certora Prover</a> is one tool that operationalises this. You write a spec in CVL (Certora Verification Language) describing what your contract must guarantee, and the Certora Prover checks that property against every possible execution. Here’s what that looks like for this bug:</p><pre>rule emergencyBurnSetsCallerBalanceToZero(env e) {<br>  // Rule is only meaningful when the caller actually holds shares.<br>  require balanceOf(e.msg.sender) &gt; 0;<br>  emergencyBurn(e);<br>  assert balanceOf(e.msg.sender) == 0,<br>     &quot;emergencyBurn must leave the caller with zero shares&quot;;<br>}</pre><p>State what the function must guarantee, and the solver finds any violation. This bug existed from day one. The reasoning question would have caught it at design time. The verifier would have confirmed it <strong>before the initial deployment.</strong></p><h3>Bug #2: The Unguarded Burn</h3><p><strong>SafeMoon — introduced by an upgrade</strong> (<a href="https://rekt.news/safemoon-rekt">source</a>)</p><p>SafeMoon is a reflection token on BSC. Every transfer automatically redistributes a fee across all holders. The protocol also includes a bridge: tokens are burned on one chain and minted on the other.</p><p>Two functions handle that bridge:</p><p><strong>mint(address user, uint256 amount)</strong>: creates tokens from the bridgeBurnAddress. Restricted to whitelisted callers via onlyWhitelistMint.</p><p><strong>burn(address from, uint256 amount)</strong>: moves tokens into the bridgeBurnAddress. No restriction whatsoever.</p><p>The asymmetry is the bug. mint is guarded. burn is not. Anyone can call burn(victim,amout) and destroy any wallet’s balance, not moving funds to the attacker, just annihilating them. The victim loses tokens. The attacker spends gas. The protocol breaks.</p><p>This wasn’t there from day one: an upgrade introduced it.</p><h4>The property that catches it</h4><p>The reasoning question here is: who is permitted to reduce a user’s balance? Answering that precisely — before writing the code, or before approving an upgrade — produces the property almost automatically. In this protocol, that means one of four things: the user themselves, an approved spender with enough allowance, the contract owner, or a whitelisted bridge address. Written as a CVL rule, that property covers every function in the contract, including ones not yet written:</p><blockquote><strong>Postcondition:</strong> If a user’s balance decreased, then msg.sender must be the user, hold sufficient allowance, be the owner, or be a whitelisted bridge address.</blockquote><p>In CVL (Certora):</p><pre>rule onlyUserOwnerOrApprovedCanReduceBalance(address user, method f) {<br>  uint256 before = balanceOf(user);<br>  env e;<br>  calldataarg args;<br>  f(e, args);<br>  uint256 after = balanceOf(user);<br>  assert after &lt; before =&gt;<br>     e.msg.sender == user ||<br>     allowance(user, e.msg.sender) &gt;= before - after ||<br>     e.msg.sender == owner() ||<br>     whitelistMint(e.msg.sender);<br>}</pre><p>The call burn(victim,1) violates this. The caller satisfies none of the four conditions. The solver returns a concrete counterexample: msg.sender=attacker, from=victim, amount=1. The property was violated before the function was even deployed to the mainnet.</p><h4>No need for spec upgrade</h4><p>This is where the second bug makes a different argument than the first.</p><p>Eleven Finance’s bug lived in the code from launch. Catching it was a matter of running verification before the initial deploy. SafeMoon’s bug was introduced later, through a code change. But notice what didn’t change: the spec. The property was already written. No one needed to anticipate the specific regression and write a new rule for it.</p><p>That’s the key property of method f. It doesn’t check burn. It doesn’t check transfer. It checks <em>every function in the contract</em>, parametrically, automatically, including functions added or modified in any future upgrade. The moment burn lost its access control, the solver would have flagged it on the next verification run, not because someone thought to write a targeted test for that specific change, but because the general property was already covering every path that can reduce a balance.</p><p>A test suite checks what you remembered to test. A parametric rule over method fchecks everything, including the function someone quietly changed at 2am before a release. But notice that the verifier is only as useful as the property it’s checking. The property existed because someone asked, precisely, what must always hold for any balance reduction. The tooling then did the exhaustive part. That’s the division of labour: reasoning produces the property, verification proves it.</p><h3>How Formal Verification Works</h3><p>The two bugs above were caught by short, declarative properties: a postcondition on `emergencyBurn`, and a parametric rule over every function that can reduce a balance. But how does a verifier actually check those properties? What does it mean to prove something holds for every possible execution?</p><p>Formal verification reasons about all possible behaviours of a program, rather than what it does for specific inputs, and proves that none of them violate a set of desired properties. To do that, it relies on two things: a mathematical model of the program’s behaviour, called its semantics, and a formal specification of the properties that model must satisfy, such as the postconditions we will see shortly.</p><h4>Capturing the semantics of a smart contract</h4><p>A smart contract is, at its core, a state machine. It has storage variables that represent its current state, and functions that transition it from one state to another. A formal verifier captures this precisely by translating the contract into a set of logical formulas that describe, for every function, how it transforms storage, and what it returns.</p><p>Return to `emergencyBurn` from the Eleven Finance vault. Here is the actual function:</p><pre>function emergencyBurn() public {<br>  uint balan = balanceOf(msg.sender);<br>  uint avai = available();<br>  if(avai &lt; balan) IMasterMind(mastermind).withdraw(nrvPid, (balan.sub(avai)));<br>  token.safeTransfer(msg.sender, balan);<br>  emit Withdrawn(msg.sender, balan, block.number);<br>}</pre><p>The function reads the caller’s share balance into balan, uses it to determine how many LP tokens to return, and transfers them. But it never reduces balanceOf(msg.sender). The caller’s claim on the vault is never settled.</p><p>Before reading the constraints, it helps to be precise about what the two token types represent. <strong>Share tokens</strong> (tracked by balanceOf(msg.sender)) are the vault’s internal accounting mechanism. When a user deposits LP tokens into the vault, they receive share tokens in return. They represent the user’s claim on the vault’s assets. <strong>LP tokens</strong> (transferred via token.safeTransfer) are the actual assets being custodied by the vault. They are what users deposit, and what they expect to get back on exit. The two are distinct: returning LP tokens settles the assets, but only burning share tokens settles the claim.</p><p>A formal verifier derives that behaviour directly from the source, producing constraints that describe every possible execution. For this function, those constraints capture what balan is bound to, how many LP tokens are transferred to the caller’s address, and what happens to the share balance:</p><pre>balan = shareBalance_before(caller)<br>lpBalance_after(caller) = lpBalance_before(caller) + balan<br>shareBalance_after(caller) = shareBalance_before(caller)</pre><p>Here, X_before and X_after denote the value of semantic variable X immediately before and immediately after the function executes. For instance, shareBalance_before(caller) and shareBalance_after(caller) denote the caller’s share balance before and after the function executes, respectively.</p><p>The third constraint is the one that matters. It says the share balance of the caller is unchanged by the function, not reduced, not zeroed, just left exactly as it was. In CVL, this is what the verifier is reasoning about when it evaluates any rule that calls emergencyBurn. The before and after values correspond directly to the CVL pattern of capturing state with uint256 before = balanceOf(e.msg.sender)before the call and reading it again after; the verifier is checking whether the contract’s own logic, translated into these constraints, is consistent with the property you have written.</p><h4>Postconditions: what a function must guarantee</h4><p>Once you have a model of the contract, you need to say what it must guarantee. The most direct way to do this is a postcondition: a property that must hold after a function returns.</p><p>For emergencyBurn, the intended postcondition is straightforward: after the function returns, the caller’s share balance must be zero. Their claim on the vault is settled. This is exactly what the CVL rule from the first bug expresses:</p><pre>assert balanceOf(e.msg.sender) == 0,<br>  &quot;emergencyBurn must leave the caller with zero shares&quot;;</pre><p>Stripped to its logical core, that assert is the postcondition:</p><pre>shareBalance_after(caller) = 0</pre><p>The verifier now has two things: the semantic constraints derived from the contract, and the postcondition the function must satisfy. Its job is to determine whether one is consistent with the other, or find a case where they conflict.</p><p>Other kinds of properties exist: preconditions that constrain when a function may be called, invariants that must hold across every reachable state of the contract, and parametric rules that generalise over every function at once rather than targeting one specifically, as in the SafeMoon rule over method f. Each captures a different dimension of correctness. But postconditions are the most natural starting point: they translate intent directly into a checkable claim about what a function must deliver.</p><h4>How the solver works</h4><p>Given the semantic constraints and the postcondition, the solver frames the question as a search problem: is there any assignment of inputs and state variables that satisfies the contract’s logic but violates the property? Here we focus on <em>automated</em> program verifiers, such as the ones based on <a href="https://en.wikipedia.org/wiki/Satisfiability_modulo_theories">SMT solving</a> for instance. There are also program verifiers based on <em>theorem provers</em>, which normally require some level of interaction from the user to craft proofs.</p><p>For emergencyBurn, it searches for any execution where the function’s constraints are satisfied — LP tokens transferred, share balances updated according to the code — but the postcondition fails: balanceOf(e.msg.sender) after the call is not zero.</p><p>The contract’s constraints say:</p><pre>shareBalance_after(caller) = shareBalance_before(caller)</pre><p>The negation of the postcondition (the property violation the solver is trying to find) is:</p><pre>shareBalance_after(caller) ≠ 0</pre><p>Any caller who holds shares before calling emergencyBurn will still hold them after. The solver finds the existence of such a caller, and the CVL assert fails. Automated verifiers usually provide concrete values for storage variables and function inputs denoting a concrete instance, known as a <em>counterexample</em>, of how the function can violate the expected property. For example, it could find shareBalance_before(caller) = 1, shareBalance_after(caller) = 1 and caller = 0x1. So, the counterexample demonstrates concretely how the contract can break.</p><p>Formal verification is fundamentally different from testing. A test says: for these specific inputs, the output was correct. A verified function says: for all possible inputs and all reachable states, the property holds, or here is a concrete instance where it does not.</p><h4>Verifying the fix</h4><p>The fix is a single line. Adding _burn(msg.sender,balan) immediately after reading the caller’s balance settles their claim before any tokens are transferred:</p><pre>function emergencyBurn() public {<br>  uint balan = balanceOf(msg.sender);<br>  _burn(msg.sender, balan); // Fix line<br>  uint avai = available();<br>  if(avai &lt; balan) IMasterMind(mastermind).withdraw(nrvPid, (balan.sub(avai)));<br>  token.safeTransfer(msg.sender, balan);<br>  emit Withdrawn(msg.sender, balan, block.number);<br>}</pre><p>With that line in place, the semantic constraints change. The burn reduces the caller’s share balance to zero before the transfer happens:</p><pre>balan = shareBalance_before(caller)<br>shareBalance_after(caller) = shareBalance_before(caller) - balan<br>lpBalance_after(caller) = lpBalance_before(caller) + balan</pre><p>The first and second constraints can be combined to derive shareBalance_after(caller) = 0; using the first constraint, we can replace balan by shareBalance_before(caller) in the second so shareBalance_after(caller) = shareBalance_before(caller) — shareBalance_before(caller) = 0. The solver runs the same search as before: is there any assignment of inputs and state variables that satisfies the contract’s logic but violates the postcondition? The postcondition requires shareBalance_after(caller) = 0. The contract’s own constraints now guarantee exactly that, for every possible value of shareBalance_before(caller). No violating assignment exists. The property is proven to hold.</p><p>The spec didn’t change. The CVL rule is identical. The only thing that changed is the contract — and the verifier confirms that the fix is sufficient.</p><h4>Formal reasoning is hard</h4><p>Despite what the simple specifications in this article may suggest, writing specs that are both precise and complete is genuinely difficult: a postcondition that is too weak will be satisfied by a buggy implementation, and one that is too strong will flag correct behaviour as a violation. The difficulty also scales with protocol complexity. For instance, specifying invariants of a lending protocol — accounting for liquidation thresholds, interest accrual, rounding behaviour, and multi-asset interactions — requires deep understanding of both the protocol’s design (i.e. what it is supposed to do) and of the formalisms available to capture these properties.</p><p>Expertise in formal reasoning gives auditors the right tools and mindset to translate deep protocol understanding into precise specifications. That discipline — asking what must always hold, and writing it down exactly — improves code analysis, even if formal verifiers are not used.</p><h3>The Power of Formal Reasoning</h3><p>Each bug falls to the same kind of defense: a short, declarative property that says what the function must guarantee.</p><p>Formal reasoning doesn’t ask you to imagine the attack. It doesn’t need you to think of the right test inputs, or hope a fuzzer stumbles into the vulnerable state. You state what “correct” means: &quot;<strong>shares must decrease when tokens leave</strong>”, “<strong>rewards can’t appear from nothing</strong>”, “<strong>deposits must return something</strong>”, and the verifier exhausts every reachable path to confirm it or hands you the exact counterexample that breaks it.</p><p>The specs shown in this article are not complex. And they would have caught bugs that careful human review missed; not because the reviewers weren’t skilled, but because exhaustive search over every possible state is a job for a solver, not a person. The discipline is asking, precisely, what must always hold and writing it down. Formal verification is what turns that question into a proof.</p><p>A rigorous audit brings both: the judgment to understand what a protocol is supposed to do, and the tooling to prove it actually does that across every possible input and state.</p><p>Formal reasoning is cheap compared to the consequence of skipping it.</p><h3>About TBTL Security</h3><p>TBTL’s security division specialises in smart contract and zero-knowledge program audits, built on formal methods expertise. Our team combines decades of academic research in formal verification with deep practical experience in Web3 security — bringing the discipline of formal reasoning to every engagement. If you are building a DeFi protocol and want an audit that goes beyond pattern-matching, <a href="https://security.tbtl.com/">get in touch</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fa362fb42ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling committee-based consensus]]></title>
            <link>https://medium.com/@tbtl/scaling-committee-based-consensus-15610236b2f0?source=rss-fe5f088b5c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/15610236b2f0</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[consensus]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <dc:creator><![CDATA[The Blockhouse Technology Ltd]]></dc:creator>
            <pubDate>Tue, 14 Apr 2026 15:29:15 GMT</pubDate>
            <atom:updated>2026-04-14T15:29:15.263Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How to safely reach agreement with small committees</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zGDXNXFfjb4krzZur1yIiQ.png" /></figure><p><em>Original post: </em><a href="https://hackmd.io/@tbtl/rkvscqz2-g"><em>https://hackmd.io/@tbtl/rkvscqz2-g</em></a></p><p>Byzantine Fault-Tolerant (BFT) consensus is at the heart of blockchain systems, and scaling these protocols is at the forefront of distributed computing research. In this article, we explore a new technique proposed by our team at <a href="https://tbtl.com/">TBTL</a> to significantly scale consensus protocols based on randomly elected committees. Our technique can dramatically reduce the size of these committees: the fewer the participants in the protocol, the quicker they can interact to reach a consensus. For some network settings, our technique can employ a committee of <em>543</em> participants to safely reach a consensus, whereas traditional algorithms would require <em>94,366</em> participants. Our research has been published at <a href="https://drops.dagstuhl.de/storage/00lipics/lipics-vol356-disc2025/LIPIcs.DISC.2025.6/LIPIcs.DISC.2025.6.pdf">DISC 2025</a>.</p><h3>Why Committee Size Matters in Practice</h3><p>In a blockchain network, consensus is the process by which nodes agree on a single, canonical history of transactions. This agreement is what produces <em>finality</em>: the guarantee that a transaction, once confirmed, is immutable and cannot be reversed. Finality is not just a theoretical property — it is what makes a blockchain useful. Without it, you cannot be certain that a payment you received will not later disappear. The size of the committee participating in consensus directly influences how quickly the network can reach that agreement, and consequently how fast finality is achieved. The more participants must coordinate, the longer it takes. To understand why this matters in practice, Ethereum offers a concrete and instructive case study.</p><p>Ethereum currently has over one million active validators participating in its consensus protocol — a figure that reflects its commitment to decentralisation, but that comes at a real cost. It takes about 15 minutes for an Ethereum block to finalize, because the protocol requires votes from a supermajority of those validators before a block is considered irreversible. From the perspective of a user, this means that after sending a transaction, the true cryptographic guarantee of immutability does not arrive for roughly a quarter of an hour. To put that in everyday terms: imagine paying at a shop with a card and being asked to wait fifteen minutes before the merchant would accept that the payment had gone through. For many use cases — exchanges, real-time payments, interactive applications — this latency is simply impractical, and it stems in large part from the sheer number of participants the protocol must coordinate.</p><p>Ethereum’s answer to this has been to push activity onto Layer 2 networks, which can offer much faster confirmations. But this speed comes with an important caveat. The fast pre-confirmations that L2s offer are not backed by the same finality guarantee as Ethereum itself; they are essentially promises made by the sequencer, not cryptographic proofs of immutability. If you want the same guarantee that Ethereum’s finality provides, you still have to wait the same amount of time — or longer. On optimistic rollups, withdrawing funds back to Ethereum requires waiting out a fraud-proof challenge window that can stretch to seven days, a consequence of the security model rather than a bug. Crucially, the speed advantage that L2s do offer today is largely a product of their centralised architecture: most rely on a single sequencer or a very small committee of sequencers, trading the decentralisation and security guarantees of a large validator set for responsiveness.</p><p>These examples illustrate that committee size sits at the heart of a fundamental tension in consensus protocol design: larger committees offer stronger security guarantees but slower finality, while smaller ones can be faster but may sacrifice either security or decentralisation. Our technique offers a way to navigate this trade-off more carefully, achieving a better balance between the two than either of these approaches. The goal is a point on the design curve that neither Ethereum’s large validator set nor today’s centralised L2 sequencers currently occupy: small enough to be fast, yet backed by rigorous safety guarantees. It is worth noting that while we use Ethereum as a concrete illustration, our technique is not specific to Ethereum — it applies to any consensus protocol based on randomly elected committees, regardless of the underlying blockchain.</p><h3>The big picture: a two-committee architecture</h3><p>Before diving into the technical details, we give an overview of what our approach can deliver with a two-committee architecture example. It can combine two consensus committees — a <em>primary</em> and a <em>secondary</em> — where each has a different role and a different tolerance for faulty nodes.</p><p>The <strong>primary committee</strong> is small. It can tolerate more than <em>n/3</em> of its members being Byzantine. This higher fault tolerance is what lets it stay small when randomly sampled from the population. The trade-off is that it is not always guaranteed to reach a decision: if too many of its members happen to be faulty, it may be unable to agree on a value.</p><p>The <strong>secondary committee</strong> is larger. It follows the classical BFT requirement of tolerating fewer than one-third Byzantine members (<em>t &lt; n/3</em>), and is therefore always guaranteed to eventually reach a decision. Its larger size is the price of that stronger guarantee.</p><p>In broad terms, the protocol works as follows. The primary runs first and attempts to reach a decision. There are two cases:</p><ul><li><strong>Optimistic path</strong> — the primary succeeds. Its decision is passed directly to the secondary, which simply accepts and propagates it without running its own agreement protocol. This is the common case when the proportion of faulty nodes is low, and it is where the efficiency gain is realised: the expensive secondary protocol never has to run.</li><li><strong>Fallback path</strong> — the primary cannot decide. It does not simply crash or stay silent; instead, it hands over safely to the secondary, which then runs its own agreement protocol and produces a final decision.</li></ul><p>The key word above is <em>safely</em>. For the handover to work correctly, the secondary must be able to pick up from whatever partial progress the primary made — without risking two different values being decided. This is the subtle and non-trivial part of the design, and it is where the new concept of <em>Justifiability</em> enters the picture. We will build up to it step by step.</p><p>The practical payoff is significant. As a concrete example, for a population where 68% of nodes are honest and an error probability of <strong>ε </strong>= 1/10¹⁸, a primary (Justifiable) committee needs only <em>543 nodes</em>, whereas a standard secondary consensus committee requires <em>94,366 agents</em> — a reduction of more than 99%. Smaller committees means fewer messages, which may even indirectly reduce the latency thanks to the lighter network load.</p><h3>The quadratic barrier and random committees</h3><p>The goal of a consensus protocol is to have the participants agree to a common decision, <em>despite</em> unreliable communication and Byzantine (<em>i.e.</em> malicious) faulty behavior from some of the participants. Many Byzantine fault-tolerant protocols require all nodes to exchange messages with each other, leading to a communication cost that grows <em>quadratically</em> with the number of nodes. As explained above, this cost is a serious bottleneck in large-scale networks. Unfortunately, this quadratic cost is to some extent fundamental to consensus: <a href="https://dl.acm.org/doi/pdf/10.1145/2455.214112">Dolev and Reischuk</a> proved that it was required for deterministic protocols. Thus, randomisation is the privileged option for breaking the <em>O(n²)</em> barrier¹.</p><p>Scalable agreement protocols typically leverage randomness using committees: a small number of nodes (the committee members) are picked randomly and independently from the overall population, and only they run the expensive <em>O(n²)</em> protocol. The result is then propagated to the rest of the population.</p><p>The limit of this approach is due to the inherent bound on the number of Byzantine nodes tolerated by consensus algorithms. In our setting of interest where the network is partially synchronous, only up to <em>t &lt; n/3</em> nodes can be Byzantine, where <em>n</em> is the total number of nodes².</p><p>This constraint applies to the random committee as well. It will fail to be satisfied if too many Byzantine nodes are picked during the random selection; let’s call <strong><em>ε</em> </strong>the probability that this happens. To minimise <strong>ε</strong>, there are two options:</p><ul><li>accept to lower the number of tolerated Byzantine nodes for the whole population, and,</li><li>increase the committee size.</li></ul><p>Asymptotically, both options make <strong>ε</strong> decrease exponentially³. In practice however, the concrete value for <strong>ε</strong> needs to be extremely small: we must trust that no committee will be Byzantine in the entire lifetime of the system. As a result, the committee size is usually rather large, <em>e.g.</em>, in the thousands.</p><p>This is a somewhat frustrating state of affairs for random committees: it lets us discharge consensus to a <em>constant</em> number of nodes, but the gain in practice isn’t so great unless we compromise on either the number of Byzantine nodes tolerated or the probability of total failure.</p><h3>Smaller committees with the multi-threshold model</h3><p>The first ingredient that will help us is an observation from <a href="https://eprint.iacr.org/2021/671.pdf">Momose and Ren</a>, showing that instead of having a single fault threshold <em>t</em> that must always be satisfied, there can be multiple thresholds, and different properties will be guaranteed depending on which thresholds are satisfied. In our case, we have two:</p><ul><li>When there are up to <em>t_safe</em> Byzantine nodes, safety properties are satisfied,</li><li>When there are up to <em>t_live</em> Byzantine nodes, liveness properties are satisfied.</li></ul><p>In this new model, the <em>n &lt; 3t</em> constraint can be generalised to <em>n &lt; t_safe + 2t_live</em>. Now let’s assume that we only want to guarantee safety for the committee. Then we can freely choose a committee size, increase <em>t_safe</em> until the probability of error <strong>ε</strong> is as low as required, and then we will have liveness whenever there are less than (<em>n - t_safe)/2</em> Byzantine nodes, which happens with fixed (non-zero) probability.</p><p>The potential gains here may be up to several orders of magnitude, as can be seen in Figure 1 where we plotted the committee size as a function of the overall number of Byzantine nodes in the population.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*KfosOZquGDMz_NR87cc9Hg.png" /><figcaption><em>Figure 1: gain in committee size, logarithmic scale. (</em><strong>ε </strong><em>= 1/10¹⁸)</em></figcaption></figure><p>Of course, we must now deal with the case where Liveness does not hold in the committee. By design, the committee cannot deal with this situation by itself, so it is natural to try and remedy the situation with a backup consensus algorithm.</p><h3>A naive attempt</h3><p>Having our first ingredient, the solution seems simple: the small committee attempts to reach consensus, we will call it the primary <em>P</em>. If it does not succeed, it will send a signal to a backup <em>B</em>. As sketched in the big picture section, we are satisfied with the backup <em>B</em> being a regular (expensive but always safe and live) consensus protocol. Whenever <em>B</em> receives such signal, it will execute normally; if it receives a consensus decision from <em>P</em>, then it has nothing to do and we save on communication cost.</p><p>Trying to implement such a solution may seem simple at first glance. With a bit of experience in designing distributed protocols, one may try the following:</p><ul><li><em>P</em> sends to <em>B</em> either a proof of a decision or a proof of indecision (<em>i.e.</em>, a proof that it has aborted).</li><li>Such proofs can be constructed by letting nodes vote and using standard quorum-based constructions⁴.</li></ul><p>To start off, let us try to fix specific voting thresholds and see where the constraints lead. The voting threshold for a proof of decision can be set at <em>T_d = (t_live + n) / 2</em>, because it is what is required to guarantee quorum intersection when there are <em>t_live</em> faults, <em>i.e.</em>, when the protocol is live. Then, we could set the voting threshold for a proof of indecision to <em>T_a = n - t_safe</em>, because it will guarantee that honest nodes alone will always be able to output a proof of indecision. Because we want our algorithm to be <em>optimal</em>, we will also require <em>n = t_safe + 2t_live + 1</em>. We must also guarantee that there is never both a proof of decision and a proof of indecision! This adds the constraint <em>T_a + T_d - n &gt; t_safe</em>, which becomes <em>n &gt; 3t_safe</em> when applying the relations above. Except that we are now back to square one, because the entire premise of this algorithm was to set <em>t_safe</em> equal to or higher than <em>n/3.</em></p><p>After many attempts, each invariably leading to a contradiction, it becomes clear that something deeper is wrong with this approach.</p><h3>The solution: Justifiable protocols</h3><p>The key to solving this issue is to realise that <em>P</em> needs to transmit more information to <em>B</em>. The problem with the naive approach is that <em>P</em> can only signal success or failure, except that deciding that failure has occurred is as hard as successfully deciding on a value. The primary is essentially trying to solve consensus, something it can’t do by design. We solve this by giving <em>P</em> a third possible output: a <em>pre-decision</em>.</p><p>A <em>pre-decision</em> is like a weaker version of a decision: once a value has been pre-decided, only that value can be subsequently decided, <em>but</em> an indecision is also allowed to happen after a pre-decision, or even no output at all.</p><p>With this modification, a backup node <em>b</em> can simply wait to receive an output <em>o</em> from <em>P</em>. If <em>o</em> is a decision, then <em>b</em> has nothing to do except propagate the value. If <em>o</em> is a pre-decision then <em>b</em> will execute the backup protocol with <em>o</em> as input. Finally, if <em>o</em> is an indecision, then <em>b</em> will execute the backup protocol with a new block as input.</p><p>With that architecture, we only need one additional property from <em>P</em>: that it eventually sends <em>some</em> output to <em>B</em> — a decision, pre-decision, or indecision. Let’s call that property <em>weak liveness</em>.</p><p>This weak liveness property is at the heart of the trade-off being made here: while it is technically a liveness property, it must always hold, <em>i.e.</em>, when there are up to <em>t_safe</em> faults, not merely <em>t_live</em>.</p><p>We call protocols that can decide, pre-decide, or abort, <em>Justifiable⁵</em>.</p><h4>Looking back at the naive attempt</h4><p>One might ask whether Justifiability is really what was required for our Primary/Backup architecture. Perhaps something simpler and/or weaker could have worked? We can answer that question in the negative by showing that any protocol where a primary communicates one-way to a backup must incorporate some kind of pre-decision.</p><p>We must also revisit the optimality of our thresholds. It turns out that <em>n &gt; 2t_safe + t_live</em> must hold for Justifiable protocols. This inequality is stricter than the previous one, since <em>t_safe &gt; t_live</em>.</p><p>Taken together, these two results⁶ explain why the naive approach was doomed from the start: we attempted to build something that required Justifiability, but our “optimal” threshold values could not satisfy the stricter bound that Justifiability imposes.</p><h3>An example of a Justifiable protocol</h3><p>To finally fulfill our initial goal, we need a concrete instantiation of a Justifiable protocol for the primary. We focus on a simple variant of consensus called Reliable Broadcast, where a single leader node sends a value to all other nodes and all nodes are guaranteed to obtain the same value⁷.</p><p>The design follows a similar approach as the one above, except there are now three types of proofs that <em>P</em> may send to <em>B</em>: decision proof, pre-decision proof and indecision proof, with thresholds <em>T_d</em>, <em>T_p</em> and <em>T_i</em>, respectively.</p><p>The quorum intersection arguments give us the following constraints:</p><ul><li><em>2T_p - n &gt; t_safe</em> guarantees that a single value can be pre-decided.</li><li><em>T_d + T_i - n &gt; t_safe</em> prevents the output of both a decision and an indecision.</li><li><em>n - T_i &gt; t_safe</em> guarantees that an indecision can always be made by honest nodes.</li><li><em>n - T_d &gt; t_live</em> guarantees that a decision can be made when there are up to <em>t_live</em>.</li></ul><p>Adding the new optimality requirement <em>n = 2t_safe + t_live + 1</em>, it is possible to derive a single correct value for <em>T_d</em>, <em>T_p</em> and <em>T_i</em>.</p><p>However if you’ve been following closely, you may remember that for those quorum arguments to work, honest nodes must not be allowed to vote twice. This means in particular that nodes cannot vote both for a decision and an indecision, causing a potential issue where honest nodes start voting for a decision, and are later prevented from voting for an indecision, thus making no output at all and breaking the weak liveness property. This is solved by requiring decision votes to be cast only for values that already have a pre-decision proof. Thus, in situation above, there will be a pre-decision proof that can be output to satisfy weak liveness.</p><p>With weak liveness sorted out, filling the gaps of the algorithm is straightforward: The leader will propose a value, nodes send pre-decision votes for the first proposal they see. They send a decision vote for the first pre-decision proof they see, unless they have already sent a vote for an indecision. They also start a timer, and when that timer expires they vote for an indecision (unless they already voted for a decision). For the full correctness proof, you may be interested in reading the <a href="https://drops.dagstuhl.de/storage/00lipics/lipics-vol356-disc2025/LIPIcs.DISC.2025.6/LIPIcs.DISC.2025.6.pdf">full paper</a>.</p><h3>Conclusion</h3><p>Committee-based consensus is a foundational building block of modern blockchain infrastructure, and its efficiency directly determines how fast, cheap, and decentralised a network can be. Our work moves the needle meaningfully: by introducing Justifiability and the multi-threshold primary/backup architecture, we show that committees can be reduced by over 99% in realistic settings without compromising safety. This kind of improvement — it is the difference between a protocol that is theoretically sound but practically sluggish, and one that could underpin genuinely fast, decentralised finality. The applications are broad: from L2 sequencer decentralisation to any permissionless system where the cost of coordination is a bottleneck. Beyond the immediate result, Justifiability is a new theoretical concept with connections to the wider distributed systems literature — one we expect to find further applications for as the field continues to develop.<br> <br>At <a href="http://www.tbtl.com/">TBTL</a>, this kind of research is what we do. We are a deep tech company specialising in cryptography, distributed systems, and formal verification, with a particular focus on the Web3 space. Whether you are building a new blockchain protocol, designing a rollup, integrating ZK proofs into your stack, or simply trying to understand whether a system you depend on is as secure as it claims to be, we can help. If you are a company moving into Web3 or already operating in it and want rigorous, research-grade expertise applied to your hardest problems, <a href="/service/mailto:tech@tbtl.com">we would love to hear from you</a>.</p><p><strong>Footnotes</strong></p><p>¹ Other options may take the form of optimistic protocols that have low communication cost when the conditions are good, or through the use of more advanced cryptographic schemes.</p><p>² In synchronous networks, the bound becomes <em>t &lt; n/2</em>, or even <em>t &lt; n</em> for some variants of consensus.</p><p>³ This can be seen with a simple application of the <a href="https://wikipedia.org/wiki/Chernoff_bound">Chernoff Bound</a>.</p><p>⁴ The quorum intersection argument states that there is a number <em>Q_S</em> such that any two sets of nodes of size <em>Q_S</em> have at least one honest node in common. Thus, if nodes are instructed to vote only once, only a single value can ever receive <em>Q_S</em> votes.</p><p>⁵ Justifiability only makes sense if the protocol is multi-threshold and has the weak liveness property. Otherwise, it collapses to the well-known family of commit-abort protocols.</p><p>⁶ The proofs can be found in the <a href="https://drops.dagstuhl.de/storage/00lipics/lipics-vol356-disc2025/LIPIcs.DISC.2025.6/LIPIcs.DISC.2025.6.pdf">full paper</a>; Theorems 5 and 9.</p><p>⁷ Of course, liveness for Reliable Broadcast can only be guaranteed if the leader is honest, in which case the output is also required to equal the leader’s input value.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15610236b2f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Soundness Bug in cvc5’s Finite Field Split Solver]]></title>
            <link>https://medium.com/@tbtl/a-soundness-bug-in-cvc5s-finite-field-split-solver-ef05d3152af0?source=rss-fe5f088b5c5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef05d3152af0</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[formal-verification]]></category>
            <category><![CDATA[smart-contract-auditing]]></category>
            <category><![CDATA[zkp]]></category>
            <category><![CDATA[noir]]></category>
            <dc:creator><![CDATA[The Blockhouse Technology Ltd]]></dc:creator>
            <pubDate>Mon, 16 Mar 2026 14:18:38 GMT</pubDate>
            <atom:updated>2026-03-16T14:18:38.603Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How a misplaced overflow check could invalidate the formal verification of Zero-Knowledge programs</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dhL4vX1SfQQom2qM5kVkpA.png" /></figure><p><em>Original post: </em><a href="https://hackmd.io/@tbtl/BJ8ak2W9bl"><em>https://hackmd.io/@tbtl/BJ8ak2W9bl</em></a></p><p>Our team at <a href="https://tbtl.com/">TBTL</a> has discovered and fixed a bug in cvc5’s finite-field split solver while testing our formal verifier <a href="https://github.com/pedrotbtl/nave">NAVe</a>; see <a href="https://github.com/cvc5/cvc5/pull/12457">PR #12457</a>. SMT solvers are amazing tools at the core of many formal verification frameworks. They discharge proof obligations to prove that a program works as intended. cvc5 is, arguably, the most well-suited and popular SMT solver for the verification of practical Zero-Knowledge (ZK) programs (circuits, systems, etc), given its performant solvers targeting its theory of finite fields. So, a bug in one of these finite-field solvers can have far-reaching repercussions. A verification framework can erroneously report that a ZK program (circuit, system, etc) is safe when it is not. If a thought-to-be-correct-but-flawed ZK program (circuit, system, etc) is exploited, aside from possibly compromising digital assets or sensitive information that this program was meant to protect, it could significantly undermine the trust in ZK technology and formal verification.</p><h3>The Stakes: When Formal Verification Tools (for ZK Technology) Fail</h3><p>ZK proof systems are among the most security-critical components in modern cryptographic infrastructure. They underpin privacy-preserving blockchains, anonymous credentials, and verifiable computation protocols that collectively secure billions of dollars in value and protect sensitive data. Many applications of ZK technology have emerged in the Web3 space. Ethereum’s <a href="https://leanroadmap.org/">lean consensus roadmap</a> relies heavily on ZK technology for a number of improvements on this platform. Ethereum Layer 2 (L2) solutions — such as ZKSync, Aztec, Starknet, to name a few — and protocols like <a href="https://tornado.cash/">tornado cash</a> also use ZK technology to ensure privacy and/or scalability. Just to illustrate the risks involved, several of these L2 solutions have hundreds of millions of dollars in total value secured, a metric associated with the value of the tokens protected by them. Also, ZK proofs are being used in the privacy-preserving identity verification — see projects like <a href="https://zkpassport.id/">ZK passport</a>. So, personal information is at stake too.</p><p>To ensure that these vast sums of digital assets and sensitive information are well protected, formal verification techniques have been applied to guarantee that ZK technology (program, circuit, VM, protocols, etc) behaves correctly. These techniques use mathematical models to <em>prove</em> that ZK programs (circuits, systems, etc) correctly encode the intended computation. <a href="https://bugs.zksecurity.xyz/">Bugs found in the wild</a> demonstrate the necessity of audits and the use of formal verification to ensure their correctness. With the growth of the ZK ecosystem — driven, especially, by Web3 applications — tools to formally analyse ZK technology started emerging, and they will likely play a key role in protecting this ecosystem. To name a few examples: <a href="https://github.com/Veridise/Picus">Picus</a> is a formal verifier for ZK circuits, <a href="https://github.com/circify/circ">CirC</a> is a compiler infrastructure that can be used to reason about ZK circuits, <a href="https://github.com/pedrotbtl/nave">NAVe</a> — our tool — is a formal verifier ZK programs written in Noir, and <a href="https://github.com/NethermindEth/CertiPlonk">CertiPlonk</a> is a framework formally verifying constraint systems from the Plonky3 zkDSL. All of them rely on cvc5 to reason about ZK technology; Picus (at least the open-source version) and NAVe use the split solver — we discovered (and fixed) this bug while testing NAVe.</p><p>The promise of formal verification is that a passing verdict is trustworthy: if the tool says a program is correct, then it must be so. When the formal verification tool itself contains a soundness bug, however, that promise is broken in the most dangerous possible way. The tool may report that a flawed circuit is safe, without any indication that something has gone wrong, and the flaw may be exploited to compromise digital assets or personal data, undermining the trust in both the ZK ecosystem and formal verification. Using formal verification in this space is a must, and we must also work towards ensuring these tools (and their reasoning engines, i.e. SMT solvers) are sound.</p><h3>SMT Solvers: The Engines of Automated Formal Verification</h3><p>Satisfiability Modulo Theories (SMT) solvers are general-purpose automated reasoning engines that sit at the heart of a vast ecosystem of formal verification tools. They employ a number of decision procedures with performant heuristics to tackle challenging computational problems. Years of research and engineering achievements have culminated in these highly optimised solvers. Their importance for the area of automated formal verification cannot be overstated: they are absolutely indispensable.</p><p>Given a logical formula — say, representing a property of a program, a circuit, or a system — an SMT solver will either produce a model demonstrating that the formula can be satisfied, or a proof that it cannot. This makes them invaluable for checking safety properties: if you can express “there exists an input for which this program is wrong” as an SMT formula and the solver returns <em>unsatisfiable</em>, you have a machine-checked proof of correctness.</p><p><a href="https://cvc5.github.io/">cvc5</a> is one of the most capable and actively maintained SMT solvers. Developed by a collaboration of leading academic institutions and industrial research labs, it has consistently ranked among the top performers in international SMT competitions. Its open architecture, rich API, and breadth of supported theories make it a natural building block for verification tools targeting domains from software verification to cryptography.</p><h3>Finite Fields and ZK Program Verification</h3><p>The constraints that capture the behaviour of a ZK program are given by a system of polynomial equations over a finite field F. For instance, a very basic example is the definition of a Boolean variable in a ZK program: let b : bool, which can be captured by constraint (<em>B</em>) wb(wb - 1) = 0, where (<em>B</em>) is a short name for the constraint and <em>B</em> stands for <em>behaviour</em>. The <em>witness</em> wb (in F) captures the value of the program variable b; the values of the program variables at different program points are captured by these witness variables. This equation ensures that out of all the possible elements in the finite field, this witness can only be 0 or 1. Each statement in a ZK program leads to such a constraint (or a set of these), which combine to create a system of equations defining the program&#39;s behaviour.</p><p>A safety property of a ZK program can then be encoded as such a constraint too, using even propositional connectors and inequalities. For instance, the property that b must be either 0 or 1 could be checked by trying to find a counterexample for it: a value of b that is neither 0 nor 1. This could be encoded as the constraint (<em>P</em>) wb != 0 &amp;&amp; wb != 1 with respect to the witness wb; <em>P</em> stands for <em>property</em>. With constraints <em>B</em> and <em>P</em>, we can check the satisfiability of <em>B</em> &amp;&amp; <em>P</em>. If this SMT formula is satisfied, there exists a value of wb that violates our property. If this formula is unsatisfiable, as it is the case, we have proven that the only two possible values for wb are 0 and 1. This satisfiability checking can be carried out by an SMT solver like cvc5, with its theory of finite fields. ZK programming and property languages are quite expressive. Here, we present a very contrived example for the sake of simplifying our presentation.</p><h3>Finite Field Solvers in cvc5</h3><p>cvc5 is one of the first general-purpose SMT checkers capable of reasoning natively about finite field arithmetic. The <em>gb</em> solver described in <a href="https://eprint.iacr.org/2023/091.pdf">Ozdemir et al. (2023)</a> was cvc5’s first finite field solver; its name is derived from <a href="https://en.wikipedia.org/wiki/Gr%C3%B6bner_basis"><em>Gröbner basis</em></a>: a representation of a system of polynomials that allows for efficient computations. Simply put, this solver takes a set of polynomial equations over a finite field and establishes whether the set of solutions for this system is empty; a key procedure in reasoning about a finite-field-theory formula. If it is not, it provides a solution: a mapping of witnesses to values that satisfies the system. The key insight presented in the corresponding paper and implemented in this solver is that the very large order of prime fields used by practical systems (like the ones behind ZK proof systems) makes the typical way of checking for emptiness not very performant. It relies on the computation of the Gröbner basis for the system extended with field equations of the form wᵖ - w for each witness variable, where p is the prime order of the field. Instead, this solver uses a combination of the Gröbner basis calculation for the (unextended) system with a technique called <em>model construction</em>, where the space of potential solutions is explored with a carefully designed heuristic.</p><p>A follow-up work, <a href="https://eprint.iacr.org/2024/572.pdf">Ozdemir et al. (2024)</a>, has introduced the <em>split</em> solver variant: a solver that was designed to target bitsum-heavy programs. A <em>bitsum</em> expression bitsum(b₀,…,bₙ) denotes the sum b₀ * 2⁰ + … + bₙ * 2ⁿ. Each bᵢ is <em>intended</em> to represent a single bit but, despite what its name may suggest, this expression alone does not impose this restriction; separate bit constraints of the form bᵢ(bᵢ-1) = 0 are necessary to enforce that. These types of constraints can capture the bit-decomposition of a finite-field value, which can, in turn, encode bit-level operations, for instance. The Gröbner-basis computation for these constraints is very demanding: the time to compute them grows exponentially with the number of bits/elements in the bitsum. The key insight was to use a <em>split</em> Gröbner basis: a combination of easier-to-calculate Gröbner bases that approximate the basis for the full system. Computing a basis for a bitsum expression <em>combined with</em> its bit constraints is expensive, as we discussed. However, analysing the bitsum expression and the bit constraints separately can be much cheaper. The split solver maintains a split basis with two Gröbner bases, one linear and one sparse, propagating information between them to accelerate convergence. They are carefully designed so that a bitsum expression and the corresponding bit constraints are always in separate bases.</p><h3>Bug Discovery During NAVe Testing</h3><p>We encountered the bug described here in the course of testing <a href="https://arxiv.org/pdf/2601.09372">NAVe</a>, our formal verifier for programs written in <a href="https://noir-lang.org/">Noir</a> — the domain-specific language used to author ZK circuits for the Aztec protocol. NAVe uses the Noir language infrastructure (parser, compiler, etc) to translate Noir programs into ACIR (Abstract Circuit Intermediate Representation). It then encodes ACIR opcodes into SMT-LIB constraints that are analysed by cvc5 and its finite field solvers; in our paper, we describe the formal semantics we propose for ACIR. During the testing of NAVe against a suite of Noir programs, we observed that cvc5’s split solver was returning an <em>unsatisfiable</em> verdict for a satisfiable formula. This failure in the underlying solver means that NAVe, and any other tool relying on cvc5’s <em>split</em> finite field theory solver, could in principle report a circuit as verified when it is not.</p><h3>Minimising the Error to a Regression Test</h3><p>Isolating a solver bug requires reducing a potentially large, complex formula down to the smallest possible instance that still triggers the erroneous behaviour. This minimisation process is as much art as science: it involves an iterative cycle of pruning variables, simplifying constraints, and re-running the solver to check that the bug is still reproducible. After this process, we reduced the failing case to a five-line SMT-LIB 2 formula that became the regression test accompanying our fix:</p><pre>(set-logic QF_FF)<br>(define-sort FF () (_ FiniteField 21888242871839275222246405745257275088548364400416034343698204186575808495617))<br>(declare-const _0 FF)<br>(declare-const _1 FF)<br>(assert (= (ff.add (ff.mul (as ff-2 FF) _0) (ff.mul (as ff-1 FF) _1) (as ff4 FF)) (as ff0 FF)))<br>(check-sat)</pre><p>This asserts that -2w₀ − w₁ + 4 = 0 , i.e. that 2w₀ + w₁ = 4, over a prime finite field of large order. In the SMT-LIB constraint, the constant _i denotes the witness variable wᵢ and (as ffi FF) denotes the field element i. This linear equation has w₀ = 0 and w₁ = 4 as a solution or w₀ = 2 and w₁ = 0, among others. So, this formula is unequivocally satisfiable. The original split solver returned <em>unsat</em>; the unsatisfiable veredict.</p><h3>The Flaw: A Premature Overflow Check</h3><p>The bug lives in the BitProp::getBitEqualities method in src/theory/ff/split_gb.cpp, which we present below. The split solver tracks bitsum expressions. The solver checks whether any of the Gröbner bases in the split basis has reduced a bitsum to a constant, i.e. it derived a constraint of the form: bitsum(b₀,…,bₙ₋₁) = C. If this bitsum of n elements evaluates to a constant C such that C &gt;= 2ⁿ, then the bits cannot all be 0 or 1 while summing to C -- an impossibility that causes the solver to return <em>unsat</em>. This overflow check is carried out on line 412.</p><pre>Polys BitProp::getBitEqualities(const SplitGb&amp; splitBasis)<br>{<br>  Polys output{};<br><br>  std::vector&lt;Node&gt; bitConstrainedBitsums{};<br><br>  std::vector&lt;Node&gt; nonConstantBitsums{};<br>  for (const auto&amp; bitsum : d_bitsums)<br>  {<br>    // does any basis know `bitsum = k`?<br>    bool isConst = false;<br>    for (const auto&amp; b : splitBasis)<br>    {<br>      Poly normal = b.reduce(d_enc-&gt;getTermEncoding(bitsum));<br>      if (CoCoA::IsConstant(normal))<br>      {<br>        // this basis b knows that bitsum is a constant<br>        Integer val =<br>            d_enc-&gt;cocoaFfToFfVal(CoCoA::ConstantCoeff(normal)).getValue();<br>        if (val &gt;= Integer(2).pow(bitsum.getNumChildren())) // ** Line 412 **;<br>        {<br>          output.clear();<br>          output.push_back(CoCoA::one(d_enc-&gt;polyRing()));<br>          return output;<br>        }<br><br>        // check that all inputs are bit-constrained<br>        if (std::all_of(bitsum.begin(), bitsum.end(), [&amp;](const Node&amp; bit) {<br>              return isBit(bit, splitBasis);<br>            }))<br>        {<br>        ...</pre><p>The critical precondition for this reasoning is that the summands actually <em>are</em> bits. The overflow check is only meaningful if every element of the bitsum is known to be 0-or-1 constrained. In the original code, however, the overflow check was executed <em>without</em> verifying that the summand elements are bit-constrained. Coincidentally, a check of whether the elements of the bitsum are bit-constrained (using the method `isBit`) came right after in line 420, guarding a separate propagation step. So, although a constraint of the form bitsum(b₀,…,bₙ₋₁) = C can always be satisfied for any C -- a solution is found by setting b₀ = C and all other bᵢ to 0 -- this erroneous check would cause this constraint to be unsatisfiable for any C &gt;= 2ⁿ. Also, note that it would only take a single such constraint to possibly generate an unsat veridict for the entire input formula.</p><h4>How the Regression Triggers an Unsound Unsat Output</h4><p>The regression test is analysing the satisfiability of the constraint 2w₀ + w₁ = 4, which can be rewritten as (RW) bitsum(w₁,w₀) = 4; the solver does this rewriting to derive as much information as possible from bitsum constraints, even if they were not originally encoded explicitly as such. These witness variables are unconstrained finite field elements -- they carry no bit constraints whatsoever. The split solver, in the context of the bit propagation pass, identifies the rewritten bitsum constraint (RW) and proceeds to the flawed overflow check. Given that this bitsum has 2 elements, it proceeds to validate the overflow condition 4 &gt;= 2², and it propagates this information into an <em>unsound</em> unsat output.</p><h4>The Fix: Moving the Overflow Check Inside the Right Guard</h4><p>The repair is small: a careful rearrangement of the existing logic. In the fixed code, the overflow check is moved inside the branch that first confirms all bitsum elements are bit-constrained. Only after `isBit` has been verified for every summand does it make sense to assert that a constant value exceeding 2ⁿ represents a genuine contradiction. The fixed code is presented below.</p><pre>Polys BitProp::getBitEqualities(const SplitGb&amp; splitBasis)<br>{<br>  Polys output{};<br><br>  std::vector&lt;Node&gt; bitConstrainedBitsums{};<br><br>  std::vector&lt;Node&gt; nonConstantBitsums{};<br>  for (const auto&amp; bitsum : d_bitsums)<br>  {<br>    // does any basis know `bitsum = k`?<br>    bool isConst = false;<br>    for (const auto&amp; b : splitBasis)<br>    {<br>      Poly normal = b.reduce(d_enc-&gt;getTermEncoding(bitsum));<br>      if (CoCoA::IsConstant(normal))<br>      {<br>      <br>        // check that all inputs are bit-constrained<br>        if (std::all_of(bitsum.begin(), bitsum.end(), [&amp;](const Node&amp; bit) {<br>              return isBit(bit, splitBasis);<br>            }))<br>        {<br>          // this basis b knows that bitsum is a constant<br>          Integer val =<br>              d_enc-&gt;cocoaFfToFfVal(CoCoA::ConstantCoeff(normal)).getValue();<br><br>          if (val &gt;= Integer(2).pow(bitsum.getNumChildren()))<br>          {<br>            output.clear();<br>            output.push_back(CoCoA::one(d_enc-&gt;polyRing()));<br>            return output;<br>          }<br>          ...</pre><p>This restores the correct precondition: the overflow check is only invoked when the solver has established that it is working with genuine boolean summands. The fix was small, consisting of moving six lines of code, but it is the difference between a sound and an unsound verdict. Also, the quality of the code simplified the task of identifying the bug and implementing the fix. The fix was reviewed and approved by Alex Ozdemir, one of the original authors of the split solver, who confirmed the bug and fix before the PR was merged into cvc5 main on February 27, 2026.</p><h3>The Expertise Required</h3><p>Understanding and fixing this bug demanded expertise across several technical domains. At the mathematical level, one needs a solid grasp of algebra in what concerns the analysis of a system of polynomial equations over a finite field of prime order and its set of solutions — for instance, how Gröbner bases can be used to determine the existence of a solution in this specific context. These are the mathematics required to understand both the <em>gb</em> and <em>split</em> solver papers. At the systems level, one needs to understand the architecture of a production SMT solver — how theories are modularised, how the DPLL(T) loop interacts with theory solvers, and how propagation and conflict detection work in the finite field backend specifically. Finally, one needs the analytical skills to work backwards from an incorrect verdict through a chain of solver decisions to identify a misplaced condition — without which the fix would be inaccessible even to an expert who understood each component in isolation. The difficult task of identifying and correcting the bug was considerably simplified by the documentation available and the code quality of the finite field solvers. We are grateful to the cvc5 team for their receptiveness, rapid review, and the impressive work that supports this entire ecosystem of high-assurance verification.</p><p>Follow us on <a href="https://www.linkedin.com/company/blockhouse-technology-ltd">LinkedIn</a>, too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef05d3152af0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>