UNPKG

@hazae41/chacha20poly1305

Version:

ChaCha20Poly1305 adapter for WebAssembly and JS implementations

129 lines (126 loc) 4.78 kB
import * as ChaChaNoble from '@noble/ciphers/chacha'; import { Lengthed } from '@hazae41/lengthed'; import { Unowned, Owned } from '../../libs/ownable/index.js'; import { Abstract } from './abstract.js'; declare function fromNoble(noble: typeof ChaChaNoble): { Memory: { new <N extends number = number>(inner: Uint8Array): { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }; fromOrThrow<N extends number = number>(memory: Abstract.Memory<N>): Unowned<{ readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N_1>; [Symbol.dispose](): void; }> | Owned<{ readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N_1>; [Symbol.dispose](): void; }>; importOrThrow<N extends number = number>(bytes: Uint8Array & Lengthed<N>): { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N_1>; [Symbol.dispose](): void; }; }; ChaCha20Cipher: { new (key: Uint8Array, nonce: Uint8Array): { counter: number; readonly key: Uint8Array; readonly nonce: Uint8Array; applyOrThrow(message: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }): void; [Symbol.dispose](): void; }; importOrThrow(key: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }, nonce: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }): { counter: number; readonly key: Uint8Array; readonly nonce: Uint8Array; applyOrThrow(message: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }): void; [Symbol.dispose](): void; }; }; ChaCha20Poly1305Cipher: { new (key: Uint8Array): { readonly key: Uint8Array; encryptOrThrow(message: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }, nonce: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }): { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }; decryptOrThrow(message: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }, nonce: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }): { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }; [Symbol.dispose](): void; }; importOrThrow(key: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }): { readonly key: Uint8Array; encryptOrThrow(message: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }, nonce: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }): { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }; decryptOrThrow(message: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }, nonce: { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }): { readonly inner: Uint8Array; readonly bytes: Uint8Array & Lengthed<N>; [Symbol.dispose](): void; }; [Symbol.dispose](): void; }; }; }; export { fromNoble };