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

remove asserts that could leak timing information (credits to @pornin) #31

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/field/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ fn sub_extra(a: &Scalar, b: &Scalar, carry: u32) -> Scalar {
// Since the borrow should never be more than 0, the carry should never be more than 1;
// XXX: Explain why the case of borrow == 1 should never happen
let borrow = chain + (carry as i64);
assert!(borrow == -1 || borrow == 0);

chain = 0i64;
for i in 0..14 {
Expand Down
4 changes: 1 addition & 3 deletions src/field/u32/prime_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,7 @@ impl FieldElement28 {
// If the value was more than p, then the final borrow will be zero. This is scarry.
// Case 2:
// If the value was less than p, the final borrow will be -1.

// The only two possibilities for the borrow bit is -1 or 0.
assert!(scarry == 0 || scarry + 1 == 0);
// Thus the only two possibilities for the borrow bit is -1 or 0.

let scarry_mask = (scarry as u32) & MASK;
let mut carry = 0u64;
Expand Down
Loading