Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix off-by-one so pedersen_hash doesn't consume too many generators. #111

Merged
merged 2 commits into from
Aug 20, 2019

Conversation

jimpo
Copy link
Contributor

@jimpo jimpo commented Aug 19, 2019

Currently, circuit::pedersen_hash::pedersen_hash always consumes one too many generators because segment_generators.next() is called before checking bits.next().

let mut segment_generators = params.pedersen_circuit_generators().iter();
let boolean_false = Boolean::constant(false);

let mut segment_i = 0;
loop {
while bits.peek().is_some() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the None case of segment_result unreachable, and I'd like this to be more obvious. We could refactor the inner while loop to address this, but it's also probably fine to just call unreachable!() instead of break.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit Use expect to remove unreachable break.

@str4d
Copy link
Contributor

str4d commented Aug 19, 2019

CI failed due to formatting errors in the latest commit.

@str4d
Copy link
Contributor

str4d commented Aug 20, 2019

cargo fmt still returns a formatting error. What version of cargo and rustfmt are you using?

@str4d str4d requested a review from ebfull August 20, 2019 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants