Repository navigation
Bulletproofs: range-check commit_value, make the key opaque, hide the seeded prover - #25
Merged
Merged
Conversation
commit_value took the value as an Int and reduced it mod r, so a commitment to value + k * r, a negative amount included, was the same point as one to value, and value's range proof verified against it. A validator that builds V from an Int amount could be given 200 - r and accept it as 200. commit_value now fails unless 0 <= value < r. The bound is r rather than 2^n: each accepted Int then gives its own point, and the range proof still decides whether the value is below 2^n. A commitment to a value between 2^n and r, for homomorphic arithmetic, keeps working. known_issue_16 becomes prop_bullet_commit_value_rejects_out_of_field (the same call must now fail for every k). New unit tests: commit_value fails for r and for -1, and accepts 0 and r - 1. Mutation-checked: dropping the check, or moving either bound by one, fails a test. Cost: two integer comparisons. verify doesn't call commit_value, so its cost is unchanged. Fixes #16 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
verify trusts every generator in the key it is given. A validator that took the key from a redeemer or datum let the prover choose them, and a prover who picks h = k * g can open a commitment to any value. The issue's first suggestion, hashing the key into the transcript, wouldn't stop that: such a prover knows the relations before any challenge is drawn. So BulletproofVerificationKey is now opaque, and setup is the only way to make one. Checked with Aiken v1.1.21: outside bullet.ak, expect from Data into the key, a record update of it, and reading its fields are compile errors, and aiken build refuses it in a validator's redeemer, datum or parameter. Before this, expect from Data into the key compiled and accepted a key with h = g. Nothing outside bullet.ak built a key or read its fields, so no caller changes. The setup comment said to embed the key as a constant. A spend validator that does so is 22,714 bytes at n = 8, over the 16,384-byte transaction limit, against 2,955 bytes when it calls setup(8) itself, which costs about 2B CPU more (7.81B against 5.83B for the check). The comments and docs now say to fix n and call setup in the validator, and the report has both sets of figures. The property tests hold the key as a constant, so setup runs once instead of in every case. Fixes #17 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
generate_proof_deterministic was public although its comment called it test-only. It derives every blinding factor from a seed, so anyone with the seed can read the committed value back from l_vec, and a proof made with it hides nothing. Someone integrating the library could easily take it for the prover. It is removed. bullet.ak's own tests call generate_proof with the private derive_blinding, whose comment now says why it mustn't be used for real proofs, and tests/bullet_props has its own seeded_blinding built on scalar.from_bytes. The only public prover is generate_proof, which takes the blinding from the caller. This is a breaking change for anyone who called generate_proof_deterministic; they need to supply their own blinding. Fixes #18 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The report said a full verify call at n = 8 costs about 5.2M memory and 14.2B CPU, "comfortably within" the per-transaction budget. 14.2B is over the 10B CPU limit, and it isn't verify's cost: it matches range_proof_valid, which also runs setup and builds the proof. Measured on its own with Aiken v1.1.21, verify costs 3.00M memory and 5.83B CPU with a constant key, proof and commitment, or 3.16M and 7.81B when setup(8) is called alongside it, as a validator has to (see the previous commit). The report now gives those, the limits, and the unit test's figure for comparison. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the Bulletproofs API hardening and documentation updates.
No open issues 🎉
What changed in this PR
This PR hardens the Bulletproofs API to address #16–#18 and corrects the documentation’s verification-cost estimates.
Changes:
- Rejects commitment values outside
[0, r)and adds boundary and property regression tests. - Makes verification keys opaque and removes the public deterministic prover, keeping seeded blinding in test helpers.
- Updates validator setup guidance, execution-cost figures, and documented test totals.
| File | Description |
|---|---|
zkp/lib/tests/bullet_props.ak |
Adds local seeded blinding, a constant key, and an out-of-field rejection property. |
zkp/lib/bullet/bullet.ak |
Enforces commitment bounds, makes keys opaque, removes the seeded prover API, and adds boundary tests. |
zkp/docs/step-by-step.md |
Documents commitment bounds and validator-controlled key setup. |
zkp/docs/plonk-implementation-report.md |
Updates package-wide test totals to 82. |
zkp/docs/groth16-implementation-report.md |
Updates the package-wide test total to 82. |
zkp/docs/bulletproofs-implementation-report.md |
Documents API hardening, regression tests, and corrected verification costs and setup tradeoffs. |
Review effort: Balanced
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the three Bulletproofs issues, one commit each, plus a correction to the report's
verifycost found while measuring for #17.Fixes #16. Fixes #17. Fixes #18.
Changes
cd12d66commit_valuefails unless0 <= value < r. It used to reduce the value modr, so a commitment to200 + ror200 - rwas the same point as one to200, and200's range proof verified against it.41939a3BulletproofVerificationKeyis opaque, sosetupis the only way to make one. A key can no longer be decoded from a redeemer, datum or otherData, or built from chosen points.f2b2c1fgenerate_proof_deterministicis removed. The tests derive their own seeded blinding; the only public prover isgenerate_proof, which takes the blinding from the caller.1aab9e6verifycall" cost of 5.2M memory and 14.2B CPU was the wholerange_proof_validtest (setup, proving and verifying), and 14.2B is over the 10B per-transaction limit.verifyon its own is given instead.Design notes
#16, why
rand not2^n. With the bound atr, each acceptedIntgives its own point, and the range proof still decides whether the value is below2^n. A commitment to a value between2^nandr, for homomorphic arithmetic, keeps working.#17, why not bind the key into the transcript. The issue's first suggestion wouldn't stop the attack: a prover who chooses the generators (
h = k * g, say) knows their relations before any challenge is drawn, so hashing them into the transcript changes nothing. The whole key has to come fromsetup. An opaque type enforces that at compile time. Checked with Aiken v1.1.21:bullet.ak,expectfromDatainto the key (aiken::check::illegal::expect_on_opaque), a record update of it, and reading its fields are compile errors;aiken buildrefuses the key in a validator's redeemer, datum or parameter, nested or not;expectfromDatainto the key compiled and accepted a key withh = g.Nothing outside
bullet.akbuilt a key or read its fields, so no caller in the package changes.#17, how a validator should hold the key. The old
setupcomment said to embed the key as a constant. Measured atn = 8with a spend validator that builds the proof from plain integers and compressed points:verify, plussetupwhere called)bullet.setup(8)called in the validatorconst vk = bullet.setup(8)The constant is evaluated at compile time, which saves about 2B CPU, but at
n = 8the script is over the 16,384-byte transaction limit (11,257 bytes atn = 2). The comments and docs now say to fixnin the validator and callsetup(n)there.Behaviour changes
commit_valuefails for a value outside[0, r), a negative one included, instead of reducing it.BulletproofVerificationKey's fields can't be read or set outsidebullet.ak.generate_proof_deterministicno longer exists; callers supply aProofBlindingtogenerate_proof.Tests
known_issue_16_bullet_commit_value_reduces_mod_ris replaced byprop_bullet_commit_value_rejects_out_of_field(fail:value + k * rmust fail for everykfrom -1000 to 1000 except 0). New unit tests:commit_valuefails forrand for-1, and accepts0andr - 1(which commits tog^-1). Mutation check: removing the check, or moving either bound by one, fails a test.aiken check, so it was checked with probe files as listed above. The property tests now hold the key as a constant, sosetupruns once at compile time rather than in every case.bullet.ak's tests callgenerate_proofwith the privatederive_blinding;tests/bullet_propshas its ownseeded_blinding.Not in this PR
A validator can't
expectaBulletproofProoffrom its redeemer either: itsState<Scalar>fields are an opaque stdlib type. It has to build the proof from plain integers and compressed points, as the sample validator above does. A decoder for that is separate work.Checks
aiken check -D: 82 tests, all pass, no warningsaiken fmt --checkandaiken buildpass