@hide-protocol/wasm 0.5.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 +17 -0
- package/README.md +101 -0
- package/hide_wasm.d.ts +190 -0
- package/hide_wasm.js +904 -0
- package/hide_wasm_bg.wasm +0 -0
- package/hide_wasm_bg.wasm.d.ts +35 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
|
|
17
|
+
The full license text is available at the URL above.
|
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @hide-protocol/wasm
|
|
2
|
+
|
|
3
|
+
HIDE in the browser, compiled to WebAssembly from the same Rust core the CLI
|
|
4
|
+
and desktop application use.
|
|
5
|
+
|
|
6
|
+
> **Experimental and unaudited.** Do not protect data you cannot afford to lose
|
|
7
|
+
> or expose. A successful decryption proves the data was not altered; it does
|
|
8
|
+
> **not** prove who sent it.
|
|
9
|
+
>
|
|
10
|
+
> A browser is also a weaker place to hold a key than a desktop: any script on
|
|
11
|
+
> the page shares the heap, so an XSS bug is equivalent to key theft. For keys
|
|
12
|
+
> that matter, prefer the CLI or the desktop application.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @hide-protocol/wasm
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Use
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import init, { SecretKey, encrypt, decrypt } from "@hide-protocol/wasm";
|
|
24
|
+
|
|
25
|
+
await init();
|
|
26
|
+
|
|
27
|
+
const secret = SecretKey.generate();
|
|
28
|
+
const publicKey = secret.publicKey();
|
|
29
|
+
|
|
30
|
+
const box = encrypt(new TextEncoder().encode("hello"), publicKey, "note.txt", null);
|
|
31
|
+
const opened = decrypt(box, secret);
|
|
32
|
+
console.log(new TextDecoder().decode(opened.data));
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`encrypt` takes recipients as concatenated public keys, so encrypting to
|
|
36
|
+
several people is one buffer:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
const recipients = new Uint8Array(alice.length + bob.length);
|
|
40
|
+
recipients.set(alice, 0);
|
|
41
|
+
recipients.set(bob, alice.length);
|
|
42
|
+
const box = encrypt(payload, recipients, null, null);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Storing a key
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
const sealed = secret.protect("a long passphrase"); // Argon2id + ChaCha20-Poly1305
|
|
49
|
+
const reopened = SecretKey.load(sealed, "a long passphrase");
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
A forgotten passphrase cannot be recovered: there is no escrow and no reset.
|
|
53
|
+
|
|
54
|
+
## Signing
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { SigningIdentity, verify } from "@hide-protocol/wasm";
|
|
58
|
+
|
|
59
|
+
const keyFile = SigningIdentity.generate("a long passphrase"); // store this
|
|
60
|
+
const identity = SigningIdentity.load(keyFile, "a long passphrase");
|
|
61
|
+
|
|
62
|
+
const context = new TextEncoder().encode("myapp/invoice");
|
|
63
|
+
const signature = identity.sign(context, payload);
|
|
64
|
+
verify(identity.publicKey(), context, payload, signature); // throws if it fails
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`context` separates uses of one identity, so a signature made for one purpose
|
|
68
|
+
cannot be replayed as another. Never let a remote party choose it. `verify`
|
|
69
|
+
returns nothing and throws on failure, so a forgotten check cannot read as a
|
|
70
|
+
pass.
|
|
71
|
+
|
|
72
|
+
A key file written before signatures existed carries no signing seed, and
|
|
73
|
+
`SigningIdentity.load` throws rather than silently downgrading it.
|
|
74
|
+
|
|
75
|
+
## Proving possession
|
|
76
|
+
|
|
77
|
+
A detached signature proves possession at some point, to nobody in particular,
|
|
78
|
+
and can be replayed. A challenge binds a nonce, an audience and an expiry:
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
import { newChallenge, SpentNonces } from "@hide-protocol/wasm";
|
|
82
|
+
|
|
83
|
+
const now = BigInt(Math.floor(Date.now() / 1000));
|
|
84
|
+
const challenge = newChallenge("app.example", now, 60n);
|
|
85
|
+
const answer = identity.answer(challenge);
|
|
86
|
+
|
|
87
|
+
const spent = new SpentNonces(); // must outlive a single request
|
|
88
|
+
spent.accept(challenge, answer, identity.publicKey(), now);
|
|
89
|
+
spent.accept(challenge, answer, identity.publicKey(), now); // throws "replayed"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Only the verifier can catch a replay: a replayed answer is a genuine signature
|
|
93
|
+
and nothing about it is invalid on its own.
|
|
94
|
+
|
|
95
|
+
## What it does not do
|
|
96
|
+
|
|
97
|
+
The container is verified as intact, but nothing binds it to a person. Any
|
|
98
|
+
filename it carries is attacker-controlled: never use it to build a path, and
|
|
99
|
+
escape it before putting it in the DOM.
|
|
100
|
+
|
|
101
|
+
Full protocol limits: [SECURITY.md](https://github.com/hide-protocol/hide/blob/main/SECURITY.md).
|
package/hide_wasm.d.ts
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A verified payload. Receiving this means it authenticated.
|
|
6
|
+
*/
|
|
7
|
+
export class Decrypted {
|
|
8
|
+
private constructor();
|
|
9
|
+
free(): void;
|
|
10
|
+
[Symbol.dispose](): void;
|
|
11
|
+
readonly data: Uint8Array;
|
|
12
|
+
readonly filename: string | undefined;
|
|
13
|
+
readonly mediaType: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A secret key. The bytes never cross into JavaScript.
|
|
18
|
+
*/
|
|
19
|
+
export class SecretKey {
|
|
20
|
+
private constructor();
|
|
21
|
+
free(): void;
|
|
22
|
+
[Symbol.dispose](): void;
|
|
23
|
+
/**
|
|
24
|
+
* Generates a key pair using the browser's CSPRNG.
|
|
25
|
+
*/
|
|
26
|
+
static generate(): SecretKey;
|
|
27
|
+
/**
|
|
28
|
+
* Loads a key file. Pass the passphrase for a protected key; a protected
|
|
29
|
+
* key without one fails rather than guessing.
|
|
30
|
+
*/
|
|
31
|
+
static load(data: Uint8Array, passphrase?: string | null): SecretKey;
|
|
32
|
+
/**
|
|
33
|
+
* Seals this key with a passphrase, for storage. A forgotten passphrase
|
|
34
|
+
* cannot be recovered.
|
|
35
|
+
*/
|
|
36
|
+
protect(passphrase: string): Uint8Array;
|
|
37
|
+
publicKey(): Uint8Array;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A signing key. The seed never crosses into JavaScript.
|
|
42
|
+
*/
|
|
43
|
+
export class SigningIdentity {
|
|
44
|
+
private constructor();
|
|
45
|
+
free(): void;
|
|
46
|
+
[Symbol.dispose](): void;
|
|
47
|
+
/**
|
|
48
|
+
* Answers a challenge, proving possession to whoever issued it.
|
|
49
|
+
*/
|
|
50
|
+
answer(challenge: Uint8Array): Uint8Array;
|
|
51
|
+
/**
|
|
52
|
+
* Creates an identity and returns the sealed key file to store. One seed
|
|
53
|
+
* backs both encryption and signing, so there is a single thing to back
|
|
54
|
+
* up. A forgotten passphrase cannot be recovered.
|
|
55
|
+
*/
|
|
56
|
+
static generate(passphrase: string): Uint8Array;
|
|
57
|
+
/**
|
|
58
|
+
* Opens a key file for signing. A file written before signatures existed
|
|
59
|
+
* carries no signing seed, and fails rather than being downgraded.
|
|
60
|
+
*/
|
|
61
|
+
static load(data: Uint8Array, passphrase?: string | null): SigningIdentity;
|
|
62
|
+
/**
|
|
63
|
+
* The shareable verifying key, for others to check signatures with.
|
|
64
|
+
*/
|
|
65
|
+
publicKey(): Uint8Array;
|
|
66
|
+
/**
|
|
67
|
+
* Signs `message` under `context`. The context separates uses of one
|
|
68
|
+
* identity; never let a remote party choose it.
|
|
69
|
+
*/
|
|
70
|
+
sign(context: Uint8Array, message: Uint8Array): Uint8Array;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The verifier's record of answered challenges.
|
|
75
|
+
*
|
|
76
|
+
* Replay can only be caught here: a replayed answer is a genuine signature
|
|
77
|
+
* and nothing about it is invalid on its own. This must therefore outlive a
|
|
78
|
+
* single request.
|
|
79
|
+
*/
|
|
80
|
+
export class SpentNonces {
|
|
81
|
+
free(): void;
|
|
82
|
+
[Symbol.dispose](): void;
|
|
83
|
+
/**
|
|
84
|
+
* Accepts an answer exactly once. Throws `"replayed"` the second time,
|
|
85
|
+
* `"expired"` after the window, and a verification failure otherwise.
|
|
86
|
+
*/
|
|
87
|
+
accept(challenge: Uint8Array, signature: Uint8Array, public_key: Uint8Array, now: bigint): void;
|
|
88
|
+
constructor();
|
|
89
|
+
readonly size: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function armorPublicKey(public_key: Uint8Array): string;
|
|
93
|
+
|
|
94
|
+
export function dearmorPublicKey(text: string): Uint8Array;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Decrypts and verifies. Nothing is returned unless the whole payload
|
|
98
|
+
* authenticates.
|
|
99
|
+
*
|
|
100
|
+
* The filename is attacker-controlled: never use it to build a path, and
|
|
101
|
+
* escape it before putting it in the DOM.
|
|
102
|
+
*/
|
|
103
|
+
export function decrypt(container: Uint8Array, secret: SecretKey): Decrypted;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Encrypts for 1..64 recipients, passed as their concatenated public keys.
|
|
107
|
+
*/
|
|
108
|
+
export function encrypt(plaintext: Uint8Array, recipients: Uint8Array, filename?: string | null, media_type?: string | null): Uint8Array;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Reports `"raw"` or `"protected"` without needing the passphrase.
|
|
112
|
+
*/
|
|
113
|
+
export function inspectKey(data: Uint8Array): string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Creates a challenge for a prover to answer.
|
|
117
|
+
*
|
|
118
|
+
* A detached signature proves possession at some point, to nobody in
|
|
119
|
+
* particular, and can be replayed. A challenge binds a random nonce, an
|
|
120
|
+
* audience and an expiry, so an answer is good once, here, now.
|
|
121
|
+
*/
|
|
122
|
+
export function newChallenge(audience: string, now: bigint, valid_for: bigint): Uint8Array;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Throws unless both halves verify. Returns nothing on success rather than a
|
|
126
|
+
* boolean, so a caller that forgets to check cannot read failure as a pass.
|
|
127
|
+
*/
|
|
128
|
+
export function verify(public_key: Uint8Array, context: Uint8Array, message: Uint8Array, signature: Uint8Array): void;
|
|
129
|
+
|
|
130
|
+
export function version(): string;
|
|
131
|
+
|
|
132
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
133
|
+
|
|
134
|
+
export interface InitOutput {
|
|
135
|
+
readonly memory: WebAssembly.Memory;
|
|
136
|
+
readonly __wbg_decrypted_free: (a: number, b: number) => void;
|
|
137
|
+
readonly __wbg_secretkey_free: (a: number, b: number) => void;
|
|
138
|
+
readonly __wbg_signingidentity_free: (a: number, b: number) => void;
|
|
139
|
+
readonly __wbg_spentnonces_free: (a: number, b: number) => void;
|
|
140
|
+
readonly armorPublicKey: (a: number, b: number, c: number) => void;
|
|
141
|
+
readonly dearmorPublicKey: (a: number, b: number, c: number) => void;
|
|
142
|
+
readonly decrypt: (a: number, b: number, c: number, d: number) => void;
|
|
143
|
+
readonly decrypted_data: (a: number, b: number) => void;
|
|
144
|
+
readonly decrypted_filename: (a: number, b: number) => void;
|
|
145
|
+
readonly decrypted_mediaType: (a: number, b: number) => void;
|
|
146
|
+
readonly encrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
147
|
+
readonly inspectKey: (a: number, b: number, c: number) => void;
|
|
148
|
+
readonly newChallenge: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
|
149
|
+
readonly secretkey_generate: (a: number) => void;
|
|
150
|
+
readonly secretkey_load: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
151
|
+
readonly secretkey_protect: (a: number, b: number, c: number, d: number) => void;
|
|
152
|
+
readonly secretkey_publicKey: (a: number, b: number) => void;
|
|
153
|
+
readonly signingidentity_answer: (a: number, b: number, c: number, d: number) => void;
|
|
154
|
+
readonly signingidentity_generate: (a: number, b: number, c: number) => void;
|
|
155
|
+
readonly signingidentity_load: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
156
|
+
readonly signingidentity_publicKey: (a: number, b: number) => void;
|
|
157
|
+
readonly signingidentity_sign: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
158
|
+
readonly spentnonces_accept: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: bigint) => void;
|
|
159
|
+
readonly spentnonces_new: () => number;
|
|
160
|
+
readonly spentnonces_size: (a: number) => number;
|
|
161
|
+
readonly verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
162
|
+
readonly version: (a: number) => void;
|
|
163
|
+
readonly __wbindgen_export: (a: number) => void;
|
|
164
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
165
|
+
readonly __wbindgen_export2: (a: number, b: number) => number;
|
|
166
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
167
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number, d: number) => number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
174
|
+
* a precompiled `WebAssembly.Module`.
|
|
175
|
+
*
|
|
176
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
177
|
+
*
|
|
178
|
+
* @returns {InitOutput}
|
|
179
|
+
*/
|
|
180
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
184
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
185
|
+
*
|
|
186
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
187
|
+
*
|
|
188
|
+
* @returns {Promise<InitOutput>}
|
|
189
|
+
*/
|
|
190
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/hide_wasm.js
ADDED
|
@@ -0,0 +1,904 @@
|
|
|
1
|
+
/* @ts-self-types="./hide_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A verified payload. Receiving this means it authenticated.
|
|
5
|
+
*/
|
|
6
|
+
export class Decrypted {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
const obj = Object.create(Decrypted.prototype);
|
|
9
|
+
obj.__wbg_ptr = ptr;
|
|
10
|
+
DecryptedFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
__destroy_into_raw() {
|
|
14
|
+
const ptr = this.__wbg_ptr;
|
|
15
|
+
this.__wbg_ptr = 0;
|
|
16
|
+
DecryptedFinalization.unregister(this);
|
|
17
|
+
return ptr;
|
|
18
|
+
}
|
|
19
|
+
free() {
|
|
20
|
+
const ptr = this.__destroy_into_raw();
|
|
21
|
+
wasm.__wbg_decrypted_free(ptr, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @returns {Uint8Array}
|
|
25
|
+
*/
|
|
26
|
+
get data() {
|
|
27
|
+
try {
|
|
28
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
29
|
+
wasm.decrypted_data(retptr, this.__wbg_ptr);
|
|
30
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
31
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
32
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
33
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
34
|
+
return v1;
|
|
35
|
+
} finally {
|
|
36
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @returns {string | undefined}
|
|
41
|
+
*/
|
|
42
|
+
get filename() {
|
|
43
|
+
try {
|
|
44
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
45
|
+
wasm.decrypted_filename(retptr, this.__wbg_ptr);
|
|
46
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
47
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
48
|
+
let v1;
|
|
49
|
+
if (r0 !== 0) {
|
|
50
|
+
v1 = getStringFromWasm0(r0, r1);
|
|
51
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
52
|
+
}
|
|
53
|
+
return v1;
|
|
54
|
+
} finally {
|
|
55
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @returns {string | undefined}
|
|
60
|
+
*/
|
|
61
|
+
get mediaType() {
|
|
62
|
+
try {
|
|
63
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
64
|
+
wasm.decrypted_mediaType(retptr, this.__wbg_ptr);
|
|
65
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
66
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
67
|
+
let v1;
|
|
68
|
+
if (r0 !== 0) {
|
|
69
|
+
v1 = getStringFromWasm0(r0, r1);
|
|
70
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
71
|
+
}
|
|
72
|
+
return v1;
|
|
73
|
+
} finally {
|
|
74
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (Symbol.dispose) Decrypted.prototype[Symbol.dispose] = Decrypted.prototype.free;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A secret key. The bytes never cross into JavaScript.
|
|
82
|
+
*/
|
|
83
|
+
export class SecretKey {
|
|
84
|
+
static __wrap(ptr) {
|
|
85
|
+
const obj = Object.create(SecretKey.prototype);
|
|
86
|
+
obj.__wbg_ptr = ptr;
|
|
87
|
+
SecretKeyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
88
|
+
return obj;
|
|
89
|
+
}
|
|
90
|
+
__destroy_into_raw() {
|
|
91
|
+
const ptr = this.__wbg_ptr;
|
|
92
|
+
this.__wbg_ptr = 0;
|
|
93
|
+
SecretKeyFinalization.unregister(this);
|
|
94
|
+
return ptr;
|
|
95
|
+
}
|
|
96
|
+
free() {
|
|
97
|
+
const ptr = this.__destroy_into_raw();
|
|
98
|
+
wasm.__wbg_secretkey_free(ptr, 0);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Generates a key pair using the browser's CSPRNG.
|
|
102
|
+
* @returns {SecretKey}
|
|
103
|
+
*/
|
|
104
|
+
static generate() {
|
|
105
|
+
try {
|
|
106
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
107
|
+
wasm.secretkey_generate(retptr);
|
|
108
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
109
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
110
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
111
|
+
if (r2) {
|
|
112
|
+
throw takeObject(r1);
|
|
113
|
+
}
|
|
114
|
+
return SecretKey.__wrap(r0);
|
|
115
|
+
} finally {
|
|
116
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Loads a key file. Pass the passphrase for a protected key; a protected
|
|
121
|
+
* key without one fails rather than guessing.
|
|
122
|
+
* @param {Uint8Array} data
|
|
123
|
+
* @param {string | null} [passphrase]
|
|
124
|
+
* @returns {SecretKey}
|
|
125
|
+
*/
|
|
126
|
+
static load(data, passphrase) {
|
|
127
|
+
try {
|
|
128
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
129
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
|
|
130
|
+
const len0 = WASM_VECTOR_LEN;
|
|
131
|
+
var ptr1 = isLikeNone(passphrase) ? 0 : passStringToWasm0(passphrase, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
132
|
+
var len1 = WASM_VECTOR_LEN;
|
|
133
|
+
wasm.secretkey_load(retptr, ptr0, len0, ptr1, len1);
|
|
134
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
135
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
136
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
137
|
+
if (r2) {
|
|
138
|
+
throw takeObject(r1);
|
|
139
|
+
}
|
|
140
|
+
return SecretKey.__wrap(r0);
|
|
141
|
+
} finally {
|
|
142
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Seals this key with a passphrase, for storage. A forgotten passphrase
|
|
147
|
+
* cannot be recovered.
|
|
148
|
+
* @param {string} passphrase
|
|
149
|
+
* @returns {Uint8Array}
|
|
150
|
+
*/
|
|
151
|
+
protect(passphrase) {
|
|
152
|
+
try {
|
|
153
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
154
|
+
const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
155
|
+
const len0 = WASM_VECTOR_LEN;
|
|
156
|
+
wasm.secretkey_protect(retptr, this.__wbg_ptr, ptr0, len0);
|
|
157
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
158
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
159
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
160
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
161
|
+
if (r3) {
|
|
162
|
+
throw takeObject(r2);
|
|
163
|
+
}
|
|
164
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
165
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
166
|
+
return v2;
|
|
167
|
+
} finally {
|
|
168
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @returns {Uint8Array}
|
|
173
|
+
*/
|
|
174
|
+
publicKey() {
|
|
175
|
+
try {
|
|
176
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
177
|
+
wasm.secretkey_publicKey(retptr, this.__wbg_ptr);
|
|
178
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
179
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
180
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
181
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
182
|
+
if (r3) {
|
|
183
|
+
throw takeObject(r2);
|
|
184
|
+
}
|
|
185
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
186
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
187
|
+
return v1;
|
|
188
|
+
} finally {
|
|
189
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (Symbol.dispose) SecretKey.prototype[Symbol.dispose] = SecretKey.prototype.free;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* A signing key. The seed never crosses into JavaScript.
|
|
197
|
+
*/
|
|
198
|
+
export class SigningIdentity {
|
|
199
|
+
static __wrap(ptr) {
|
|
200
|
+
const obj = Object.create(SigningIdentity.prototype);
|
|
201
|
+
obj.__wbg_ptr = ptr;
|
|
202
|
+
SigningIdentityFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
203
|
+
return obj;
|
|
204
|
+
}
|
|
205
|
+
__destroy_into_raw() {
|
|
206
|
+
const ptr = this.__wbg_ptr;
|
|
207
|
+
this.__wbg_ptr = 0;
|
|
208
|
+
SigningIdentityFinalization.unregister(this);
|
|
209
|
+
return ptr;
|
|
210
|
+
}
|
|
211
|
+
free() {
|
|
212
|
+
const ptr = this.__destroy_into_raw();
|
|
213
|
+
wasm.__wbg_signingidentity_free(ptr, 0);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Answers a challenge, proving possession to whoever issued it.
|
|
217
|
+
* @param {Uint8Array} challenge
|
|
218
|
+
* @returns {Uint8Array}
|
|
219
|
+
*/
|
|
220
|
+
answer(challenge) {
|
|
221
|
+
try {
|
|
222
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
223
|
+
const ptr0 = passArray8ToWasm0(challenge, wasm.__wbindgen_export2);
|
|
224
|
+
const len0 = WASM_VECTOR_LEN;
|
|
225
|
+
wasm.signingidentity_answer(retptr, this.__wbg_ptr, ptr0, len0);
|
|
226
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
227
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
228
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
229
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
230
|
+
if (r3) {
|
|
231
|
+
throw takeObject(r2);
|
|
232
|
+
}
|
|
233
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
234
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
235
|
+
return v2;
|
|
236
|
+
} finally {
|
|
237
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Creates an identity and returns the sealed key file to store. One seed
|
|
242
|
+
* backs both encryption and signing, so there is a single thing to back
|
|
243
|
+
* up. A forgotten passphrase cannot be recovered.
|
|
244
|
+
* @param {string} passphrase
|
|
245
|
+
* @returns {Uint8Array}
|
|
246
|
+
*/
|
|
247
|
+
static generate(passphrase) {
|
|
248
|
+
try {
|
|
249
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
250
|
+
const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
251
|
+
const len0 = WASM_VECTOR_LEN;
|
|
252
|
+
wasm.signingidentity_generate(retptr, ptr0, len0);
|
|
253
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
254
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
255
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
256
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
257
|
+
if (r3) {
|
|
258
|
+
throw takeObject(r2);
|
|
259
|
+
}
|
|
260
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
261
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
262
|
+
return v2;
|
|
263
|
+
} finally {
|
|
264
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Opens a key file for signing. A file written before signatures existed
|
|
269
|
+
* carries no signing seed, and fails rather than being downgraded.
|
|
270
|
+
* @param {Uint8Array} data
|
|
271
|
+
* @param {string | null} [passphrase]
|
|
272
|
+
* @returns {SigningIdentity}
|
|
273
|
+
*/
|
|
274
|
+
static load(data, passphrase) {
|
|
275
|
+
try {
|
|
276
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
277
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
|
|
278
|
+
const len0 = WASM_VECTOR_LEN;
|
|
279
|
+
var ptr1 = isLikeNone(passphrase) ? 0 : passStringToWasm0(passphrase, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
280
|
+
var len1 = WASM_VECTOR_LEN;
|
|
281
|
+
wasm.signingidentity_load(retptr, ptr0, len0, ptr1, len1);
|
|
282
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
283
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
284
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
285
|
+
if (r2) {
|
|
286
|
+
throw takeObject(r1);
|
|
287
|
+
}
|
|
288
|
+
return SigningIdentity.__wrap(r0);
|
|
289
|
+
} finally {
|
|
290
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* The shareable verifying key, for others to check signatures with.
|
|
295
|
+
* @returns {Uint8Array}
|
|
296
|
+
*/
|
|
297
|
+
publicKey() {
|
|
298
|
+
try {
|
|
299
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
300
|
+
wasm.signingidentity_publicKey(retptr, this.__wbg_ptr);
|
|
301
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
302
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
303
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
304
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
305
|
+
return v1;
|
|
306
|
+
} finally {
|
|
307
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Signs `message` under `context`. The context separates uses of one
|
|
312
|
+
* identity; never let a remote party choose it.
|
|
313
|
+
* @param {Uint8Array} context
|
|
314
|
+
* @param {Uint8Array} message
|
|
315
|
+
* @returns {Uint8Array}
|
|
316
|
+
*/
|
|
317
|
+
sign(context, message) {
|
|
318
|
+
try {
|
|
319
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
320
|
+
const ptr0 = passArray8ToWasm0(context, wasm.__wbindgen_export2);
|
|
321
|
+
const len0 = WASM_VECTOR_LEN;
|
|
322
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_export2);
|
|
323
|
+
const len1 = WASM_VECTOR_LEN;
|
|
324
|
+
wasm.signingidentity_sign(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
325
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
326
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
327
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
328
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
329
|
+
if (r3) {
|
|
330
|
+
throw takeObject(r2);
|
|
331
|
+
}
|
|
332
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
333
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
334
|
+
return v3;
|
|
335
|
+
} finally {
|
|
336
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (Symbol.dispose) SigningIdentity.prototype[Symbol.dispose] = SigningIdentity.prototype.free;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* The verifier's record of answered challenges.
|
|
344
|
+
*
|
|
345
|
+
* Replay can only be caught here: a replayed answer is a genuine signature
|
|
346
|
+
* and nothing about it is invalid on its own. This must therefore outlive a
|
|
347
|
+
* single request.
|
|
348
|
+
*/
|
|
349
|
+
export class SpentNonces {
|
|
350
|
+
__destroy_into_raw() {
|
|
351
|
+
const ptr = this.__wbg_ptr;
|
|
352
|
+
this.__wbg_ptr = 0;
|
|
353
|
+
SpentNoncesFinalization.unregister(this);
|
|
354
|
+
return ptr;
|
|
355
|
+
}
|
|
356
|
+
free() {
|
|
357
|
+
const ptr = this.__destroy_into_raw();
|
|
358
|
+
wasm.__wbg_spentnonces_free(ptr, 0);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Accepts an answer exactly once. Throws `"replayed"` the second time,
|
|
362
|
+
* `"expired"` after the window, and a verification failure otherwise.
|
|
363
|
+
* @param {Uint8Array} challenge
|
|
364
|
+
* @param {Uint8Array} signature
|
|
365
|
+
* @param {Uint8Array} public_key
|
|
366
|
+
* @param {bigint} now
|
|
367
|
+
*/
|
|
368
|
+
accept(challenge, signature, public_key, now) {
|
|
369
|
+
try {
|
|
370
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
371
|
+
const ptr0 = passArray8ToWasm0(challenge, wasm.__wbindgen_export2);
|
|
372
|
+
const len0 = WASM_VECTOR_LEN;
|
|
373
|
+
const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_export2);
|
|
374
|
+
const len1 = WASM_VECTOR_LEN;
|
|
375
|
+
const ptr2 = passArray8ToWasm0(public_key, wasm.__wbindgen_export2);
|
|
376
|
+
const len2 = WASM_VECTOR_LEN;
|
|
377
|
+
wasm.spentnonces_accept(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, now);
|
|
378
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
379
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
380
|
+
if (r1) {
|
|
381
|
+
throw takeObject(r0);
|
|
382
|
+
}
|
|
383
|
+
} finally {
|
|
384
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
constructor() {
|
|
388
|
+
const ret = wasm.spentnonces_new();
|
|
389
|
+
this.__wbg_ptr = ret;
|
|
390
|
+
SpentNoncesFinalization.register(this, this.__wbg_ptr, this);
|
|
391
|
+
return this;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* @returns {number}
|
|
395
|
+
*/
|
|
396
|
+
get size() {
|
|
397
|
+
const ret = wasm.spentnonces_size(this.__wbg_ptr);
|
|
398
|
+
return ret >>> 0;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (Symbol.dispose) SpentNonces.prototype[Symbol.dispose] = SpentNonces.prototype.free;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* @param {Uint8Array} public_key
|
|
405
|
+
* @returns {string}
|
|
406
|
+
*/
|
|
407
|
+
export function armorPublicKey(public_key) {
|
|
408
|
+
let deferred3_0;
|
|
409
|
+
let deferred3_1;
|
|
410
|
+
try {
|
|
411
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
412
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_export2);
|
|
413
|
+
const len0 = WASM_VECTOR_LEN;
|
|
414
|
+
wasm.armorPublicKey(retptr, ptr0, len0);
|
|
415
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
416
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
417
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
418
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
419
|
+
var ptr2 = r0;
|
|
420
|
+
var len2 = r1;
|
|
421
|
+
if (r3) {
|
|
422
|
+
ptr2 = 0; len2 = 0;
|
|
423
|
+
throw takeObject(r2);
|
|
424
|
+
}
|
|
425
|
+
deferred3_0 = ptr2;
|
|
426
|
+
deferred3_1 = len2;
|
|
427
|
+
return getStringFromWasm0(ptr2, len2);
|
|
428
|
+
} finally {
|
|
429
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
430
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* @param {string} text
|
|
436
|
+
* @returns {Uint8Array}
|
|
437
|
+
*/
|
|
438
|
+
export function dearmorPublicKey(text) {
|
|
439
|
+
try {
|
|
440
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
441
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
442
|
+
const len0 = WASM_VECTOR_LEN;
|
|
443
|
+
wasm.dearmorPublicKey(retptr, ptr0, len0);
|
|
444
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
445
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
446
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
447
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
448
|
+
if (r3) {
|
|
449
|
+
throw takeObject(r2);
|
|
450
|
+
}
|
|
451
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
452
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
453
|
+
return v2;
|
|
454
|
+
} finally {
|
|
455
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Decrypts and verifies. Nothing is returned unless the whole payload
|
|
461
|
+
* authenticates.
|
|
462
|
+
*
|
|
463
|
+
* The filename is attacker-controlled: never use it to build a path, and
|
|
464
|
+
* escape it before putting it in the DOM.
|
|
465
|
+
* @param {Uint8Array} container
|
|
466
|
+
* @param {SecretKey} secret
|
|
467
|
+
* @returns {Decrypted}
|
|
468
|
+
*/
|
|
469
|
+
export function decrypt(container, secret) {
|
|
470
|
+
try {
|
|
471
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
472
|
+
const ptr0 = passArray8ToWasm0(container, wasm.__wbindgen_export2);
|
|
473
|
+
const len0 = WASM_VECTOR_LEN;
|
|
474
|
+
_assertClass(secret, SecretKey);
|
|
475
|
+
wasm.decrypt(retptr, ptr0, len0, secret.__wbg_ptr);
|
|
476
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
477
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
478
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
479
|
+
if (r2) {
|
|
480
|
+
throw takeObject(r1);
|
|
481
|
+
}
|
|
482
|
+
return Decrypted.__wrap(r0);
|
|
483
|
+
} finally {
|
|
484
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Encrypts for 1..64 recipients, passed as their concatenated public keys.
|
|
490
|
+
* @param {Uint8Array} plaintext
|
|
491
|
+
* @param {Uint8Array} recipients
|
|
492
|
+
* @param {string | null} [filename]
|
|
493
|
+
* @param {string | null} [media_type]
|
|
494
|
+
* @returns {Uint8Array}
|
|
495
|
+
*/
|
|
496
|
+
export function encrypt(plaintext, recipients, filename, media_type) {
|
|
497
|
+
try {
|
|
498
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
499
|
+
const ptr0 = passArray8ToWasm0(plaintext, wasm.__wbindgen_export2);
|
|
500
|
+
const len0 = WASM_VECTOR_LEN;
|
|
501
|
+
const ptr1 = passArray8ToWasm0(recipients, wasm.__wbindgen_export2);
|
|
502
|
+
const len1 = WASM_VECTOR_LEN;
|
|
503
|
+
var ptr2 = isLikeNone(filename) ? 0 : passStringToWasm0(filename, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
504
|
+
var len2 = WASM_VECTOR_LEN;
|
|
505
|
+
var ptr3 = isLikeNone(media_type) ? 0 : passStringToWasm0(media_type, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
506
|
+
var len3 = WASM_VECTOR_LEN;
|
|
507
|
+
wasm.encrypt(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
508
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
509
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
510
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
511
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
512
|
+
if (r3) {
|
|
513
|
+
throw takeObject(r2);
|
|
514
|
+
}
|
|
515
|
+
var v5 = getArrayU8FromWasm0(r0, r1).slice();
|
|
516
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
517
|
+
return v5;
|
|
518
|
+
} finally {
|
|
519
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Reports `"raw"` or `"protected"` without needing the passphrase.
|
|
525
|
+
* @param {Uint8Array} data
|
|
526
|
+
* @returns {string}
|
|
527
|
+
*/
|
|
528
|
+
export function inspectKey(data) {
|
|
529
|
+
let deferred2_0;
|
|
530
|
+
let deferred2_1;
|
|
531
|
+
try {
|
|
532
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
533
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
|
|
534
|
+
const len0 = WASM_VECTOR_LEN;
|
|
535
|
+
wasm.inspectKey(retptr, ptr0, len0);
|
|
536
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
537
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
538
|
+
deferred2_0 = r0;
|
|
539
|
+
deferred2_1 = r1;
|
|
540
|
+
return getStringFromWasm0(r0, r1);
|
|
541
|
+
} finally {
|
|
542
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
543
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Creates a challenge for a prover to answer.
|
|
549
|
+
*
|
|
550
|
+
* A detached signature proves possession at some point, to nobody in
|
|
551
|
+
* particular, and can be replayed. A challenge binds a random nonce, an
|
|
552
|
+
* audience and an expiry, so an answer is good once, here, now.
|
|
553
|
+
* @param {string} audience
|
|
554
|
+
* @param {bigint} now
|
|
555
|
+
* @param {bigint} valid_for
|
|
556
|
+
* @returns {Uint8Array}
|
|
557
|
+
*/
|
|
558
|
+
export function newChallenge(audience, now, valid_for) {
|
|
559
|
+
try {
|
|
560
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
561
|
+
const ptr0 = passStringToWasm0(audience, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
562
|
+
const len0 = WASM_VECTOR_LEN;
|
|
563
|
+
wasm.newChallenge(retptr, ptr0, len0, now, valid_for);
|
|
564
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
565
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
566
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
567
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
568
|
+
if (r3) {
|
|
569
|
+
throw takeObject(r2);
|
|
570
|
+
}
|
|
571
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
572
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
573
|
+
return v2;
|
|
574
|
+
} finally {
|
|
575
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Throws unless both halves verify. Returns nothing on success rather than a
|
|
581
|
+
* boolean, so a caller that forgets to check cannot read failure as a pass.
|
|
582
|
+
* @param {Uint8Array} public_key
|
|
583
|
+
* @param {Uint8Array} context
|
|
584
|
+
* @param {Uint8Array} message
|
|
585
|
+
* @param {Uint8Array} signature
|
|
586
|
+
*/
|
|
587
|
+
export function verify(public_key, context, message, signature) {
|
|
588
|
+
try {
|
|
589
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
590
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_export2);
|
|
591
|
+
const len0 = WASM_VECTOR_LEN;
|
|
592
|
+
const ptr1 = passArray8ToWasm0(context, wasm.__wbindgen_export2);
|
|
593
|
+
const len1 = WASM_VECTOR_LEN;
|
|
594
|
+
const ptr2 = passArray8ToWasm0(message, wasm.__wbindgen_export2);
|
|
595
|
+
const len2 = WASM_VECTOR_LEN;
|
|
596
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_export2);
|
|
597
|
+
const len3 = WASM_VECTOR_LEN;
|
|
598
|
+
wasm.verify(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
599
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
600
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
601
|
+
if (r1) {
|
|
602
|
+
throw takeObject(r0);
|
|
603
|
+
}
|
|
604
|
+
} finally {
|
|
605
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* @returns {string}
|
|
611
|
+
*/
|
|
612
|
+
export function version() {
|
|
613
|
+
let deferred1_0;
|
|
614
|
+
let deferred1_1;
|
|
615
|
+
try {
|
|
616
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
617
|
+
wasm.version(retptr);
|
|
618
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
619
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
620
|
+
deferred1_0 = r0;
|
|
621
|
+
deferred1_1 = r1;
|
|
622
|
+
return getStringFromWasm0(r0, r1);
|
|
623
|
+
} finally {
|
|
624
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
625
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
function __wbg_get_imports() {
|
|
629
|
+
const import0 = {
|
|
630
|
+
__proto__: null,
|
|
631
|
+
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
632
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
633
|
+
},
|
|
634
|
+
__wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
|
|
635
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
636
|
+
}, arguments); },
|
|
637
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
638
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
639
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
640
|
+
return addHeapObject(ret);
|
|
641
|
+
},
|
|
642
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
643
|
+
takeObject(arg0);
|
|
644
|
+
},
|
|
645
|
+
};
|
|
646
|
+
return {
|
|
647
|
+
__proto__: null,
|
|
648
|
+
"./hide_wasm_bg.js": import0,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
const DecryptedFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
653
|
+
? { register: () => {}, unregister: () => {} }
|
|
654
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_decrypted_free(ptr, 1));
|
|
655
|
+
const SecretKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
656
|
+
? { register: () => {}, unregister: () => {} }
|
|
657
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_secretkey_free(ptr, 1));
|
|
658
|
+
const SigningIdentityFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
659
|
+
? { register: () => {}, unregister: () => {} }
|
|
660
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_signingidentity_free(ptr, 1));
|
|
661
|
+
const SpentNoncesFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
662
|
+
? { register: () => {}, unregister: () => {} }
|
|
663
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_spentnonces_free(ptr, 1));
|
|
664
|
+
|
|
665
|
+
function addHeapObject(obj) {
|
|
666
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
667
|
+
const idx = heap_next;
|
|
668
|
+
heap_next = heap[idx];
|
|
669
|
+
|
|
670
|
+
heap[idx] = obj;
|
|
671
|
+
return idx;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function _assertClass(instance, klass) {
|
|
675
|
+
if (!(instance instanceof klass)) {
|
|
676
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function dropObject(idx) {
|
|
681
|
+
if (idx < 1028) return;
|
|
682
|
+
heap[idx] = heap_next;
|
|
683
|
+
heap_next = idx;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
687
|
+
ptr = ptr >>> 0;
|
|
688
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
let cachedDataViewMemory0 = null;
|
|
692
|
+
function getDataViewMemory0() {
|
|
693
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
694
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
695
|
+
}
|
|
696
|
+
return cachedDataViewMemory0;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function getStringFromWasm0(ptr, len) {
|
|
700
|
+
return decodeText(ptr >>> 0, len);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
let cachedUint8ArrayMemory0 = null;
|
|
704
|
+
function getUint8ArrayMemory0() {
|
|
705
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
706
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
707
|
+
}
|
|
708
|
+
return cachedUint8ArrayMemory0;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function getObject(idx) { return heap[idx]; }
|
|
712
|
+
|
|
713
|
+
function handleError(f, args) {
|
|
714
|
+
try {
|
|
715
|
+
return f.apply(this, args);
|
|
716
|
+
} catch (e) {
|
|
717
|
+
wasm.__wbindgen_export(addHeapObject(e));
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
let heap = new Array(1024).fill(undefined);
|
|
722
|
+
heap.push(undefined, null, true, false);
|
|
723
|
+
|
|
724
|
+
let heap_next = heap.length;
|
|
725
|
+
|
|
726
|
+
function isLikeNone(x) {
|
|
727
|
+
return x === undefined || x === null;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
731
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
732
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
733
|
+
WASM_VECTOR_LEN = arg.length;
|
|
734
|
+
return ptr;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
738
|
+
if (realloc === undefined) {
|
|
739
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
740
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
741
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
742
|
+
WASM_VECTOR_LEN = buf.length;
|
|
743
|
+
return ptr;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
let len = arg.length;
|
|
747
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
748
|
+
|
|
749
|
+
const mem = getUint8ArrayMemory0();
|
|
750
|
+
|
|
751
|
+
let offset = 0;
|
|
752
|
+
|
|
753
|
+
for (; offset < len; offset++) {
|
|
754
|
+
const code = arg.charCodeAt(offset);
|
|
755
|
+
if (code > 0x7F) break;
|
|
756
|
+
mem[ptr + offset] = code;
|
|
757
|
+
}
|
|
758
|
+
if (offset !== len) {
|
|
759
|
+
if (offset !== 0) {
|
|
760
|
+
arg = arg.slice(offset);
|
|
761
|
+
}
|
|
762
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
763
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
764
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
765
|
+
|
|
766
|
+
offset += ret.written;
|
|
767
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
WASM_VECTOR_LEN = offset;
|
|
771
|
+
return ptr;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
function takeObject(idx) {
|
|
775
|
+
const ret = getObject(idx);
|
|
776
|
+
dropObject(idx);
|
|
777
|
+
return ret;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
781
|
+
cachedTextDecoder.decode();
|
|
782
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
783
|
+
let numBytesDecoded = 0;
|
|
784
|
+
function decodeText(ptr, len) {
|
|
785
|
+
numBytesDecoded += len;
|
|
786
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
787
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
788
|
+
cachedTextDecoder.decode();
|
|
789
|
+
numBytesDecoded = len;
|
|
790
|
+
}
|
|
791
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
const cachedTextEncoder = new TextEncoder();
|
|
795
|
+
|
|
796
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
797
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
798
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
799
|
+
view.set(buf);
|
|
800
|
+
return {
|
|
801
|
+
read: arg.length,
|
|
802
|
+
written: buf.length
|
|
803
|
+
};
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
let WASM_VECTOR_LEN = 0;
|
|
808
|
+
|
|
809
|
+
let wasmModule, wasmInstance, wasm;
|
|
810
|
+
function __wbg_finalize_init(instance, module) {
|
|
811
|
+
wasmInstance = instance;
|
|
812
|
+
wasm = instance.exports;
|
|
813
|
+
wasmModule = module;
|
|
814
|
+
cachedDataViewMemory0 = null;
|
|
815
|
+
cachedUint8ArrayMemory0 = null;
|
|
816
|
+
return wasm;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
async function __wbg_load(module, imports) {
|
|
820
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
821
|
+
if (!module.ok) {
|
|
822
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
826
|
+
try {
|
|
827
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
828
|
+
} catch (e) {
|
|
829
|
+
const validResponse = expectedResponseType(module.type);
|
|
830
|
+
|
|
831
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
832
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
833
|
+
|
|
834
|
+
} else { throw e; }
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
const bytes = await module.arrayBuffer();
|
|
839
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
840
|
+
} else {
|
|
841
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
842
|
+
|
|
843
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
844
|
+
return { instance, module };
|
|
845
|
+
} else {
|
|
846
|
+
return instance;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
function expectedResponseType(type) {
|
|
851
|
+
switch (type) {
|
|
852
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
853
|
+
}
|
|
854
|
+
return false;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
function initSync(module) {
|
|
859
|
+
if (wasm !== undefined) return wasm;
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
if (module !== undefined) {
|
|
863
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
864
|
+
({module} = module)
|
|
865
|
+
} else {
|
|
866
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
const imports = __wbg_get_imports();
|
|
871
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
872
|
+
module = new WebAssembly.Module(module);
|
|
873
|
+
}
|
|
874
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
875
|
+
return __wbg_finalize_init(instance, module);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
async function __wbg_init(module_or_path) {
|
|
879
|
+
if (wasm !== undefined) return wasm;
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
if (module_or_path !== undefined) {
|
|
883
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
884
|
+
({module_or_path} = module_or_path)
|
|
885
|
+
} else {
|
|
886
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
if (module_or_path === undefined) {
|
|
891
|
+
module_or_path = new URL('hide_wasm_bg.wasm', import.meta.url);
|
|
892
|
+
}
|
|
893
|
+
const imports = __wbg_get_imports();
|
|
894
|
+
|
|
895
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
896
|
+
module_or_path = fetch(module_or_path);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
900
|
+
|
|
901
|
+
return __wbg_finalize_init(instance, module);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_decrypted_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_secretkey_free: (a: number, b: number) => void;
|
|
6
|
+
export const __wbg_signingidentity_free: (a: number, b: number) => void;
|
|
7
|
+
export const __wbg_spentnonces_free: (a: number, b: number) => void;
|
|
8
|
+
export const armorPublicKey: (a: number, b: number, c: number) => void;
|
|
9
|
+
export const dearmorPublicKey: (a: number, b: number, c: number) => void;
|
|
10
|
+
export const decrypt: (a: number, b: number, c: number, d: number) => void;
|
|
11
|
+
export const decrypted_data: (a: number, b: number) => void;
|
|
12
|
+
export const decrypted_filename: (a: number, b: number) => void;
|
|
13
|
+
export const decrypted_mediaType: (a: number, b: number) => void;
|
|
14
|
+
export const encrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
15
|
+
export const inspectKey: (a: number, b: number, c: number) => void;
|
|
16
|
+
export const newChallenge: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
|
17
|
+
export const secretkey_generate: (a: number) => void;
|
|
18
|
+
export const secretkey_load: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
19
|
+
export const secretkey_protect: (a: number, b: number, c: number, d: number) => void;
|
|
20
|
+
export const secretkey_publicKey: (a: number, b: number) => void;
|
|
21
|
+
export const signingidentity_answer: (a: number, b: number, c: number, d: number) => void;
|
|
22
|
+
export const signingidentity_generate: (a: number, b: number, c: number) => void;
|
|
23
|
+
export const signingidentity_load: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
24
|
+
export const signingidentity_publicKey: (a: number, b: number) => void;
|
|
25
|
+
export const signingidentity_sign: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
26
|
+
export const spentnonces_accept: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: bigint) => void;
|
|
27
|
+
export const spentnonces_new: () => number;
|
|
28
|
+
export const spentnonces_size: (a: number) => number;
|
|
29
|
+
export const verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
30
|
+
export const version: (a: number) => void;
|
|
31
|
+
export const __wbindgen_export: (a: number) => void;
|
|
32
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
33
|
+
export const __wbindgen_export2: (a: number, b: number) => number;
|
|
34
|
+
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
35
|
+
export const __wbindgen_export4: (a: number, b: number, c: number, d: number) => number;
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hide-protocol/wasm",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "HIDE for the browser via WebAssembly. Experimental and unaudited.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"main": "./hide_wasm.js",
|
|
8
|
+
"types": "./hide_wasm.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"hide_wasm.js",
|
|
11
|
+
"hide_wasm.d.ts",
|
|
12
|
+
"hide_wasm_bg.wasm",
|
|
13
|
+
"hide_wasm_bg.wasm.d.ts",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"sideEffects": [
|
|
18
|
+
"./hide_wasm.js"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"encryption",
|
|
22
|
+
"post-quantum",
|
|
23
|
+
"cryptography",
|
|
24
|
+
"webassembly",
|
|
25
|
+
"ml-kem"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/hide-protocol/hide.git",
|
|
30
|
+
"directory": "sdk/wasm"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/hide-protocol/hide"
|
|
33
|
+
}
|