apoelstra / secp256k1-zkp

Personal fork of -zkp. Has some old mimblewimble stuff but mostly I just PR everything upstream now.
MIT License
82 stars 27 forks source link

bulletproofs: expose a macro returning proof-size #13

Closed HalosGhost closed 2 years ago

HalosGhost commented 2 years ago

This PR adds a convenience macro enabling callers to allocate the necessary and sufficient space for an uncompressed rangeproof. In particular, this makes it tractible to avoid pessimistically over-allocating the maximum possible space an uncompressed rangeproof might ever occupy.

Also, SECP256K1_BULLETPROOFS_RANGEPROOF_UNCOMPRESSED_MAXLENGTH is redefined as a short-cut leveraging the new convenience macro. This both makes clear from where the maximum length is derived, and should avoid the two macros drifting apart should the expected size change (e.g., if compression is supported in the future).

apoelstra commented 2 years ago

ACK that this formula matches the one I implemented in https://github.com/ElementsProject/secp256k1-zkp/pull/123 (but apparently did not make it into https://github.com/ElementsProject/secp256k1-zkp/pull/108)

apoelstra commented 2 years ago

Cherry-picked onto https://github.com/ElementsProject/secp256k1-zkp/pull/108