Crate crypto_bigint[−][src]
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
subtle
crate. - Leverage what is possible today with const generics on
stable
rust. - Support
const fn
as 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 subtle; | |
pub use generic_array; |
Modules
consts | Type aliases for many constants. |
Macros
nlimbs | Calculate the number of limbs required to represent the given number of bits. |
Structs
Checked | Provides intentionally-checked arithmetic on |
Limb | Big integers are represented as an array of smaller CPU word-size integers called “limbs”. |
UInt | Big unsigned integer. |
Wrapping | Provides intentionally-wrapped arithmetic on |
Constants
LIMB_BYTES | Number of bytes in a |
Traits
ArrayEncoding | generic-array Support for encoding a big integer as a |
Concat | Concatenate two numbers into a “wide” twice-width value, using the |
Encoding | Encoding support. |
Split | Split a number in half, returning the most significant half followed by the least significant. |
Type Definitions
ByteArray | generic-array Alias for a byte array whose size is defined by |
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 |