dalek-cryptography / bulletproofs

A pure-Rust implementation of Bulletproofs using Ristretto.
MIT License
1.02k stars 216 forks source link

u128 and Scalar #364

Open ripa1995 opened 1 year ago

ripa1995 commented 1 year ago

Disclaimer: This pull request has been made against main and not develop since the latter is unmaintained, while the former has recent updates.

Motivations

Allowing bigger inputs increases the landscape of domains in which bulletproofs can be used.

We increased the bitsize to 128 and replaced the u64 type with u128 in many places within the code.

We also decided to support Scalar as input value, and we decided to implement it as a feature of the library, which can be enabled with scalar_range_proof. Also in this case we had to modify the code such that Scalar could be accepted. To support Scalar we had to implement the extraction of a single bit from a Scalar.

Our implementation of the above consists in an indexing of the Scalar's underlying array of bytes, followed by a shift and mask of the appropriate byte. In both cases where this operation is used, the index is not secret, so the timing and memory access patterns of this operation shouldn't enable any side-channel attack.

We think that at the moment there is no bigger bitsize value that can be used together with Scalar, because the range for the next eligible bitsize (i.e., [0, 2^256)), contains all possible Scalar values.

Changes

Extras

This PR also solves issues #359 and #363.

ripa1995 commented 1 year ago

Dear @cathieyun, @hdevalence, @oleganza; it looks like that we are not allowed to put reviewers, so I'm adding this comment as "request for review", tagging all of you, since you are the authors of the library. Thank you in advance, for your time and effort.