@aldea/sdk / Exports / util
Namespace: util
Table of contents
Functions
- bnToBytes
- bnToShortestBytes
- buffEquals
- bytesToBn
- bytesToHex
- bytesToStr
- concatBytes
- hexToBytes
- invert
- mod
- pow2
- randomBytes
- strToBytes
Functions
bnToBytes
▸ bnToBytes(num
, len?
): Uint8Array
Encodes the given bigint as a little-endian Uint8Array.
Parameters
Name | Type |
---|---|
num | bigint |
len? | number |
Returns
Uint8Array
Defined in
packages/core/dist/support/util.d.ts:10
bnToShortestBytes
▸ bnToShortestBytes(num
): Uint8Array
Parameters
Name | Type |
---|---|
num | bigint |
Returns
Uint8Array
Defined in
packages/core/dist/support/util.d.ts:11
buffEquals
▸ buffEquals(a
, b
): boolean
Check if 2 Uint8Arrays are equal // TODO - review function name
Parameters
Name | Type |
---|---|
a | Uint8Array |
b | Uint8Array |
Returns
boolean
Defined in
packages/core/dist/support/util.d.ts:6
bytesToBn
▸ bytesToBn(data
): bigint
Decodes the given Uint8Array as a little-endian bigint.
Parameters
Name | Type |
---|---|
data | Uint8Array |
Returns
bigint
Defined in
packages/core/dist/support/util.d.ts:15
bytesToHex
▸ bytesToHex(b
): string
Parameters
Name | Type |
---|---|
b | Uint8Array |
Returns
string
Defined in
packages/core/dist/support/util.d.ts:28
bytesToStr
▸ bytesToStr(data
): string
Encodes the given string as utf8 Uint8Array.
Parameters
Name | Type |
---|---|
data | Uint8Array |
Returns
string
Defined in
packages/core/dist/support/util.d.ts:19
concatBytes
▸ concatBytes(...arrs
): Uint8Array
Parameters
Name | Type |
---|---|
...arrs | Uint8Array [] |
Returns
Uint8Array
Defined in
packages/core/dist/support/util.d.ts:28
hexToBytes
▸ hexToBytes(hex
): Uint8Array
Parameters
Name | Type |
---|---|
hex | string |
Returns
Uint8Array
Defined in
packages/core/dist/support/util.d.ts:28
invert
▸ invert(num
, md?
): bigint
Parameters
Name | Type |
---|---|
num | bigint |
md? | bigint |
Returns
bigint
Defined in
packages/core/dist/support/util.d.ts:28
mod
▸ mod(a
, b?
): bigint
Parameters
Name | Type |
---|---|
a | bigint |
b? | bigint |
Returns
bigint
Defined in
packages/core/dist/support/util.d.ts:28
pow2
▸ pow2(x
, power
, modulo
): bigint
Computes x ^ (2 ^ power) mod p
Parameters
Name | Type |
---|---|
x | bigint |
power | bigint |
modulo | bigint |
Returns
bigint
Defined in
packages/core/dist/support/util.d.ts:27
randomBytes
▸ randomBytes(bytesLength?
): Uint8Array
Secure PRNG. Uses crypto.getRandomValues
, which defers to OS.
Parameters
Name | Type |
---|---|
bytesLength? | number |
Returns
Uint8Array
Defined in
node_modules/@noble/hashes/utils.d.ts:89
strToBytes
▸ strToBytes(str
): Uint8Array
Decodes the given utf8 Uint8Array as a string.
Parameters
Name | Type |
---|---|
str | string |
Returns
Uint8Array
Defined in
packages/core/dist/support/util.d.ts:23