RescueCipher
The Rescue cipher in Counter (CTR) mode, with a fixed block size m = 5. See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287
Constructors
Constructor
new RescueCipher(
sharedSecret
):RescueCipher
Constructs a RescueCipher instance using a shared secret. The key is derived using HKDF-RescuePrime and used to initialize the RescueDesc.
Parameters
Parameter | Type | Description |
---|---|---|
sharedSecret | Uint8Array | The shared secret to derive the cipher key from. |
Returns
RescueCipher
Properties
Property | Type |
---|---|
desc | RescueDesc |
Methods
decrypt()
decrypt(
ciphertext
,nonce
):bigint
[]
Deserializes and decrypts the ciphertext vector in Counter (CTR) mode.
Parameters
Parameter | Type | Description |
---|---|---|
ciphertext | number [][] | The array of arrays of numbers (each 32 bytes) to decrypt. |
nonce | Uint8Array | A 16-byte nonce for CTR mode. |
Returns
bigint
[]
The decrypted plaintext as an array of bigints.
decrypt_raw()
decrypt_raw(
ciphertext
,nonce
):bigint
[]
Decrypts the ciphertext vector in Counter (CTR) mode (raw, expects bigints).
Parameters
Parameter | Type | Description |
---|---|---|
ciphertext | bigint [] | The array of ciphertext bigints to decrypt. |
nonce | Uint8Array | A 16-byte nonce for CTR mode. |
Returns
bigint
[]
The decrypted plaintext as an array of bigints.
Throws
Error if the nonce is not 16 bytes long.
encrypt()
encrypt(
plaintext
,nonce
):number
[][]
Encrypts the plaintext vector in Counter (CTR) mode and serializes each block.
Parameters
Parameter | Type | Description |
---|---|---|
plaintext | bigint [] | The array of plaintext bigints to encrypt. |
nonce | Uint8Array | A 16-byte nonce for CTR mode. |
Returns
number
[][]
The ciphertext as an array of arrays of numbers (each 32 bytes).
encrypt_raw()
encrypt_raw(
plaintext
,nonce
):bigint
[]
Encrypts the plaintext vector in Counter (CTR) mode (raw, returns bigints).
Parameters
Parameter | Type | Description |
---|---|---|
plaintext | bigint [] | The array of plaintext bigints to encrypt. |
nonce | Uint8Array | A 16-byte nonce for CTR mode. |
Returns
bigint
[]
The ciphertext as an array of bigints.
Throws
Error if the nonce is not 16 bytes long.