Skip to content

Conversation

@ppopth
Copy link
Contributor

@ppopth ppopth commented Apr 18, 2020

No description provided.

}

fn mod_final_25519(x: Felem) -> Felem {
const MASK_64BITS: u128 = 0xffff_ffff_ffff_ffff;

Choose a reason for hiding this comment

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

Defining this as a const at the top and replacing all instances would definitely be welcome, along with 0x7fff_....

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea.

acc1 = acc1.wrapping_add(acc0 >> 64);
acc2 = acc2.wrapping_add(acc1 >> 64);
acc3 = acc3.wrapping_add(acc2 >> 64);
acc3 &= 0x7fff_ffff_ffff_ffff;

Choose a reason for hiding this comment

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

What is this extra code doing? It doesn't make sense to me

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like masking the top bit of the output. However is it not sufficient to execute just a single extra round of mul + add?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put the comments in the source code. What do you think?

@ppopth ppopth force-pushed the fix_curve25519 branch 2 times, most recently from 551c60b to 699367b Compare October 29, 2020 08:34
@ppopth ppopth requested a review from Bren2010 October 29, 2020 08:38
mod tests {
use super::super::{mod_final_25519, mod_inv_25519, x25519_shared_key, Felem};
use super::super::{
mod_25519, mod_final_25519, mod_inv_25519, x25519_shared_key, Felem, Felem2,

Choose a reason for hiding this comment

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

mod_25519 and Felem2 never used

assert_eq!(mod_final_25519(max + one).0, zero.0);
}

fn x25519_test_vectors() {

Choose a reason for hiding this comment

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

You've stolen this function's #[test] annotation

@ppopth ppopth requested a review from Bren2010 November 2, 2020 08:31
@Bren2010 Bren2010 merged commit a6d9d05 into cloudflare:master Nov 3, 2020
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