Base- digit expansions and adaptive correctness for the KFLT Groth16 garbling scheme
2026-09-26
Trust-minimised Bitcoin bridges in the BitVM lineage garble a Groth16 verifier and disclose a secret exactly when a published proof is invalid. Khambhati, Feickert, Lewe and Tiwari (KFLT) garble the pairing over the source and target groups directly, obtaining a MiB scheme for BN254, much of it variable cost from rekeying and from the group encodings. We replace the binary decomposition of the rekeying scalar by a base- expansion with digits in , the free endomorphisms of the curve, cutting the A-encoding dimension from to ( versus ). We prove the greedy expansion correct with length at most and machine-check the BN254 bound in Lean 4 via a square-root-free threshold chain. We then identify an adaptive-correctness gap: the incomplete Jacobian formulas used to realise the encodings can be steered to return by a garbler who chooses the proof after garbling. We characterise the exceptional outputs and give a repair at no increase in garbled program size. Costing the stacked changes brings the scheme from MiB to roughly MiB, at which point the untouched fixed cost is of the program.
Introduction
Trust-minimised Bitcoin bridges in the BitVM lineage move SNARK verification off chain: an operator garbles a verifier before the proof exists, later publishes a proof together with one-time signatures on its bits, and a challenger evaluates the garbled verifier locally. If the proof is invalid the evaluation reveals a secret with which the challenger contests the claim; if it is valid the secret stays hidden. The size of the garbled program is the setup cost of the bridge, and for Groth16 the Boolean route costs tens of gigabytes.
Khambhati, Feickert, Lewe and Tiwari[1] (henceforth KFLT) instead garble the verification equation over the source and target groups directly. Building on Argo MAC[2], BABE[3] and Duty-Free Bits[4], they obtain a projective partial garbling scheme for the disclosure function “reveal iff the proof is invalid” whose BN254 instantiation is MiB. The central difficulty is the pairing , whose two arguments are both supplied by the evaluator; it is handled by a rekeying gadget that gives the evaluator for a private scalar , obtained as a public linear combination of Argo encodings indexed by the binary digits of .
Where the bytes go. The MiB decomposes as KiB of group program, KiB of fixed projectivization cost (eight bit-to-CRT conversions, one per -bit coordinate block) and KiB of variable cost proportional to the aggregate affine dimension
where , , and the factor on comes from projectivizing -affine encodings through two instances of doubled width. KFLT’s Appendix A reduces by sampling the encoding coefficients from rather than (), and remarks that the binary decomposition of in the rekeying gadget could likewise be replaced by a decomposition against , “always possible” and “more compact”, but that “the analysis involved in showing the bound is nontrivial” and the gain “marginal”. We disagree on the second point and supply the first.
Contributions.
- Eisenstein digit expansions (Section 3). The set is a complete residue system in modulo , which has norm . The greedy expansion terminates, is correct, and has length at most . Every lifts to with by coordinatewise rounding. For BN254 this gives at most digits, versus binary digits.
- Machine-checked bound (Section 7). The BN254 statement is proved in Lean 4 (v4.34.1) with no external library. The integer square roots that appear in the step bound are avoided in the kernel by a checkable threshold chain: a list of pairs certifying and , verified by
decide. The main theorem depends only onpropext,Classical.choiceandQuot.sound. - The rekeying gadget with Eisenstein digits (Section 4). Replacing by , where is one doubling and one free endomorphism, leaves correctness and the DDH-based privacy proof of KFLT unchanged and cuts from to .
- Adaptive correctness (Section 5). KFLT’s correctness (their Definition 1) fixes the evaluator’s input before the garbling randomness is drawn. In the bridge the garbler is the prover and chooses the proof afterwards, knowing every mask. We show that with the incomplete Jacobian formulas used to realise Argo encodings this is exploitable: an invalid proof with evaluates to . We characterise the exceptional outputs algebraically and give a repair that costs no garbled material for binary digits and a bounded candidate enumeration for .
- Cost accounting (Section 6). A stacked estimate, labelled by evidential status, from MiB to roughly MiB, after which the untouched KiB fixed cost is of the program.
Relation to KFLT. Nothing here changes the shape of KFLT’s construction; we replace a number system inside one gadget, tighten one definition to match one application, and account. All cost figures for the unmodified scheme are theirs. We have not implemented the modified scheme; Section 6 labels each row of the cost table as proven, the authors’ own estimate, or ours.
Background
Groth16 verification and KFLT’s group encodings
We follow KFLT’s notation. All groups are written additively, including the target group. A Groth16 proof is with , , all of prime order ; with the verification key and statement fixed at garbling time, the check is for public , . The disclosure function returns the garbler’s if and otherwise.
A point is encoded as for a private coefficient and a uniform private mask . KFLT’s scheme samples , encodes and at each under , and handles by the rekeying gadget: the masks on are for public and a single private , and the evaluator is given , from which cancels the input-dependent mask . The point is obtained from encodings , where , as and .
To projectivize, each encoding is itself garbled from the affine coordinates of by an information-theoretic partial garbling (Ishai–Wee[5]) of the Jacobian addition formulas, then from the bits of those coordinates by Duty-Free Bits[4:1]. With the incomplete formulas of KFLT Theorem 3, each encoding contributes affine dimensions ( for , for ); with the complete formulas of Renes–Costello–Batina[6] used in KFLT Appendix A, .
Endomorphisms of BN254 and the digit set
BN254 has -invariant : over and its sextic twist over . For a primitive cube root of unity the map is an endomorphism of acting on as multiplication by a primitive cube root of unity ; plays the same role on (KFLT Appendix A.1). Negation is . Hence every element of
acts on and by a map that is a coordinatewise scaling of by constants. This is what makes “free”: the polynomials computing have the same monomial support in as those computing , so the affine dimension of the encoding is unchanged.
Eisenstein integers
with is the ring of integers of , with norm , multiplicative, and conjugate . Since , splits as with , and via , where is the root of in for which . The other root corresponds to ; we fix so that acts as , and then the ring homomorphism , , factors through . Concretely, for and any ,
Base- expansions with digits in
Let . Then , and , so
Lemma 1 (Residue system). , the residue of modulo is determined by , and is a complete system of residues modulo :
| 0 | 1 | 2 | 3 | 4 | 5 | 6 |
Proof. . By (2), iff , since . The table is direct: has and has .
Definition (Greedy expansion). For let be the digit with the residue of (Lemma 1) and , computed by (2). Define and for , and .
The definition is well founded because the norm strictly decreases, which is the content of the next lemma. Write for the symmetric bilinear form with , i.e. .
Lemma 2 (One step). Let and with . Then . In particular , and over the reals .
Proof. with , so . If this is . Otherwise is a unit, , and by Cauchy–Schwarz; for the six units this is the integer inequality , each case being , or after expansion. Then forces , so . The real form is .
Theorem 3 (Expansion). For every , and every digit lies in . If the expansion has at most digits.
Proof. Correctness is the identity unrolled along the (finite, by Lemma 2) recursion. For the length, put where and , and , the fixed point of . Lemma 2 gives while , hence . A nonzero Eisenstein integer has , so as soon as , i.e. as soon as . Since , the first such is at most , and the number of digits is that .
Exhaustive computation over the box finds the bound attained in every range , .
Lemma 4 (Lifting to ). Fix with . For let with and (coordinatewise nearest integer to ), and . Then and .
Proof. , whose coordinates , satisfy and by the choice of . Multiplicativity gives , and follows from , and (sum of and ).
Theorem 5 (BN254). Let be the BN254 scalar field order and
so that . For every there is with whose greedy base- expansion has digits in , evaluates to , and has length at most .
Proof. Lemma 4 and Theorem 3: , so at most digits. The machine-checked proof (Section 7) uses the integer form of Lemma 2 instead of the real recurrence and reaches the same .
Remark (Ninety-one). The coordinatewise rounding of Lemma 4 is not the nearest lattice point. The hexagonal lattice has covering radius , so a true nearest-point lift gives , and yields . Sampling random scalars, the greedy expansion of the rounded lift never exceeded digits, so is likely loose by exactly one. We did not formalise the nearest-point lift.
Remark (Digit sets are bounded by the endomorphism ring). The only cheap coefficients on a curve are the units of : any other Eisenstein integer, e.g. of norm , costs a point addition and raises the degree of the encoding polynomials. So , with bits per encoding, is the natural ceiling for . On the untwisted Frobenius gives a cheap action of , but KFLT’s scheme needs the same coefficient vector on and , and , so this cannot be used without restructuring the disclosure; we leave it open.
The rekeying gadget with Eisenstein digits
Construction 6. is modified as follows; everything not mentioned is unchanged.
- Garb. Sample as before. Lift to by Lemma 4 and compute , , padding with zero digits to a fixed length. Sample for and set , where acts on through .
- Enc. for .
- Eval. , computed by Horner’s rule with , one doubling and one free endomorphism per digit.
Proposition 7. Construction 6 is correct: . Its privacy is exactly that of KFLT Theorem 8, under DDH in in the random-oracle model. The affine dimension of the -encoding is with the incomplete formulas of KFLT Theorem 3, or with the complete formulas of KFLT Appendix A.2.
Proof. Correctness is (1): because . For privacy, the only property of the -encodings used in the proof of KFLT Theorem 8 is that the are independent uniform points (so they can be sampled first and defined as ); this holds for any coefficients since the are uniform, and the public combination is as good as there. The DDH hybrid and the relabelling of do not involve the -encodings. For the dimension, is a coordinatewise scaling of , so the polynomials of KFLT eq. (1) evaluated at have the same monomials ; ; , with the garbler’s private constants absorbed into the coefficients, and the Ishai–Wee dimension count is unchanged.
Remark (Digit privacy). The digits are part of the private encoding key, exactly as the bits were; the evaluator sees only , which is uniform. The expansion is computed once by the garbler, and runs in integer operations.
Adaptive correctness
The gap
KFLT Definition 1 asks that for every fixed , evaluation returns except with probability over the randomness of . This is the standard, non-adaptive notion. In the bridge application described in KFLT Section 1, the operator prepares the garbled verifier, holds , and later publishes the proof; that is, the party who chooses knows every mask in before choosing.
KFLT realise the group encoding from the coordinates of with the incomplete Jacobian formulas (their eq. (1)),
for , , curve , and note that they are incomplete when , returning , “which occurs with probability for a uniformly sampled mask”. That is true for an input fixed in advance. An operator who has drawn and can choose .
Proposition 8 (Steering). In KFLT’s as written, a garbler who chooses the evaluator’s input after garbling can produce an invalid proof on which honest evaluation returns . The same holds for the entries of and : with , the input or makes the -th encoding evaluate to , and returns whenever any single index has no unique candidate.
Proof. Take for some with and any making the proof invalid. The inner evaluation of returns by (3), which is not a Jacobian representative of any point, and returns at its step 2. (Were the evaluator to substitute an arbitrary point instead, would be off by some , every by , and no candidate would hash to except with probability .) The proof itself is a legitimate triple of group elements, so the Lamport signatures on its bits are valid, and the garbling is honest, so cut-and-choose does not reject it.
Whether the surrounding bridge protocol has an independent defence, such as a challenge path that forces the operator to open masks, is outside KFLT and outside this note; at the level of the garbling scheme and the definition it is proved against, the gap is real. KFLT’s Appendix A moves to complete formulas “to account for all input cases comprehensively”; we read this as the same concern, and note that if complete formulas are required then they are required in the main construction too, at rather than dimensions per encoding, i.e. and roughly MiB rather than . The repair below avoids that.
Characterising the exceptional outputs
Lemma 9 (Exceptional outputs of (3)). Let and both satisfy , and let . Then (3) returns if and only if ; and it returns with if and only if , in which case is a valid Jacobian representative of the identity.
Proof. iff , and then from the curve equations. With , , which is iff ; if a direct substitution using gives . If then and , and places on the projective closure, where is the identity.
In and every point has , since the group orders and are odd and would give -torsion. The randomised representative has the same zero pattern, and the constant representatives used for and for have . Hence, applied to , the lemma says: the evaluator sees at an encoding exactly when and , and then the encoded point is .
Repair
Construction 10 (Repaired evaluation). Let the inner evaluator, on obtaining for an encoding of , return the candidate set instead of failing; for binary coefficients this is the single point .
- Entries of and . Index enters only through and the subgroup test. Extend the candidate test at to range over the candidate set(s) for , and : at most hash evaluations at that index. A wrong candidate passes only by a hash collision, so the correctness error grows by at most .
- Entries of . If indices return the evaluator has candidates for (one, if uses binary digits), each testable against all at once. Since the are the garbler’s own choice, is not bounded by chance. Derive them instead as from a seed that is opened in the cut-and-choose check of the malicious-security compiler. Then a second collision for the same requires two of pseudorandom points in one orbit of size , probability about per seed, negligible even against a grinding operator, so and the enumeration has at most elements.
Proposition 11. With Construction 10, KFLT’s scheme, with binary or Eisenstein digits on and binary or coefficients on , is correct against an adversary that chooses the evaluator’s input after seeing , except with probability , at no increase in garbled program size.
Proof. By Lemma 9 every output of the inner evaluation is either a correct representative or , and in the latter case the true encoded point is in the candidate set. The outer candidate test is complete because the correct candidate always passes, and sound up to hash collisions; the -side enumeration is bounded as computed. No garbled material changes; only evaluator work, by a constant factor.
Remark (Privacy is unaffected). In the exceptional case the evaluator learns that the coefficient at that index is nonzero (and, for , which digit). This is reachable only by the garbler’s own steering, and the privacy game has an honest garbler, so the simulator of KFLT Theorem 8 is unchanged. In the bridge, an operator who steers a valid proof into the exceptional case leaks bits of its own secret; it has no incentive to.
Remark (Alternatives). Complete formulas on only cost dimensions; binary digits on with the deterministic repair cost nothing beyond KFLT’s . The seed-derived masks are the cheapest option and need only that the malicious-security compiler already opens garbling randomness, which cut-and-choose does.
Cost accounting
The table stacks the changes. Variable cost is scaled linearly in from KFLT’s measured KiB at ; the fixed KiB is untouched throughout. All rows assume dimensions per encoding with the repair of Section 5; with complete formulas the variable cost of every row, including KFLT’s, is larger and the ratios are essentially unchanged.
| Step | Status | Total | vs. KFLT | |
|---|---|---|---|---|
| KFLT, binary digits | measured[1:1] | 10,758 | 2.44 MiB | — |
| Eisenstein digits on (Section 4) | proven, Section 7 | 8,814 | 2.16 MiB | −12% |
| + on , | KFLT App. A | 3,894 | 1.44 MiB | −41% |
| + two-input gadget (Conjecture 12) | conjectured | 2,780 | 1.27 MiB | −48% |
| + output-mask elimination | suggested in Duty-Free Bits[4:2] | 2,780 | 1.07 MiB | −56% |
(or under Conjecture 12); , from the second row on.
Conjecture 12 (Two-input affine maps in Duty-Free Bits). KFLT Lemma 12 projectivizes an -dimensional -affine encoding as two instances of dimension , an additive sharing that costs base-field output dimensions. In Duty-Free Bits (Section 4.3 of that paper[4:3]), stage 1 converts each input to CRT residues at a cost independent of , while stage 2 pays one terminal output label per (CRT prime, output dimension), with multiplication by the garbler’s private coefficient being linear. If that reading is right, a native gadget for over with two encoded inputs needs output wires, not , and the factor on drops from to . We have not verified this against the switch-system formalism of Duty-Free Bits Section 6.
Remark (What does not work: -only encodings). The fixed cost is eight bit-to-CRT conversions, one per coordinate block. Sending only and recovering up to sign would remove three blocks, and the symmetric functions of and are polynomial in with private coefficients, of Ishai–Wee dimension . But the evaluator then learns the unordered pair , and with public the second root identifies : for the two roots coincide iff . So -only encodings leak the coefficient and cannot be used.
After the table the fixed cost is of the program. Its floor is bits per block, about KiB, against the KiB per block measured; closing that is engineering inside Duty-Free Bits rather than protocol design.
Formalisation
The BN254 statement (Theorem 5) is proved in Lean 4[7], version 4.34.1, in about lines with no dependency on Mathlib or any other library. The development defines as pairs of integers with the multiplication , the norm, conjugate, base , the digit and quotient maps of Section 3, the greedy expansion by well-founded recursion on the norm, and the Horner evaluation. The main theorem is stated as
theorem bn254 (k : Int) :
∃ z : Eis, (∃ q : Eis, z = ofInt k - q * π) ∧
(∀ d ∈ expand z, d ∈ digitSet) ∧ eval (expand z) = z ∧ (expand z).length ≤ 92
and #print axioms Eis.bn254 reports propext, Classical.choice, Quot.sound; there is no sorry and no native_decide.
Avoiding square roots in the kernel. Lemma 2 is formalised in the form for any with , which needs no square-root function at all. The length argument is a general lemma: a list is a valid threshold chain if and for each , and ; then every with has an expansion of length at most . Validity of a concrete chain involves only natural-number multiplication, division and comparison, which the kernel evaluates directly, so the -entry chain for BN254, with and found offline, is checked by decide and depends on no axioms. Lean’s Nat.sqrt is defined by well-founded recursion and does not reduce under decide; the certificate sidesteps it.
Arithmetic. Cauchy–Schwarz for the six units, the norm identities and the expansions of products in Lemma 4 are polynomial identities discharged by grind; the remaining inequalities are linear in the monomials and discharged by omega after supplying square-nonnegativity facts. The rounding bounds in Lemma 4 are linear in and once is unfolded to a literal, and omega handles them directly.
What is not formalised. The identification and the action (1), which are standard and not specific to this work; the closed form of Theorem 3, which uses real arithmetic; Lemma 9, which needs field arithmetic over and is the natural next target for a Mathlib development; and the nearest-point lift of the Ninety-one remark.
Conclusion
The rekeying gadget of KFLT was paying for a binary number system where the curve offers a base- one. Replacing it is a change of one line in the evaluator and of the garbler’s offline arithmetic; the accompanying bound is now a theorem checked by a kernel rather than an estimate, and the same technique of shipping a threshold certificate should transfer to any bound of the form “the norm shrinks by a factor at each step” that one wants to certify without real analysis. The adaptive-correctness gap is, we think, the more important of the two observations, since it separates the scheme’s definition from its application; the repair is cheap and we would expect it, or complete formulas, to be adopted before deployment.
Open: the nearest-point lift and the -digit bound; a Mathlib formalisation of Lemma 9 and of adaptive correctness itself; Conjecture 12; using on ; and, dominating everything after these, the fixed cost of bit-to-CRT conversion.
Provenance
This note was produced by the model named in the submission’s provenance record, in an interactive session with a human collaborator who posed the problem, chose the direction at each stage (improving the native-group design, machine-checking the bound, and this write-up), reviewed the results and chose not to be credited. The Lean artifact is the only part of the argument that has been checked by something other than the model; everything else should be read with that in mind.
References
N. Khambhati, A. Feickert, C. Lewe, M. Tiwari. Garbling Groth16 with native group operations. Cryptology ePrint Archive, Paper 2026/2100. ↩︎ ↩︎
L. Eagen, Y. T. Lai. Argo MAC: Garbling with elliptic curve MACs. Cryptology ePrint Archive, Paper 2026/049. ↩︎
S. Garg, D. Kolonelos, M. Sergeevitch, S. Sridhar, D. Tse. BABE: Verifying proofs on Bitcoin made 1000x cheaper. Cryptology ePrint Archive, Paper 2026/065. ↩︎
N. Khambhati, A. Bhattacharya, D. Heath. Duty-free bits: Projectivizing garbling schemes. Cryptology ePrint Archive, Paper 2026/476. ↩︎ ↩︎ ↩︎ ↩︎
Y. Ishai, H. Wee. Partial garbling schemes and their applications. ICALP 2014. ↩︎
J. Renes, C. Costello, L. Batina. Complete addition formulas for prime order elliptic curves. EUROCRYPT 2016. ↩︎
L. de Moura, S. Ullrich. The Lean 4 theorem prover and programming language. CADE 2021. ↩︎