You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge #286: refactor confidential.rs and clean up code
e9ffc69 confidential: directly use Read/Write in Encodable/Decodable (Andrew Poelstra)
c92694b confidential: add a bunch of consts and type aliases (Andrew Poelstra)
2a4ce2d confidential: enable use_self lint (Andrew Poelstra)
9a4c8b8 run rustfmt on src/confidential/* tree (Andrew Poelstra)
8cc6e02 confidential: move commitment types into their own modules (Andrew Poelstra)
278ad33 confidential: improve unit tests by defining constants (Andrew Poelstra)
273ed15 confidential: encapsulate SurjectionProof (Andrew Poelstra)
de00948 confidential: encapsulate RangeProof (Andrew Poelstra)
06f4575 pset: add unit test from Claude (Andrew Poelstra)
9b949f4 rename confidential.rs to confidential/mod.rs (Andrew Poelstra)
4336802 remove Encodable/Decodable impls for PedersenCommitment/Generator/PublicKey (Andrew Poelstra)
f3a0afe fuzz: fix typo in generate-files.sh (Andrew Poelstra)
ad4788e rustfmt src/lib.rs (Andrew Poelstra)
Pull request description:
This is a lot of commits but hopefully should be straightforward to review. Two are formatting, one is a rename-only, at least one is code-move-only, and a few others just enable lints. The big changes are:
1. We encapsulate `RangeProof` and `SurjectionProof` into dedicated types, rather than using `Option<Box<secp256k1_zkp::RangeProof>>` everywhere. This fixes a type confusion in the PSET code and overall greatly simplifies all our interactions with rangeproofs and surjection proofs.
2. We break apart the three confidential commitment types into their own modules and refactor the code a bunch to try to minimize the text-diff between the modules. This hopefully will prevent divergence between these three basically-the-same objects. But there is no user-visible effect to this change.
3. We remove `Encodable/Decodable` for secp256k1_zkp objects, since these should never appear "bare" in rust-elements code. Instead we implement these only on rust-elements wrapper types. We also simplify these implementations a bit to e.g. directly encode big-endian integers for confidential values rather than calling `u64::consensus_encode` then `u64::swap_bytes`.
The next PR will introduce the rust-bitcoin 0.32.100 series, which have new `Encode`/`Decode` traits with much better error handling, no more `bitcoin-io`, and fewer allocations. This PR helps set the stage for that by cleaning up the existing `Encodable/Decodable` impls and improving the overall type safety of the library.
ACKs for top commit:
delta1:
ACK e9ffc69; tested locally
Tree-SHA512: 2faf30de7131aafcc67a6b8d3ca44d2e39292632b778460f6c7e887dabd14e88bef986a1fd646e6c4a4e0e4127fad4373600ac891f21e1f156ce582f3d466595
0 commit comments