Repository navigation
Bulletproofs: decode a proof from a redeemer - #26
Merged
Merged
Conversation
BulletproofProof can't come from a redeemer, because its scalars are State<Scalar>, which is opaque in stdlib 3.0.0, so expect on Data is a compile error. Add CompressedBulletproofProof, with compressed G1 points as ByteArray and scalars as Int, plus uncompress_proof and compress_proof. uncompress_proof fails unless every scalar is in [0, r), since scalars are used mod r and x + r or x - r would otherwise decode to the same proof. Points go through g1.decompress, which fails off the curve or outside the subgroup. It fails rather than returning None, like commit_value and the Groth16 and PLONK decoders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A compressed proof decodes to one that verifies and re-encodes to the same data; tau_x, mu, or an l_vec or r_vec entry given as x + k * r (negative for k < 0) is rejected; and a point outside the subgroup in any of the four point fields is rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bulletproofs report: CompressedBulletproofProof, uncompress_proof and compress_proof in section 3, the new tests in section 7, and the "No on-chain entry point yet" limitation replaced by what is still left to a validator (trusting V). The key table in section 4 is re-measured with a spend validator that takes V from its datum and the proof from its redeemer: 2,888 bytes calling setup(8), 22,647 bytes with a constant key. Test counts go from 82 to 89 in all three report headers. The PLONK header also said 5/5 for tests/point_props, which has 4 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the compressed Bulletproof proof representation and conversion changes.
No open issues 🎉
What changed in this PR
This PR lets validators receive Bulletproofs proofs through redeemers or datums, avoiding the opaque scalar types in BulletproofProof.
Changes:
- Adds
CompressedBulletproofProofand conversion functions with scalar-range and point validation. - Adds unit and property tests for round trips and rejection of invalid encodings.
- Documents validator integration, updated cost measurements, and reported test totals.
| File | Description |
|---|---|
zkp/lib/tests/bullet_props.ak |
Adds round-trip, scalar-range, and subgroup-rejection properties. |
zkp/lib/bullet/bullet.ak |
Adds the plain-data proof type, encoding/decoding functions, and unit tests. |
zkp/docs/plonk-implementation-report.md |
Updates the package test total and corrects the point-property count. |
zkp/docs/groth16-implementation-report.md |
Updates the package test total. |
zkp/docs/bulletproofs-implementation-report.md |
Documents the new API, validator example, tests, costs, and remaining integration responsibilities. |
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.
A validator couldn't take a Bulletproofs proof from its redeemer.
BulletproofProofhasState<Scalar>fields, andStateis opaque in stdlib 3.0.0, soexpect proof: BulletproofProof = redeemeris a compile error and the type can't be a redeemer type. A validator had to build the proof by hand from plain integers and compressed points.What changes
CompressedBulletproofProof: the same fields as plain data, with each point a 48-byte compressed G1 encoding and each scalar anInt.uncompress_proof, which turns it into aBulletproofProof. It fails unless every scalar lies in[0, r)and every point gets throughg1.decompress, which rejects points off the curve or outside the prime-order subgroup.r, so without the range checkx + randx - rwould decode to the same proof asx, and one proof would have many encodings that all verify. The Groth16 and PLONK public inputs are checked the same way (common/inputs.ak).None, likecommit_valueand the Groth16 and PLONK proof decoders. A bad point can't be reported any other way, sinceg1.decompressis a builtin that fails on one.verify, which already returnsFalseunlessl_vecandr_veceach havenentries.compress_proof, the reverse, for building a redeemer from a proof made withgenerate_proof.A validator now looks like this:
Tests
bullet.ak: a compressed proof round-trips and still verifies;tau_x + ris rejected; anl_vecentry given asx - r(negative) is rejected; a point whosexis not on the curve is rejected.tests/bullet_props.ak: the round trip for any value, blinding and seed;tau_x,mu, or the first entry ofl_vecorr_vecgiven asx + k·r(k from -1000 to 1000, not zero) is rejected; a point on the curve but outside the subgroup is rejected in each ofa,s,t1andt2.x < 0,x >= r) makes a unit test and the scalar property fail. The point tests were checked by putting a valid point in place of the bad one, which makes both fail.89 tests pass with
aiken check -D(82 before).aiken fmtandaiken buildare clean.Cost
Measured at n = 8 with the validator above, which was built only to measure and isn't part of the package: 2,888 bytes when it calls
setup(8), and 22,647 bytes withconst vk = bullet.setup(8). One call to its spend handler, with the redeemer decoded fromDatafirst, costs 3.40M memory and 8.09B CPU, about 0.23M and 0.28B more thanverifyon a proof that's already decoded. The implementation report's key table now uses this validator.Docs
The Bulletproofs report covers the new type and functions in §3, the new tests in §7, and the re-measured key table in §4. In §8, the "No on-chain entry point yet" limitation is replaced by what's still left to a validator: deciding why to trust
V. All three report headers now count 89 tests, and the PLONK header'stests/point_propscount is corrected from 5 to 4.