Arcium LogoArcium TS SDK Docs

Aes128Cipher

AES-128 cipher in Counter (CTR) mode, using HKDF-SHA3-256 to derive the key from a shared secret. See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.

Constructors

Constructor

new Aes128Cipher(sharedSecret): Aes128Cipher

Constructs an AES-128 cipher instance using a shared secret. The key is derived using HKDF-SHA3-256.

Parameters

ParameterTypeDescription
sharedSecretUint8ArrayThe shared secret to derive the AES key from.

Returns

Aes128Cipher

Properties

PropertyType
keyUint8Array

Methods

decrypt()

decrypt(ciphertext, nonce): Uint8Array

Decrypts the ciphertext array in Counter (CTR) mode.

Parameters

ParameterTypeDescription
ciphertextUint8ArrayThe data to decrypt.
nonceUint8ArrayAn 8-byte nonce for CTR mode.

Returns

Uint8Array

The decrypted plaintext as a Uint8Array.

Throws

Error if the nonce is not 8 bytes long.


encrypt()

encrypt(plaintext, nonce): Uint8Array

Encrypts the plaintext array in Counter (CTR) mode.

Parameters

ParameterTypeDescription
plaintextUint8ArrayThe data to encrypt.
nonceUint8ArrayAn 8-byte nonce for CTR mode.

Returns

Uint8Array

The encrypted ciphertext as a Uint8Array.

Throws

Error if the nonce is not 8 bytes long.