@celo/encrypted-backup"utils"

Module: "utils"

Index

Enumerations

Interfaces

Type aliases

Functions

Type aliases

EIP712Wallet

Ƭ EIP712Wallet: Pick‹ReadOnlyWallet, "getAccounts" | "hasAccount" | "signTypedData"›

Defined in packages/sdk/encrypted-backup/src/utils.ts:11

Pared down ReadOnlyWallet type that supports the required functions of EIP-712 signing.

Functions

computationalHardenKey

computationalHardenKey(key: Buffer, config: ComputationalHardeningConfig): Promise‹Result‹Buffer, PbkdfError | ScryptError››

Defined in packages/sdk/encrypted-backup/src/utils.ts:148

Parameters:

Name Type
key Buffer
config ComputationalHardeningConfig

Returns: Promise‹Result‹Buffer, PbkdfError | ScryptError››


decrypt

decrypt(key: Buffer, ciphertext: Buffer): Result‹Buffer, DecryptionError

Defined in packages/sdk/encrypted-backup/src/utils.ts:66

AES-256-GCM decrypt the given data with the given 32-byte key. Ciphertext should be encoded as { iv || data || auth tag }.

Parameters:

Name Type
key Buffer
ciphertext Buffer

Returns: Result‹Buffer, DecryptionError


deriveKey

deriveKey(info: KDFInfo, sources: Buffer[]): Buffer

Defined in packages/sdk/encrypted-backup/src/utils.ts:34

Key derivation function for mixing source keying material.

remarks This function does not add any hardening to the input keying material. It is used only to mix the provided key material sources. It's output should not be used to directly derive a key from a password or other low entropy sources.

Parameters:

Name Type Description
info KDFInfo Fixed string value used for domain separation.
sources Buffer[] An array of keying material source values (e.g. a password and a nonce).

Returns: Buffer


encrypt

encrypt(key: Buffer, data: Buffer): Result‹Buffer, EncryptionError

Defined in packages/sdk/encrypted-backup/src/utils.ts:51

AES-256-GCM encrypt the given data with the given 32-byte key. Encode the ciphertext as { iv || data || auth tag }

Parameters:

Name Type
key Buffer
data Buffer

Returns: Result‹Buffer, EncryptionError


pbkdf2

pbkdf2(key: Buffer, iterations: number): Promise‹Result‹Buffer, PbkdfError››

Defined in packages/sdk/encrypted-backup/src/utils.ts:103

PBKDF2-SHA256 computational key hardening.

remarks When possible, a memory hard function such as scrypt should be used instead. No salt parameter is provided as the intended use case of this function is to harden a key value which is derived from a password but already has the salt mixed in.

see { @link https://nodejs.org/api/crypto.html#cryptopbkdf2password-salt-iterations-keylen-digest-callback | NodeJS crypto.pbkdf2 API }

Parameters:

Name Type Description
key Buffer Key buffer to compute hardening against. Should have a salt or nonce mixed in.
iterations number Number of PBKDF2 iterations to execute for key hardening.

Returns: Promise‹Result‹Buffer, PbkdfError››


scrypt

scrypt(key: Buffer, options: ScryptOptions): Promise‹Result‹Buffer, ScryptError››

Defined in packages/sdk/encrypted-backup/src/utils.ts:134

scrypt computational key hardening.

remarks No salt parameter is provided as the intended use case of this function is to harden a key value which is derived from a password but already has the salt mixed in.

see { @link https://nodejs.org/api/crypto.html#cryptoscryptpassword-salt-keylen-options-callback | NodeJS crypto.scrypt API }

Parameters:

Name Type Description
key Buffer Key buffer to compute hardening against. Should have a salt or nonce mixed in.
options ScryptOptions Options to control the cost of the scrypt function.

Returns: Promise‹Result‹Buffer, ScryptError››