Utilities to assist with implementing big number arithmetic. More...
#include <BigNumberUtil.h>
Static Public Member Functions | |
static void | unpackLE (limb_t *limbs, size_t count, const uint8_t *bytes, size_t len) |
Unpacks the little-endian byte representation of a big number into a limb array. More... | |
static void | unpackBE (limb_t *limbs, size_t count, const uint8_t *bytes, size_t len) |
Unpacks the big-endian byte representation of a big number into a limb array. More... | |
static void | packLE (uint8_t *bytes, size_t len, const limb_t *limbs, size_t count) |
Packs the little-endian byte representation of a big number into a byte array. More... | |
static void | packBE (uint8_t *bytes, size_t len, const limb_t *limbs, size_t count) |
Packs the big-endian byte representation of a big number into a byte array. More... | |
Utilities to assist with implementing big number arithmetic.
Big numbers are represented as arrays of limb_t words, which may be 8 bits, 16 bits, or 32 bits in size depending upon how the library was configured. For AVR, 16 bit limbs usually give the best performance.
Limb arrays are ordered from the least significant word to the most significant.
Definition at line 52 of file BigNumberUtil.h.
|
static |
Packs the big-endian byte representation of a big number into a byte array.
bytes | The byte array to pack into. |
len | The number of bytes in the destination bytes array. |
limbs | The limb array representing the big number, starting with the least significant word. |
count | The number of elements in the limbs array. |
If len is shorter than the length of limbs, then the number will be truncated to the least significant len bytes. If len is longer than the length of limbs, then the high bytes will be filled with zeroes.
Definition at line 293 of file BigNumberUtil.cpp.
|
static |
Packs the little-endian byte representation of a big number into a byte array.
bytes | The byte array to pack into. |
len | The number of bytes in the destination bytes array. |
limbs | The limb array representing the big number, starting with the least significant word. |
count | The number of elements in the limbs array. |
If len is shorter than the length of limbs, then the number will be truncated to the least significant len bytes. If len is longer than the length of limbs, then the high bytes will be filled with zeroes.
Definition at line 207 of file BigNumberUtil.cpp.
|
static |
Unpacks the big-endian byte representation of a big number into a limb array.
limbs | The limb array, starting with the least significant word. |
count | The number of elements in the limbs array. |
bytes | The bytes to unpack. |
len | The number of bytes to unpack. |
If len is shorter than the length of limbs, then the high bytes will be filled with zeroes. If len is longer than the length of limbs, then the high bytes will be truncated and lost.
Definition at line 133 of file BigNumberUtil.cpp.
|
static |
Unpacks the little-endian byte representation of a big number into a limb array.
limbs | The limb array, starting with the least significant word. |
count | The number of elements in the limbs array. |
bytes | The bytes to unpack. |
len | The number of bytes to unpack. |
If len is shorter than the length of limbs, then the high bytes will be filled with zeroes. If len is longer than the length of limbs, then the high bytes will be truncated and lost.
Definition at line 54 of file BigNumberUtil.cpp.