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 crate::limb::Limb;
pub use subtle;
pub use generic_array;

Modules

Type aliases for many constants.

Big integers are represented as an array of smaller CPU word-size integers called “limbs”.

Macros

Calculate the number of limbs required to represent the given number of bits.

Structs

Provides intentionally-checked arithmetic on T.

Big unsigned integer.

Provides intentionally-wrapped arithmetic on T.

Constants

LIMB_BYTESDeprecated

Number of bytes in a Limb.

Traits

Compute self + rhs mod p.

ArrayEncodinggeneric-array

Support for encoding a big integer as a GenericArray.

Concatenate two numbers into a “wide” twice-width value, using the rhs value as the least significant value.

Encoding support.

Compute self * rhs mod p.

Compute -self mod p.

Split a number in half, returning the most significant half followed by the least significant.

Compute self - rhs mod p.

Type Definitions

ByteArraygeneric-array

Alias for a byte array whose size is defined by ArrayEncoding::ByteSize.

64-bit unsigned big integer

128-bit unsigned big integer

192-bit unsigned big integer

256-bit unsigned big integer

384-bit unsigned big integer

448-bit unsigned big integer

512-bit unsigned big integer

768-bit unsigned big integer

896-bit unsigned big integer

1024-bit unsigned big integer

1536-bit unsigned big integer

1792-bit unsigned big integer

2048-bit unsigned big integer

3072-bit unsigned big integer

3584-bit unsigned big integer

4096-bit unsigned big integer

6144-bit unsigned big integer

8192-bit unsigned big integer