Struct curve25519_dalek::field::FieldElement32 [] [src]

pub struct FieldElement32(_);

A FieldElement32 represents an element of the field GF(2255 - 19).

In the 32-bit implementation, a FieldElement32 is represented in radix 225.5 as ten i32s, so that an element t, entries t[0],...,t[9], represents the integer t[0]+226 t[1]+251 t[2]+277 t[3]+2102 t[4]+...+2230 t[9].

The coefficients t[i] are allowed to grow between multiplications.

XXX document by how much

Warning

You almost certainly do not want to use FieldElement32 directly. Consider using curve25519_dalek::field::FieldElement, which will automatically select between FieldElement32 and FieldElement64 depending on whether curve25519-dalek was compiled with --features="nightly".

This implementation, FieldElement32, is intended for platforms that can multiply 32-bit inputs to produce 64-bit outputs, and is not preferred for use on x86_64, since the 64-bit implementation is both much simpler and much faster. However, the FieldElement64 implementation requires Rust's u128, which is not yet stable.

Methods

impl FieldElement32
[src]

[src]

Invert the sign of this field element

[src]

Construct zero.

[src]

Construct one.

[src]

Construct -1.

[src]

Load a FieldElement64 from the low 255 bits of a 256-bit input.

Warning

This function does not check that the input used the canonical representative. It masks the high bit, but it will happily decode 2255 - 18 to 1. Applications that require a canonical encoding of every field element should decode, re-encode to the canonical encoding, and check that the input was canonical.

XXX the above applies to the 64-bit implementation; check that it applies here too.

[src]

Serialize this FieldElement64 to a 32-byte array. The encoding is canonical.

[src]

Calculates h = f*f. Can overlap h with f.

XXX limbs: better to talk about headroom?

Preconditions

  • |f[i]| bounded by 1.1*226, 1.1*225, 1.1*226, 1.1*225, etc.

Postconditions

  • |h[i]| bounded by 1.1*225, 1.1*224, 1.1*225, 1.1*224, etc.

[src]

Square this field element and multiply the result by 2.

XXX explain why square2 exists vs square (overflow)

Preconditions

  • |f[i]| bounded by 1.65*226, 1.65*225, 1.65*226, 1.65*225, etc.

Postconditions

  • |h[i]| bounded by 1.01*225, 1.01*224, 1.01*225, 1.01*224, etc.

Notes

See fe_mul.c in ref10 implementation for discussion of implementation strategy.

Trait Implementations

impl Copy for FieldElement32
[src]

impl Clone for FieldElement32
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for FieldElement32
[src]

[src]

Formats the value using the given formatter.

impl<'b> AddAssign<&'b FieldElement32> for FieldElement32
[src]

[src]

Performs the += operation.

impl<'a, 'b> Add<&'b FieldElement32> for &'a FieldElement32
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'b> SubAssign<&'b FieldElement32> for FieldElement32
[src]

[src]

Performs the -= operation.

impl<'a, 'b> Sub<&'b FieldElement32> for &'a FieldElement32
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<'b> MulAssign<&'b FieldElement32> for FieldElement32
[src]

[src]

Performs the *= operation.

impl<'a, 'b> Mul<&'b FieldElement32> for &'a FieldElement32
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a> Neg for &'a FieldElement32
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

impl ConditionallyAssignable for FieldElement32
[src]

[src]

Conditionally assign other to self in constant time. Read more