pqbox 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +412 -2
- package/dist/generated/pqbox_wasm.d.ts +231 -0
- package/dist/generated/pqbox_wasm.js +977 -0
- package/dist/generated/wasm-bytes.d.ts +2 -0
- package/dist/generated/wasm-bytes.js +2 -0
- package/dist/index.d.ts +177 -0
- package/dist/index.js +235 -0
- package/package.json +44 -4
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* BLAKE3 (32 bytes).
|
|
6
|
+
*/
|
|
7
|
+
export function blake3(data: Uint8Array): Uint8Array;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* AEAD decryption.
|
|
11
|
+
*
|
|
12
|
+
* # Errors
|
|
13
|
+
* Parse errors or `Decrypt`.
|
|
14
|
+
*/
|
|
15
|
+
export function decrypt(key: Uint8Array, data: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* AEAD encryption with a random nonce.
|
|
19
|
+
*
|
|
20
|
+
* # Errors
|
|
21
|
+
* `InvalidParams` for an unknown algorithm, `InvalidLength` for a bad key.
|
|
22
|
+
*/
|
|
23
|
+
export function encrypt(key: Uint8Array, plaintext: Uint8Array, aad: Uint8Array, algorithm: string): Uint8Array;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A fresh random 32-byte AEAD key.
|
|
27
|
+
*/
|
|
28
|
+
export function generateKey(): Uint8Array;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Hashes with a named algorithm (`sha256`, `sha3-256`, `blake3`).
|
|
32
|
+
*
|
|
33
|
+
* # Errors
|
|
34
|
+
* `InvalidParams` for an unknown algorithm.
|
|
35
|
+
*/
|
|
36
|
+
export function hash(data: Uint8Array, algorithm: string): Uint8Array;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* HKDF-SHA-256.
|
|
40
|
+
*
|
|
41
|
+
* # Errors
|
|
42
|
+
* `InvalidParams` when `length` is not an integer in `0..=8160`.
|
|
43
|
+
*/
|
|
44
|
+
export function hkdfSha256(ikm: Uint8Array, salt: Uint8Array, info: Uint8Array, length: number): Uint8Array;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* HMAC-SHA-256.
|
|
48
|
+
*
|
|
49
|
+
* # Errors
|
|
50
|
+
* Never in practice.
|
|
51
|
+
*/
|
|
52
|
+
export function hmacSha256(key: Uint8Array, message: Uint8Array): Uint8Array;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Constant-time HMAC-SHA-256 tag check.
|
|
56
|
+
*/
|
|
57
|
+
export function hmacSha256Verify(key: Uint8Array, message: Uint8Array, tag: Uint8Array): boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Decapsulates a ciphertext into the 32-byte shared secret.
|
|
61
|
+
*
|
|
62
|
+
* # Errors
|
|
63
|
+
* Parse errors, `SuiteNotAllowed`, `SuiteMismatch` or `Decrypt`.
|
|
64
|
+
*/
|
|
65
|
+
export function kemDecapsulate(secret_key: Uint8Array, ciphertext: Uint8Array, allow_suites: string[]): Uint8Array;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Encapsulates to a public key: `{ ciphertext, sharedSecret }`.
|
|
69
|
+
*
|
|
70
|
+
* # Errors
|
|
71
|
+
* Parse errors of the public key, `SuiteNotAllowed`.
|
|
72
|
+
*/
|
|
73
|
+
export function kemEncapsulate(public_key: Uint8Array, allow_suites: string[]): object;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Generates a KEM key pair: `{ publicKey, secretKey }`.
|
|
77
|
+
*
|
|
78
|
+
* # Errors
|
|
79
|
+
* `InvalidParams` for an unknown suite.
|
|
80
|
+
*/
|
|
81
|
+
export function kemKeygen(suite_name: string): object;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Opens a sealed box.
|
|
85
|
+
*
|
|
86
|
+
* # Errors
|
|
87
|
+
* Parse errors, `SuiteNotAllowed`, `SuiteMismatch` or `Decrypt`.
|
|
88
|
+
*/
|
|
89
|
+
export function open(secret_key: Uint8Array, sealed: Uint8Array, allow_suites: string[]): Uint8Array;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Derives a key from a password and a stored salt with Argon2id (version 0x13, no secret, no
|
|
93
|
+
* associated data).
|
|
94
|
+
*
|
|
95
|
+
* # Errors
|
|
96
|
+
* `InvalidParams` for a salt shorter than 16 bytes, a length outside `16..=64`, or costs that
|
|
97
|
+
* are out of range or above the given limits (checked before any memory is allocated).
|
|
98
|
+
*/
|
|
99
|
+
export function passwordDeriveKey(password: Uint8Array, salt: Uint8Array, length: number, m_cost: number, t_cost: number, p_cost: number, max_m_cost: number, max_t_cost: number, max_p_cost: number): Uint8Array;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A fresh random 16-byte salt for [`password_derive_key`].
|
|
103
|
+
*/
|
|
104
|
+
export function passwordGenerateSalt(): Uint8Array;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Argon2id password hash as a PHC string.
|
|
108
|
+
*
|
|
109
|
+
* # Errors
|
|
110
|
+
* `InvalidParams` for out-of-range costs (including costs above the default limits: 256 MiB,
|
|
111
|
+
* 10 passes, 8 lanes).
|
|
112
|
+
*/
|
|
113
|
+
export function passwordHash(password: Uint8Array, m_cost: number, t_cost: number, p_cost: number): string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Checks a password: `false` on mismatch, an error for an invalid hash string or one whose costs
|
|
117
|
+
* exceed the given limits (checked before any memory is allocated).
|
|
118
|
+
*
|
|
119
|
+
* # Errors
|
|
120
|
+
* `InvalidPasswordHash`, or `InvalidParams` for limits that are not integers in `0..=2^32-1`.
|
|
121
|
+
*/
|
|
122
|
+
export function passwordVerify(password: Uint8Array, phc: string, max_m_cost: number, max_t_cost: number, max_p_cost: number): boolean;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Seals a message to a KEM public key.
|
|
126
|
+
*
|
|
127
|
+
* # Errors
|
|
128
|
+
* Parse errors of the public key, `SuiteNotAllowed`.
|
|
129
|
+
*/
|
|
130
|
+
export function seal(public_key: Uint8Array, plaintext: Uint8Array, allow_suites: string[]): Uint8Array;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* SHA-256.
|
|
134
|
+
*/
|
|
135
|
+
export function sha256(data: Uint8Array): Uint8Array;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* SHA3-256.
|
|
139
|
+
*/
|
|
140
|
+
export function sha3_256(data: Uint8Array): Uint8Array;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Signs a message.
|
|
144
|
+
*
|
|
145
|
+
* # Errors
|
|
146
|
+
* Parse errors of the secret key, `SuiteNotAllowed`.
|
|
147
|
+
*/
|
|
148
|
+
export function sign(secret_key: Uint8Array, message: Uint8Array, allow_suites: string[]): Uint8Array;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Generates a signing key pair: `{ publicKey, secretKey }`.
|
|
152
|
+
*
|
|
153
|
+
* # Errors
|
|
154
|
+
* `InvalidParams` for an unknown suite.
|
|
155
|
+
*/
|
|
156
|
+
export function signKeygen(suite_name: string): object;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The suites compiled into this build, by name.
|
|
160
|
+
*/
|
|
161
|
+
export function suites(): string[];
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Verifies a signature: `false` when it does not verify, an error for malformed input.
|
|
165
|
+
*
|
|
166
|
+
* # Errors
|
|
167
|
+
* Parse errors, `SuiteNotAllowed` and `SuiteMismatch`.
|
|
168
|
+
*/
|
|
169
|
+
export function verify(public_key: Uint8Array, message: Uint8Array, signature: Uint8Array, allow_suites: string[]): boolean;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The package version.
|
|
173
|
+
*/
|
|
174
|
+
export function version(): string;
|
|
175
|
+
|
|
176
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
177
|
+
|
|
178
|
+
export interface InitOutput {
|
|
179
|
+
readonly memory: WebAssembly.Memory;
|
|
180
|
+
readonly blake3: (a: number, b: number, c: number) => void;
|
|
181
|
+
readonly decrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
182
|
+
readonly encrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
183
|
+
readonly generateKey: () => number;
|
|
184
|
+
readonly hash: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
185
|
+
readonly hkdfSha256: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
186
|
+
readonly hmacSha256: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
187
|
+
readonly hmacSha256Verify: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
188
|
+
readonly kemDecapsulate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
189
|
+
readonly kemEncapsulate: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
190
|
+
readonly kemKeygen: (a: number, b: number, c: number) => void;
|
|
191
|
+
readonly open: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
192
|
+
readonly passwordDeriveKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
193
|
+
readonly passwordGenerateSalt: (a: number) => void;
|
|
194
|
+
readonly passwordHash: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
195
|
+
readonly passwordVerify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
196
|
+
readonly seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
197
|
+
readonly sha256: (a: number, b: number, c: number) => void;
|
|
198
|
+
readonly sha3_256: (a: number, b: number, c: number) => void;
|
|
199
|
+
readonly sign: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
200
|
+
readonly signKeygen: (a: number, b: number, c: number) => void;
|
|
201
|
+
readonly suites: (a: number) => void;
|
|
202
|
+
readonly verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
203
|
+
readonly version: (a: number) => void;
|
|
204
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
205
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
206
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
207
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
208
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
215
|
+
* a precompiled `WebAssembly.Module`.
|
|
216
|
+
*
|
|
217
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
218
|
+
*
|
|
219
|
+
* @returns {InitOutput}
|
|
220
|
+
*/
|
|
221
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
225
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
226
|
+
*
|
|
227
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
228
|
+
*
|
|
229
|
+
* @returns {Promise<InitOutput>}
|
|
230
|
+
*/
|
|
231
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|