di-wings
Version:
Aviary Tech's common library for decentralized identity
43 lines • 1.88 kB
TypeScript
export declare const JWE_ENC = "XC20P";
/**
* Generates a content encryption key (CEK). The 256-bit key is intended to be
* used as a XChaCha20Poly1305 (draft-irtf-cfrg-xchacha-01) key.
*
* @returns {Promise<Uint8Array>} - Resolves to the generated key.
*/
export declare function generateKey(): Promise<Uint8Array<ArrayBufferLike>>;
/**
* Encrypts some data. The data will be encrypted using the given
* 256-bit XChaCha20Poly1305 (draft-irtf-cfrg-xchacha-01) content encryption
* key (CEK).
*
* @param {object} options - The options to use.
* @param {Uint8Array} options.data - The data to encrypt.
* @param {Uint8Array} [options.additionalData] - Optional additional
* authentication data.
* @param {Uint8Array} options.cek - The content encryption key to use.
*
* @returns {Promise<object>} - Resolves to `{ciphertext, iv, tag}`.
*/
export declare function encrypt({ data, additionalData, cek }: any): Promise<{
ciphertext: Uint8Array<ArrayBufferLike>;
iv: Uint8Array<ArrayBufferLike>;
tag: Uint8Array<ArrayBufferLike>;
}>;
/**
* Decrypts some encrypted data. The data must have been encrypted using
* the given XChaCha20Poly1305 (draft-irtf-cfrg-xchacha-01) content encryption
* key (CEK).
*
* @param {object} options - The options to use.
* @param {Uint8Array} options.ciphertext - The data to decrypt.
* @param {Uint8Array} options.iv - The initialization vector (aka nonce).
* @param {Uint8Array} options.tag - The authentication tag.
* @param {Uint8Array} [options.additionalData] - Optional additional
* authentication data.
* @param {Uint8Array} options.cek - The content encryption key to use.
*
* @returns {Promise<Uint8Array>} The decrypted data.
*/
export declare function decrypt({ ciphertext, iv, tag, additionalData, cek, }: any): Promise<Uint8Array<ArrayBufferLike> | null>;
//# sourceMappingURL=xc20p.d.ts.map