hpke 0.1.1 → 0.2.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/README.md +5 -2
- package/hpke_dispatch.d.ts +39 -20
- package/hpke_dispatch_bg.js +148 -54
- package/hpke_dispatch_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,10 +15,13 @@ single-shot message encryption/decryption, as defined in [RFC9180§6][section-6]
|
|
|
15
15
|
|
|
16
16
|
## Web-assembly ready
|
|
17
17
|
|
|
18
|
-
This crate
|
|
19
|
-
package, and can also be custom
|
|
18
|
+
This crate is also published to npm as [`hpke`][npm] as a
|
|
19
|
+
typescript/javascript package, and can also be custom built for
|
|
20
|
+
specific wasm use cases (omitting unused algorithms) with
|
|
20
21
|
[`wasm-pack`](https://github.com/rustwasm/wasm-pack)
|
|
21
22
|
|
|
23
|
+
[npm]: https://www.npmjs.com/package/hpke
|
|
24
|
+
|
|
22
25
|
## Nightly-only feature to work around a wasm-bindgen bug: `cfg_eval`
|
|
23
26
|
|
|
24
27
|
In order to opt out of `algo-all` for a wasm build, you must use
|
package/hpke_dispatch.d.ts
CHANGED
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
*
|
|
20
20
|
*
|
|
21
21
|
* @param {Config} config
|
|
22
|
-
* @param {Uint8Array}
|
|
22
|
+
* @param {Uint8Array} recipient_public_key
|
|
23
23
|
* @param {Uint8Array} info
|
|
24
24
|
* @param {Uint8Array} plaintext
|
|
25
25
|
* @param {Uint8Array} aad
|
|
26
26
|
* @returns {EncappedKeyAndCiphertext}
|
|
27
27
|
*/
|
|
28
|
-
export function base_mode_seal(config: Config,
|
|
28
|
+
export function base_mode_seal(config: Config, recipient_public_key: Uint8Array, info: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): EncappedKeyAndCiphertext;
|
|
29
29
|
/**
|
|
30
30
|
*
|
|
31
31
|
*`base_mode_open` provides an interface to [`hpke::single_shot_open`]
|
|
@@ -46,12 +46,12 @@ export function base_mode_seal(config: Config, pk_recip: Uint8Array, info: Uint8
|
|
|
46
46
|
* @param {Config} config
|
|
47
47
|
* @param {Uint8Array} private_key
|
|
48
48
|
* @param {Uint8Array} encapped_key
|
|
49
|
-
* @param {Uint8Array} ciphertext
|
|
50
49
|
* @param {Uint8Array} info
|
|
50
|
+
* @param {Uint8Array} ciphertext
|
|
51
51
|
* @param {Uint8Array} aad
|
|
52
52
|
* @returns {Uint8Array}
|
|
53
53
|
*/
|
|
54
|
-
export function base_mode_open(config: Config, private_key: Uint8Array, encapped_key: Uint8Array,
|
|
54
|
+
export function base_mode_open(config: Config, private_key: Uint8Array, encapped_key: Uint8Array, info: Uint8Array, ciphertext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
55
55
|
/**
|
|
56
56
|
*
|
|
57
57
|
*Aead represents an authenticated encryption with additional data
|
|
@@ -93,8 +93,10 @@ export enum Kdf {
|
|
|
93
93
|
/**
|
|
94
94
|
*
|
|
95
95
|
*Kem represents an asymmetric key encapsulation mechanism, as per
|
|
96
|
-
*[RFC9180§7.1]
|
|
97
|
-
*
|
|
96
|
+
*[RFC9180§7.1][section-7.1]. Currently only two of options listed in
|
|
97
|
+
*the hpke draft are available.
|
|
98
|
+
*
|
|
99
|
+
*[section-7.1]: https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1
|
|
98
100
|
*/
|
|
99
101
|
export enum Kem {
|
|
100
102
|
/**
|
|
@@ -132,13 +134,13 @@ export class Config {
|
|
|
132
134
|
* * there is an error in encryption
|
|
133
135
|
*
|
|
134
136
|
*
|
|
135
|
-
* @param {Uint8Array}
|
|
137
|
+
* @param {Uint8Array} recipient_public_key
|
|
136
138
|
* @param {Uint8Array} info
|
|
137
139
|
* @param {Uint8Array} plaintext
|
|
138
140
|
* @param {Uint8Array} aad
|
|
139
141
|
* @returns {EncappedKeyAndCiphertext}
|
|
140
142
|
*/
|
|
141
|
-
base_mode_seal(
|
|
143
|
+
base_mode_seal(recipient_public_key: Uint8Array, info: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): EncappedKeyAndCiphertext;
|
|
142
144
|
/**
|
|
143
145
|
*
|
|
144
146
|
* base_mode_open provides an interface to [`hpke::single_shot_open`]
|
|
@@ -158,13 +160,13 @@ export class Config {
|
|
|
158
160
|
*
|
|
159
161
|
*
|
|
160
162
|
* @param {Uint8Array} private_key
|
|
161
|
-
* @param {Uint8Array} ciphertext
|
|
162
163
|
* @param {Uint8Array} encapped_key
|
|
163
164
|
* @param {Uint8Array} info
|
|
165
|
+
* @param {Uint8Array} ciphertext
|
|
164
166
|
* @param {Uint8Array} aad
|
|
165
167
|
* @returns {Uint8Array}
|
|
166
168
|
*/
|
|
167
|
-
base_mode_open(private_key: Uint8Array,
|
|
169
|
+
base_mode_open(private_key: Uint8Array, encapped_key: Uint8Array, info: Uint8Array, ciphertext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
168
170
|
/**
|
|
169
171
|
* Attempt to convert three u16 ids into a valid config. The id mappings are defined in the draft.
|
|
170
172
|
* @param {number} aead_id
|
|
@@ -187,23 +189,20 @@ export class Config {
|
|
|
187
189
|
kem: number;
|
|
188
190
|
}
|
|
189
191
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
192
|
+
*
|
|
193
|
+
*a simple struct to return the combined encapsulated key
|
|
194
|
+
*and ciphertext from seal
|
|
194
195
|
*/
|
|
195
196
|
export class EncappedKeyAndCiphertext {
|
|
196
197
|
free(): void;
|
|
197
198
|
/**
|
|
198
|
-
*
|
|
199
|
-
* @returns {Uint8Array}
|
|
199
|
+
* the ciphertext, encrypted with the key
|
|
200
200
|
*/
|
|
201
|
-
|
|
201
|
+
ciphertext: Uint8Array;
|
|
202
202
|
/**
|
|
203
|
-
*
|
|
204
|
-
* @returns {Uint8Array}
|
|
203
|
+
* the encapsulated encryption key
|
|
205
204
|
*/
|
|
206
|
-
|
|
205
|
+
encapped_key: Uint8Array;
|
|
207
206
|
}
|
|
208
207
|
/**
|
|
209
208
|
*r"
|
|
@@ -216,7 +215,27 @@ export class HpkeError {
|
|
|
216
215
|
/**
|
|
217
216
|
*
|
|
218
217
|
*A simple error type for failed id lookups
|
|
218
|
+
*
|
|
219
219
|
*/
|
|
220
220
|
export class IdLookupError {
|
|
221
221
|
free(): void;
|
|
222
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* An encoded keypair
|
|
225
|
+
*/
|
|
226
|
+
export class Keypair {
|
|
227
|
+
free(): void;
|
|
228
|
+
/**
|
|
229
|
+
* generate a keypair from a [`Kem`]
|
|
230
|
+
* @param {number} kem
|
|
231
|
+
*/
|
|
232
|
+
constructor(kem: number);
|
|
233
|
+
/**
|
|
234
|
+
* the private key for this keypair,
|
|
235
|
+
*/
|
|
236
|
+
private_key: Uint8Array;
|
|
237
|
+
/**
|
|
238
|
+
* the public key for this keypair
|
|
239
|
+
*/
|
|
240
|
+
public_key: Uint8Array;
|
|
241
|
+
}
|
package/hpke_dispatch_bg.js
CHANGED
|
@@ -47,15 +47,6 @@ function getStringFromWasm0(ptr, len) {
|
|
|
47
47
|
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
let WASM_VECTOR_LEN = 0;
|
|
51
|
-
|
|
52
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
53
|
-
const ptr = malloc(arg.length * 1);
|
|
54
|
-
getUint8Memory0().set(arg, ptr / 1);
|
|
55
|
-
WASM_VECTOR_LEN = arg.length;
|
|
56
|
-
return ptr;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
50
|
let cachegetInt32Memory0 = null;
|
|
60
51
|
function getInt32Memory0() {
|
|
61
52
|
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
|
@@ -68,6 +59,15 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
68
59
|
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
69
60
|
}
|
|
70
61
|
|
|
62
|
+
let WASM_VECTOR_LEN = 0;
|
|
63
|
+
|
|
64
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
65
|
+
const ptr = malloc(arg.length * 1);
|
|
66
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
67
|
+
WASM_VECTOR_LEN = arg.length;
|
|
68
|
+
return ptr;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
71
|
function _assertClass(instance, klass) {
|
|
72
72
|
if (!(instance instanceof klass)) {
|
|
73
73
|
throw new Error(`expected instance of ${klass.name}`);
|
|
@@ -93,27 +93,25 @@ function _assertClass(instance, klass) {
|
|
|
93
93
|
*
|
|
94
94
|
*
|
|
95
95
|
* @param {Config} config
|
|
96
|
-
* @param {Uint8Array}
|
|
96
|
+
* @param {Uint8Array} recipient_public_key
|
|
97
97
|
* @param {Uint8Array} info
|
|
98
98
|
* @param {Uint8Array} plaintext
|
|
99
99
|
* @param {Uint8Array} aad
|
|
100
100
|
* @returns {EncappedKeyAndCiphertext}
|
|
101
101
|
*/
|
|
102
|
-
export function base_mode_seal(config,
|
|
102
|
+
export function base_mode_seal(config, recipient_public_key, info, plaintext, aad) {
|
|
103
103
|
try {
|
|
104
104
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
105
105
|
_assertClass(config, Config);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const ptr1 = passArray8ToWasm0(
|
|
106
|
+
const ptr0 = passArray8ToWasm0(recipient_public_key, wasm.__wbindgen_malloc);
|
|
107
|
+
const len0 = WASM_VECTOR_LEN;
|
|
108
|
+
const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
109
109
|
const len1 = WASM_VECTOR_LEN;
|
|
110
|
-
const ptr2 = passArray8ToWasm0(
|
|
110
|
+
const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
111
111
|
const len2 = WASM_VECTOR_LEN;
|
|
112
|
-
const ptr3 = passArray8ToWasm0(
|
|
112
|
+
const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
113
113
|
const len3 = WASM_VECTOR_LEN;
|
|
114
|
-
|
|
115
|
-
const len4 = WASM_VECTOR_LEN;
|
|
116
|
-
wasm.base_mode_seal(retptr, ptr0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
114
|
+
wasm.base_mode_seal(retptr, config.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
117
115
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
118
116
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
119
117
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -146,28 +144,26 @@ export function base_mode_seal(config, pk_recip, info, plaintext, aad) {
|
|
|
146
144
|
* @param {Config} config
|
|
147
145
|
* @param {Uint8Array} private_key
|
|
148
146
|
* @param {Uint8Array} encapped_key
|
|
149
|
-
* @param {Uint8Array} ciphertext
|
|
150
147
|
* @param {Uint8Array} info
|
|
148
|
+
* @param {Uint8Array} ciphertext
|
|
151
149
|
* @param {Uint8Array} aad
|
|
152
150
|
* @returns {Uint8Array}
|
|
153
151
|
*/
|
|
154
|
-
export function base_mode_open(config, private_key, encapped_key,
|
|
152
|
+
export function base_mode_open(config, private_key, encapped_key, info, ciphertext, aad) {
|
|
155
153
|
try {
|
|
156
154
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
157
155
|
_assertClass(config, Config);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const ptr1 = passArray8ToWasm0(
|
|
156
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
157
|
+
const len0 = WASM_VECTOR_LEN;
|
|
158
|
+
const ptr1 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
|
|
161
159
|
const len1 = WASM_VECTOR_LEN;
|
|
162
|
-
const ptr2 = passArray8ToWasm0(
|
|
160
|
+
const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
163
161
|
const len2 = WASM_VECTOR_LEN;
|
|
164
162
|
const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
165
163
|
const len3 = WASM_VECTOR_LEN;
|
|
166
|
-
const ptr4 = passArray8ToWasm0(
|
|
164
|
+
const ptr4 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
167
165
|
const len4 = WASM_VECTOR_LEN;
|
|
168
|
-
|
|
169
|
-
const len5 = WASM_VECTOR_LEN;
|
|
170
|
-
wasm.base_mode_open(retptr, ptr0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
|
|
166
|
+
wasm.base_mode_open(retptr, config.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
171
167
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
172
168
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
173
169
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -175,9 +171,9 @@ export function base_mode_open(config, private_key, encapped_key, ciphertext, in
|
|
|
175
171
|
if (r3) {
|
|
176
172
|
throw takeObject(r2);
|
|
177
173
|
}
|
|
178
|
-
var
|
|
174
|
+
var v5 = getArrayU8FromWasm0(r0, r1).slice();
|
|
179
175
|
wasm.__wbindgen_free(r0, r1 * 1);
|
|
180
|
-
return
|
|
176
|
+
return v5;
|
|
181
177
|
} finally {
|
|
182
178
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
183
179
|
}
|
|
@@ -229,8 +225,10 @@ Sha512:3,"3":"Sha512", });
|
|
|
229
225
|
/**
|
|
230
226
|
*
|
|
231
227
|
*Kem represents an asymmetric key encapsulation mechanism, as per
|
|
232
|
-
*[RFC9180§7.1]
|
|
233
|
-
*
|
|
228
|
+
*[RFC9180§7.1][section-7.1]. Currently only two of options listed in
|
|
229
|
+
*the hpke draft are available.
|
|
230
|
+
*
|
|
231
|
+
*[section-7.1]: https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1
|
|
234
232
|
*/
|
|
235
233
|
export const Kem = Object.freeze({
|
|
236
234
|
/**
|
|
@@ -327,17 +325,16 @@ export class Config {
|
|
|
327
325
|
* * there is an error in encryption
|
|
328
326
|
*
|
|
329
327
|
*
|
|
330
|
-
* @param {Uint8Array}
|
|
328
|
+
* @param {Uint8Array} recipient_public_key
|
|
331
329
|
* @param {Uint8Array} info
|
|
332
330
|
* @param {Uint8Array} plaintext
|
|
333
331
|
* @param {Uint8Array} aad
|
|
334
332
|
* @returns {EncappedKeyAndCiphertext}
|
|
335
333
|
*/
|
|
336
|
-
base_mode_seal(
|
|
334
|
+
base_mode_seal(recipient_public_key, info, plaintext, aad) {
|
|
337
335
|
try {
|
|
338
|
-
const ptr = this.__destroy_into_raw();
|
|
339
336
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
340
|
-
const ptr0 = passArray8ToWasm0(
|
|
337
|
+
const ptr0 = passArray8ToWasm0(recipient_public_key, wasm.__wbindgen_malloc);
|
|
341
338
|
const len0 = WASM_VECTOR_LEN;
|
|
342
339
|
const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
343
340
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -345,7 +342,7 @@ export class Config {
|
|
|
345
342
|
const len2 = WASM_VECTOR_LEN;
|
|
346
343
|
const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
347
344
|
const len3 = WASM_VECTOR_LEN;
|
|
348
|
-
wasm.
|
|
345
|
+
wasm.config_base_mode_seal(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
349
346
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
350
347
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
351
348
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -376,27 +373,26 @@ export class Config {
|
|
|
376
373
|
*
|
|
377
374
|
*
|
|
378
375
|
* @param {Uint8Array} private_key
|
|
379
|
-
* @param {Uint8Array} ciphertext
|
|
380
376
|
* @param {Uint8Array} encapped_key
|
|
381
377
|
* @param {Uint8Array} info
|
|
378
|
+
* @param {Uint8Array} ciphertext
|
|
382
379
|
* @param {Uint8Array} aad
|
|
383
380
|
* @returns {Uint8Array}
|
|
384
381
|
*/
|
|
385
|
-
base_mode_open(private_key,
|
|
382
|
+
base_mode_open(private_key, encapped_key, info, ciphertext, aad) {
|
|
386
383
|
try {
|
|
387
|
-
const ptr = this.__destroy_into_raw();
|
|
388
384
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
389
385
|
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
390
386
|
const len0 = WASM_VECTOR_LEN;
|
|
391
|
-
const ptr1 = passArray8ToWasm0(
|
|
387
|
+
const ptr1 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
|
|
392
388
|
const len1 = WASM_VECTOR_LEN;
|
|
393
|
-
const ptr2 = passArray8ToWasm0(
|
|
389
|
+
const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
394
390
|
const len2 = WASM_VECTOR_LEN;
|
|
395
|
-
const ptr3 = passArray8ToWasm0(
|
|
391
|
+
const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
396
392
|
const len3 = WASM_VECTOR_LEN;
|
|
397
393
|
const ptr4 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
398
394
|
const len4 = WASM_VECTOR_LEN;
|
|
399
|
-
wasm.
|
|
395
|
+
wasm.config_base_mode_open(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
400
396
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
401
397
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
402
398
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -435,10 +431,9 @@ export class Config {
|
|
|
435
431
|
}
|
|
436
432
|
}
|
|
437
433
|
/**
|
|
438
|
-
*r"
|
|
439
|
-
* a simple struct to return the combined encapsulated key
|
|
440
|
-
* and ciphertext from seal
|
|
441
434
|
*
|
|
435
|
+
*a simple struct to return the combined encapsulated key
|
|
436
|
+
*and ciphertext from seal
|
|
442
437
|
*/
|
|
443
438
|
export class EncappedKeyAndCiphertext {
|
|
444
439
|
|
|
@@ -461,13 +456,12 @@ export class EncappedKeyAndCiphertext {
|
|
|
461
456
|
wasm.__wbg_encappedkeyandciphertext_free(ptr);
|
|
462
457
|
}
|
|
463
458
|
/**
|
|
464
|
-
*
|
|
465
|
-
* @returns {Uint8Array}
|
|
459
|
+
* the encapsulated encryption key
|
|
466
460
|
*/
|
|
467
461
|
get encapped_key() {
|
|
468
462
|
try {
|
|
469
463
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
470
|
-
wasm.
|
|
464
|
+
wasm.__wbg_get_encappedkeyandciphertext_encapped_key(retptr, this.ptr);
|
|
471
465
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
472
466
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
473
467
|
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
@@ -478,13 +472,21 @@ export class EncappedKeyAndCiphertext {
|
|
|
478
472
|
}
|
|
479
473
|
}
|
|
480
474
|
/**
|
|
481
|
-
*
|
|
482
|
-
* @
|
|
475
|
+
* the encapsulated encryption key
|
|
476
|
+
* @param {Uint8Array} arg0
|
|
477
|
+
*/
|
|
478
|
+
set encapped_key(arg0) {
|
|
479
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
480
|
+
const len0 = WASM_VECTOR_LEN;
|
|
481
|
+
wasm.__wbg_set_encappedkeyandciphertext_encapped_key(this.ptr, ptr0, len0);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* the ciphertext, encrypted with the key
|
|
483
485
|
*/
|
|
484
486
|
get ciphertext() {
|
|
485
487
|
try {
|
|
486
488
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
487
|
-
wasm.
|
|
489
|
+
wasm.__wbg_get_encappedkeyandciphertext_ciphertext(retptr, this.ptr);
|
|
488
490
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
489
491
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
490
492
|
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
@@ -494,6 +496,15 @@ export class EncappedKeyAndCiphertext {
|
|
|
494
496
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
495
497
|
}
|
|
496
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* the ciphertext, encrypted with the key
|
|
501
|
+
* @param {Uint8Array} arg0
|
|
502
|
+
*/
|
|
503
|
+
set ciphertext(arg0) {
|
|
504
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
505
|
+
const len0 = WASM_VECTOR_LEN;
|
|
506
|
+
wasm.__wbg_set_encappedkeyandciphertext_ciphertext(this.ptr, ptr0, len0);
|
|
507
|
+
}
|
|
497
508
|
}
|
|
498
509
|
/**
|
|
499
510
|
*r"
|
|
@@ -524,6 +535,7 @@ export class HpkeError {
|
|
|
524
535
|
/**
|
|
525
536
|
*
|
|
526
537
|
*A simple error type for failed id lookups
|
|
538
|
+
*
|
|
527
539
|
*/
|
|
528
540
|
export class IdLookupError {
|
|
529
541
|
|
|
@@ -546,6 +558,88 @@ export class IdLookupError {
|
|
|
546
558
|
wasm.__wbg_idlookuperror_free(ptr);
|
|
547
559
|
}
|
|
548
560
|
}
|
|
561
|
+
/**
|
|
562
|
+
* An encoded keypair
|
|
563
|
+
*/
|
|
564
|
+
export class Keypair {
|
|
565
|
+
|
|
566
|
+
static __wrap(ptr) {
|
|
567
|
+
const obj = Object.create(Keypair.prototype);
|
|
568
|
+
obj.ptr = ptr;
|
|
569
|
+
|
|
570
|
+
return obj;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
__destroy_into_raw() {
|
|
574
|
+
const ptr = this.ptr;
|
|
575
|
+
this.ptr = 0;
|
|
576
|
+
|
|
577
|
+
return ptr;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
free() {
|
|
581
|
+
const ptr = this.__destroy_into_raw();
|
|
582
|
+
wasm.__wbg_keypair_free(ptr);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* the public key for this keypair
|
|
586
|
+
*/
|
|
587
|
+
get public_key() {
|
|
588
|
+
try {
|
|
589
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
590
|
+
wasm.__wbg_get_keypair_public_key(retptr, this.ptr);
|
|
591
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
592
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
593
|
+
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
594
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
595
|
+
return v0;
|
|
596
|
+
} finally {
|
|
597
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* the public key for this keypair
|
|
602
|
+
* @param {Uint8Array} arg0
|
|
603
|
+
*/
|
|
604
|
+
set public_key(arg0) {
|
|
605
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
606
|
+
const len0 = WASM_VECTOR_LEN;
|
|
607
|
+
wasm.__wbg_set_keypair_public_key(this.ptr, ptr0, len0);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* the private key for this keypair,
|
|
611
|
+
*/
|
|
612
|
+
get private_key() {
|
|
613
|
+
try {
|
|
614
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
615
|
+
wasm.__wbg_get_keypair_private_key(retptr, this.ptr);
|
|
616
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
617
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
618
|
+
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
619
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
620
|
+
return v0;
|
|
621
|
+
} finally {
|
|
622
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* the private key for this keypair,
|
|
627
|
+
* @param {Uint8Array} arg0
|
|
628
|
+
*/
|
|
629
|
+
set private_key(arg0) {
|
|
630
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
631
|
+
const len0 = WASM_VECTOR_LEN;
|
|
632
|
+
wasm.__wbg_set_keypair_private_key(this.ptr, ptr0, len0);
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* generate a keypair from a [`Kem`]
|
|
636
|
+
* @param {number} kem
|
|
637
|
+
*/
|
|
638
|
+
constructor(kem) {
|
|
639
|
+
const ret = wasm.keypair_new(kem);
|
|
640
|
+
return Keypair.__wrap(ret);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
549
643
|
|
|
550
644
|
export function __wbg_idlookuperror_new(arg0) {
|
|
551
645
|
const ret = IdLookupError.__wrap(arg0);
|
package/hpke_dispatch_bg.wasm
CHANGED
|
Binary file
|