fromPrimitive
Creates a new modulus from a primitive value. The modulus must be odd and larger than 2.
Function parameters
Parameters
- T:type
- x:T
An unsigned big integer with a fixed maximum size (`max_bits`), suitable for cryptographic operations.
Functions
Error sets in this namespace
Error Sets
- OverflowError
- Value is too large for the destination.
- InvalidModulusError
- Invalid modulus.
- NullExponentError
- Exponentiation with a null exponent.
- FieldElementError
- Invalid field element for the given modulus.
- RepresentationError
- Invalid representation (Montgomery vs non-Montgomery domain.)
- Error
- The set of all possible errors `std.crypto.ff` functions can return.
Source
Implementation
pub fn fromPrimitive(comptime T: type, x: T) (InvalidModulusError || OverflowError)!Self {
comptime assert(@bitSizeOf(T) <= max_bits); // Primitive type is larger than the modulus type.
const v = try FeUint.fromPrimitive(T, x);
return try Self.fromUint(v);
}