mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Remove fixme notes from FieldElement code
This commit is contained in:
parent
8d46eacd2c
commit
bc731f9d79
1 changed files with 5 additions and 16 deletions
21
src/field.rs
21
src/field.rs
|
|
@ -96,17 +96,10 @@ impl FieldElement {
|
||||||
|
|
||||||
/// Compute (self^(2^250-1), self^11), used as a helper function
|
/// Compute (self^(2^250-1), self^11), used as a helper function
|
||||||
/// within invert() and pow22523().
|
/// within invert() and pow22523().
|
||||||
///
|
|
||||||
/// XXX This returns an extra intermediate to save computation in
|
|
||||||
/// finding inverses, at the cost of an extra copy when it's not
|
|
||||||
/// used (e.g., when raising to (p-1)/2 or (p-5)/8). Good idea?
|
|
||||||
fn pow22501(&self) -> (FieldElement, FieldElement) {
|
fn pow22501(&self) -> (FieldElement, FieldElement) {
|
||||||
// Instead of managing which temporary variables are used
|
// Instead of managing which temporary variables are used
|
||||||
// for what, we define as many as we need and trust the
|
// for what, we define as many as we need and leave stack
|
||||||
// compiler to reuse stack space as appropriate.
|
// allocation to the compiler
|
||||||
//
|
|
||||||
// XXX testing some examples suggests that this does happen,
|
|
||||||
// but it would be good to check asm for this function.
|
|
||||||
//
|
//
|
||||||
// Each temporary variable t_i is of the form (self)^e_i.
|
// Each temporary variable t_i is of the form (self)^e_i.
|
||||||
// Squaring t_i corresponds to multiplying e_i by 2,
|
// Squaring t_i corresponds to multiplying e_i by 2,
|
||||||
|
|
@ -177,12 +170,9 @@ impl FieldElement {
|
||||||
///
|
///
|
||||||
/// The inverse is computed as self^(p-2), since
|
/// The inverse is computed as self^(p-2), since
|
||||||
/// x^(p-2)x = x^(p-1) = 1 (mod p).
|
/// x^(p-2)x = x^(p-1) = 1 (mod p).
|
||||||
//
|
///
|
||||||
// XXX do we want the debug assertion to check for zero? it breaks behaviour
|
/// This function returns zero on input zero.
|
||||||
// such as that such as in curve25519_dalek::montgomery::test::identity_to_monty.
|
|
||||||
pub fn invert(&self) -> FieldElement {
|
pub fn invert(&self) -> FieldElement {
|
||||||
// debug_assert!(*self != FieldElement::zero());
|
|
||||||
|
|
||||||
// The bits of p-2 = 2^255 -19 -2 are 11010111111...11.
|
// The bits of p-2 = 2^255 -19 -2 are 11010111111...11.
|
||||||
//
|
//
|
||||||
// nonzero bits of exponent
|
// nonzero bits of exponent
|
||||||
|
|
@ -194,8 +184,7 @@ impl FieldElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Raise this field element to the power (p-5)/8 = 2^252 -3.
|
/// Raise this field element to the power (p-5)/8 = 2^252 -3.
|
||||||
/// Used in decoding.
|
fn pow_p58(&self) -> FieldElement {
|
||||||
pub fn pow_p58(&self) -> FieldElement {
|
|
||||||
// The bits of (p-5)/8 are 101111.....11.
|
// The bits of (p-5)/8 are 101111.....11.
|
||||||
//
|
//
|
||||||
// nonzero bits of exponent
|
// nonzero bits of exponent
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue