Skip to content

@aldea/sdk / Exports / util

Namespace: util

Table of contents

Functions

Functions

bnToBytes

bnToBytes(num, len?): Uint8Array

Encodes the given bigint as a little-endian Uint8Array.

Parameters

NameType
numbigint
len?number

Returns

Uint8Array

Defined in

packages/core/dist/support/util.d.ts:10


bnToShortestBytes

bnToShortestBytes(num): Uint8Array

Parameters

NameType
numbigint

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

NameType
aUint8Array
bUint8Array

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

NameType
dataUint8Array

Returns

bigint

Defined in

packages/core/dist/support/util.d.ts:15


bytesToHex

bytesToHex(b): string

Parameters

NameType
bUint8Array

Returns

string

Defined in

packages/core/dist/support/util.d.ts:28


bytesToStr

bytesToStr(data): string

Encodes the given string as utf8 Uint8Array.

Parameters

NameType
dataUint8Array

Returns

string

Defined in

packages/core/dist/support/util.d.ts:19


concatBytes

concatBytes(...arrs): Uint8Array

Parameters

NameType
...arrsUint8Array[]

Returns

Uint8Array

Defined in

packages/core/dist/support/util.d.ts:28


hexToBytes

hexToBytes(hex): Uint8Array

Parameters

NameType
hexstring

Returns

Uint8Array

Defined in

packages/core/dist/support/util.d.ts:28


invert

invert(num, md?): bigint

Parameters

NameType
numbigint
md?bigint

Returns

bigint

Defined in

packages/core/dist/support/util.d.ts:28


mod

mod(a, b?): bigint

Parameters

NameType
abigint
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

NameType
xbigint
powerbigint
modulobigint

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

NameType
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

NameType
strstring

Returns

Uint8Array

Defined in

packages/core/dist/support/util.d.ts:23