Expand description
Pure Rust implementation of a big integer library designed for cryptography.
§About
This library has been designed from the ground-up for use in cryptographic
applications. It provides constant-time, no_std-friendly implementations
of modern formulas implemented using const generics.
§Minimum Supported Rust Version
Rust 1.51 at a minimum.
§Goals
- No heap allocations i.e.
no_std-friendly. - Constant-time by default using traits from the
subtlecrate. - Leverage what is possible today with const generics on
stablerust. - Support
const fnas much as possible, including decoding big integers from bytes/hex and performing arithmetic operations on them, with the goal of being able to compute values at compile-time.
§Status
This library presently provides only a baseline level of functionality. It’s new, unaudited, and may contain bugs. We recommend that it only be used in an experimental capacity for now.
Please see the feature wishlist tracking ticket for more information.
§generic-array interop
When the optional generic-array feature is enabled, this library provides
an ArrayEncoding trait which can be used to serialize/deserialize big
integer values as GenericArray<u8, N>.
Re-exports§
pub use crate::checked::Checked;pub use crate::limb::Limb;pub use crate::wrapping::Wrapping;pub use subtle;pub use self;pub use crate::traits::*;pub use crate::uint::*;
Modules§
- consts
- limb
- Big integers are represented as an array of smaller CPU word-size integers called “limbs”.
Macros§
- nlimbs
- Calculate the number of limbs required to represent the given number of bits.
Structs§
- Checked
- Provides intentionally-checked arithmetic on
T. - UInt
- Big unsigned integer.
- Wrapping
- Provides intentionally-wrapped arithmetic on
T.
Constants§
- LIMB_
BYTES Deprecated - Number of bytes in a
Limb.
Traits§
- AddMod
- Compute
self + rhs mod p. - Array
Encoding - Support for encoding a big integer as a
GenericArray. - Concat
- Concatenate two numbers into a “wide” twice-width value, using the
rhsvalue as the least significant value. - Encoding
- Encoding support.
- MulMod
- Compute
self * rhs mod p. - NegMod
- Compute
-self mod p. - Split
- Split a number in half, returning the most significant half followed by the least significant.
- SubMod
- Compute
self - rhs mod p.
Type Aliases§
- Byte
Array - Alias for a byte array whose size is defined by
ArrayEncoding::ByteSize. - U64
- 64-bit unsigned big integer
- U128
- 128-bit unsigned big integer
- U192
- 192-bit unsigned big integer
- U256
- 256-bit unsigned big integer
- U384
- 384-bit unsigned big integer
- U448
- 448-bit unsigned big integer
- U512
- 512-bit unsigned big integer
- U768
- 768-bit unsigned big integer
- U896
- 896-bit unsigned big integer
- U1024
- 1024-bit unsigned big integer
- U1536
- 1536-bit unsigned big integer
- U1792
- 1792-bit unsigned big integer
- U2048
- 2048-bit unsigned big integer
- U3072
- 3072-bit unsigned big integer
- U3584
- 3584-bit unsigned big integer
- U4096
- 4096-bit unsigned big integer
- U6144
- 6144-bit unsigned big integer
- U8192
- 8192-bit unsigned big integer