pub struct Fp256 { /* fields omitted */ }
Square the value. Same as a value times itself, but slightly more performant.
See normalize_little_limbs.
This normalize should only be used when the input is at most
2*p-1. Anything that might be bigger should use the normalize_big
options, which use barrett.
See normalize_little_limbs.
Convert the value to a byte array which is PRIMEBYTES
long.
Ported from BearSSL br_i31_encode.
Create a new instance given the raw limbs form. Note that this is least significant bit first.
Swaps this with other if the value was true
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the minimum of two values. Read more
Performs copy-assignment from source
. Read more
Assume element zero is most sig
Returns the "default value" for a type. Read more
Prints the hex value of the number in big endian (most significant
digit on the left and least on the right) to make debugging easier.
Formats the value using the given formatter.
Performs the +=
operation.
Formats the value using the given formatter. Read more
type Output = Fp256
The resulting type after applying the +
operator.
Performs the +
operation.
type Output = Fp256
The resulting type after applying the -
operator.
Performs the -
operation.
type Output = Fp256
The resulting type after applying the *
operator.
Performs the *
operation.
Note that this reveals the u32, but nothing else. It's expected that the u32 is not secret.
If it is, you can use Mul<$classname>
type Output = Fp256
The resulting type after applying the *
operator.
Performs the *
operation.
type Output = Fp256
The resulting type after applying the *
operator.
Performs the *
operation.
type Output = Fp256
The resulting type after applying the *
operator.
Performs the *
operation.
type Output = Fp256
The resulting type after applying the /
operator.
Performs the /
operation.
type Output = Fp256
The resulting type after applying the -
operator.
Performs the unary -
operation.
Performs the -=
operation.
Note that this uses a conversion to montgomery form and then multiplies by the other value to get back out.
This takes less time than just doing the multiplication and doing a reduction.
Performs the *=
operation.
Returns the additive identity element of Self
, 0
. Read more
Returns true
if self
is equal to the additive identity.
Returns the multiplicative identity element of Self
, 1
. Read more
Returns true
if self
is equal to the multiplicative identity. Read more
type Output = Fp256
The result after applying the operator.
Returns the multiplicative inverse of self
. Read more
Reveals the exponent. If you need constant time, use Pow<$classname>
type Output = Fp256
The result after applying the operator.
type Output = Fp256
The result after applying the operator.
14.94 Algorithm Montgomery exponentiation in Handbook of Applied Crypto
INPUT:m=(ml−1···m0)b,R=bl,m′ =−m−1 modb,e=(et···e0)2 withet =1, and an integer x, 1 ≤ x < m.
OUTPUT: xe mod m.
- x← Mont(x,R2 mod m), A←R mod m. (R mod m and R2 mod m may be pro-ided as inputs.)
- For i from t down to 0 do the following: 2.1 A←Mont(A,A).
2.2 If ei = 1 then A← Mont(A, x).
- A←Mont(A,1).
- Return(A).
type Owned = T
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
type Error = !
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more