Skip to content

Fix: append final carry after wnaf_form loop#83

Open
revofusion wants to merge 1 commit into
zkcrypto:mainfrom
revofusion:main
Open

Fix: append final carry after wnaf_form loop#83
revofusion wants to merge 1 commit into
zkcrypto:mainfrom
revofusion:main

Conversation

@revofusion

Copy link
Copy Markdown

Summary

Fixes wnaf_form dropping a final carry after processing the last input bit.
For window size w, a negative digit sets carry = 1. If that carry remains after pos >= bit_len, the previous code terminates without emitting it, so the produced WNAF digits reconstructed a different scalar.

For example, with window = 4, [0xff] encoded as [-1, 0, 0, 0, 0, 0, 0, 0], which evaluates to -1 instead of 255.
This appends the final carry when present and adds a regression test for [0xff], whose correct WNAF is [-1, 0, 0, 0, 0, 0, 0, 0, 1].

Test

cargo test wnaf_form_keeps_final_carry

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.

1 participant