Add DST to bulletproofs, DDH and key consistency proofs#967
Open
jonas-lj wants to merge 1 commit into
Open
Conversation
fa1d158 to
b519d32
Compare
69cb481 to
9ced462
Compare
a930d31 to
11a526e
Compare
benr-ml
approved these changes
Jun 2, 2026
Adds a domain-separation-tag (DST) parameter to the range proofs (bulletproofs) and the sigma-protocol proofs used by Contra: - RangeProof prove/verify bind the DST into the Merlin transcript. - DdhTupleNizk (nizk.rs) and ZeroProof / ConsistencyProof / KeyConsistencyProof (twisted_elgamal.rs) bind the DST into their Fiat-Shamir challenge. The DDH, ElGamal and key-consistency challenge constructions are made byte-for-byte compatible with the Move and TypeScript implementations in Contra: blake2b256(dst || canonical-element-bytes... in Move's order) with the top byte zeroed and reduced to a canonical little-endian scalar, exposed as RistrettoScalar::fiat_shamir_challenge. The DDH challenge reduction is abstracted behind a FiatShamirChallenge strategy trait (default Blake2bCanonicalChallenge) so alternative reductions can be plugged in; ZeroProof and KeyConsistencyProof reuse the same strategy.
Daeinar
reviewed
Jun 15, 2026
Comment on lines
+73
to
+80
| fn challenge(x_g: &G, x_h: &G, a: &G, b: &G, dst: &[u8]) -> G::ScalarType { | ||
| let chunks: Vec<Vec<u8>> = vec![ | ||
| dst.to_vec(), | ||
| bcs::to_bytes(x_g).expect("Serialization succeeds"), | ||
| bcs::to_bytes(x_h).expect("Serialization succeeds"), | ||
| bcs::to_bytes(a).expect("Serialization succeeds"), | ||
| bcs::to_bytes(b).expect("Serialization succeeds"), | ||
| ]; |
Collaborator
There was a problem hiding this comment.
Nit: Should we pass parameters to challenge in the same order as they are processed, i.e., move dst to the front?
Daeinar
reviewed
Jun 15, 2026
| let mut digest = Blake2b256::digest(bcs::to_bytes(msg).unwrap()).digest; | ||
| digest[31] = 0; | ||
| RistrettoScalar::from_byte_array(&digest).expect("Always in field") | ||
| /// Derive an internal batching coefficient labelled `label` from the challenge `c` and (optional) |
Collaborator
There was a problem hiding this comment.
This should not be derived from the challenge c but from a fresh random value. I know that this will be fixed in another PR (right?) but I'm wondering if it would make sense to write here already that the batching coefficient will be derived from randomness r instead of challenge c (i.e. update the name of the input parameter etc)?
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.
Adds a domain-separation-tag (
dst) to the bulletproof range proofs and the Twisted ElGamal / DDH sigma proofs (DdhTupleNizk,ZeroProof,ConsistencyProof,KeyConsistencyProof).The sigma-proof challenges are made byte-for-byte compatible with Contra's Move/TS implementations:
blake2b256(dst || canonical-element-bytes…), top byte zeroed, canonical LE scalar (RistrettoScalar::fiat_shamir_challenge). Breaking change: prove/verify call sites now require adst.This changes range proof verification, so Sui must be updated.
Test plan
cargo test -p fastcrypto --lib(nizk, twisted_elgamal, bulletproofs)cargo fmt --check+cargo xclippy -D warnings