cpace-ts 0.1.0 → 0.1.2
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 +81 -1
- package/package.json +57 -56
- package/wasm/pkg/.gitignore +0 -1
- package/wasm/pkg/cpace_wasm.d.ts +0 -38
- package/wasm/pkg/cpace_wasm.js +0 -180
- package/wasm/pkg/cpace_wasm_bg.js +0 -81
- package/wasm/pkg/cpace_wasm_bg.wasm +0 -0
- package/wasm/pkg/cpace_wasm_bg.wasm.d.ts +0 -9
- package/wasm/pkg/package.json +0 -15
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](#)
|
|
6
6
|
[](#)
|
|
7
7
|
|
|
8
|
-
**What is it?** Minimal, audit-friendly implementation in strict accordance with version
|
|
8
|
+
**What is it?** Minimal, audit-friendly implementation in strict accordance with version 18 of the [IETF draft](https://datatracker.ietf.org/doc/draft-irtf-cfrg-cpace/) CPace for TS
|
|
9
9
|
**Why?** Clean API, strict validation, audit hooks, test-driven.
|
|
10
10
|
|
|
11
11
|
## Features
|
|
@@ -18,3 +18,83 @@
|
|
|
18
18
|
## Install
|
|
19
19
|
```bash
|
|
20
20
|
pnpm add cpace-ts
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import {
|
|
27
|
+
type CPaceMessage,
|
|
28
|
+
type CPaceMode,
|
|
29
|
+
type CPaceRole,
|
|
30
|
+
CPaceSession,
|
|
31
|
+
G_X25519,
|
|
32
|
+
sha512,
|
|
33
|
+
} from 'cpace-ts';
|
|
34
|
+
|
|
35
|
+
const EMPTY_AD = new Uint8Array(0);
|
|
36
|
+
|
|
37
|
+
export function newSession(role: CPaceRole, prs: Uint8Array): CPaceSession {
|
|
38
|
+
const suite = {
|
|
39
|
+
name: 'CPACE-X25519-SHA512',
|
|
40
|
+
group: G_X25519,
|
|
41
|
+
hash: sha512,
|
|
42
|
+
} as const;
|
|
43
|
+
|
|
44
|
+
const mode: CPaceMode = 'initiator-responder';
|
|
45
|
+
|
|
46
|
+
const s = new CPaceSession({
|
|
47
|
+
prs,
|
|
48
|
+
suite,
|
|
49
|
+
mode,
|
|
50
|
+
role,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return s;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function start(s: CPaceSession): Promise<Uint8Array> {
|
|
57
|
+
const msg = await s.start();
|
|
58
|
+
if (!msg) throw new Error('CPaceSession.start() returned null/undefined');
|
|
59
|
+
return msg.payload;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function receive(
|
|
63
|
+
s: CPaceSession,
|
|
64
|
+
payload: Uint8Array,
|
|
65
|
+
): Promise<Uint8Array> {
|
|
66
|
+
const inbound: CPaceMessage = {
|
|
67
|
+
type: 'msg',
|
|
68
|
+
payload,
|
|
69
|
+
ad: EMPTY_AD,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const out = await s.receive(inbound);
|
|
73
|
+
return out.payload;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function exportISK(s: CPaceSession): Uint8Array {
|
|
77
|
+
return s.exportISK();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function runFullHandshake() {
|
|
81
|
+
const prs = new Uint8Array([...]); // Pre-shared secret
|
|
82
|
+
|
|
83
|
+
// Setup both parties
|
|
84
|
+
const initiator = newSession('initiator', prs);
|
|
85
|
+
const responder = newSession('responder', prs);
|
|
86
|
+
|
|
87
|
+
// 1. Initiator starts and sends message to Responder
|
|
88
|
+
const msg1 = await start(initiator);
|
|
89
|
+
|
|
90
|
+
// 2. Responder receives message and sends a reply
|
|
91
|
+
const msg2 = await receive(responder, msg1);
|
|
92
|
+
|
|
93
|
+
// 3. Initiator receives the reply
|
|
94
|
+
await receive(initiator, msg2);
|
|
95
|
+
|
|
96
|
+
// Handshake complete, keys can be exported
|
|
97
|
+
const initiatorKey = exportISK(initiator);
|
|
98
|
+
const responderKey = exportISK(responder);
|
|
99
|
+
}
|
|
100
|
+
```
|
package/package.json
CHANGED
|
@@ -1,58 +1,59 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
2
|
+
"name": "cpace-ts",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "CPace for TypeScript",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/slava-nikulin/cpace-ts.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"cpace",
|
|
12
|
+
"pake"
|
|
13
|
+
],
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@biomejs/biome": "2.3.2",
|
|
16
|
+
"@types/node": "^24.9.2",
|
|
17
|
+
"@typescript-eslint/parser": "^8.46.2",
|
|
18
|
+
"rimraf": "^6.1.0",
|
|
19
|
+
"ts-node": "^10.9.2",
|
|
20
|
+
"tsup": "^8.5.0",
|
|
21
|
+
"typescript": "^5.9.3",
|
|
22
|
+
"vitest": "^4.0.4"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/index.cjs",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./wasm": {
|
|
35
|
+
"types": "./wasm/pkg/cpace_wasm.d.ts",
|
|
36
|
+
"import": "./wasm/pkg/cpace_wasm.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist/**",
|
|
41
|
+
"wasm/pkg/**",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"prepack": "pnpm build",
|
|
47
|
+
"build": "pnpm clean && pnpm build:wasm && tsup",
|
|
48
|
+
"build:wasm": "wasm-pack build crates/cpace-wasm --target web --release --out-dir ../../wasm/pkg",
|
|
49
|
+
"dev": "tsup --watch",
|
|
50
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
51
|
+
"clean": "rimraf dist",
|
|
52
|
+
"test:unit": "vitest run --project unit",
|
|
53
|
+
"test:int": "vitest run --project integration",
|
|
54
|
+
"test": "pnpm test:unit && pnpm test:int"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@noble/curves": "^2.0.1"
|
|
58
|
+
}
|
|
58
59
|
}
|
package/wasm/pkg/.gitignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
*
|
package/wasm/pkg/cpace_wasm.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
export function elligator2_curve25519_u(rep: Uint8Array): Uint8Array;
|
|
5
|
-
|
|
6
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
7
|
-
|
|
8
|
-
export interface InitOutput {
|
|
9
|
-
readonly memory: WebAssembly.Memory;
|
|
10
|
-
readonly elligator2_curve25519_u: (a: number, b: number) => [number, number, number, number];
|
|
11
|
-
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
12
|
-
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
13
|
-
readonly __externref_table_dealloc: (a: number) => void;
|
|
14
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
15
|
-
readonly __wbindgen_start: () => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
22
|
-
* a precompiled `WebAssembly.Module`.
|
|
23
|
-
*
|
|
24
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
25
|
-
*
|
|
26
|
-
* @returns {InitOutput}
|
|
27
|
-
*/
|
|
28
|
-
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
32
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
33
|
-
*
|
|
34
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
35
|
-
*
|
|
36
|
-
* @returns {Promise<InitOutput>}
|
|
37
|
-
*/
|
|
38
|
-
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/wasm/pkg/cpace_wasm.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/* @ts-self-types="./cpace_wasm.d.ts" */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {Uint8Array} rep
|
|
5
|
-
* @returns {Uint8Array}
|
|
6
|
-
*/
|
|
7
|
-
export function elligator2_curve25519_u(rep) {
|
|
8
|
-
const ptr0 = passArray8ToWasm0(rep, wasm.__wbindgen_malloc);
|
|
9
|
-
const len0 = WASM_VECTOR_LEN;
|
|
10
|
-
const ret = wasm.elligator2_curve25519_u(ptr0, len0);
|
|
11
|
-
if (ret[3]) {
|
|
12
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
13
|
-
}
|
|
14
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
15
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
16
|
-
return v2;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function __wbg_get_imports() {
|
|
20
|
-
const import0 = {
|
|
21
|
-
__proto__: null,
|
|
22
|
-
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
23
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
24
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
25
|
-
return ret;
|
|
26
|
-
},
|
|
27
|
-
__wbindgen_init_externref_table: function() {
|
|
28
|
-
const table = wasm.__wbindgen_externrefs;
|
|
29
|
-
const offset = table.grow(4);
|
|
30
|
-
table.set(0, undefined);
|
|
31
|
-
table.set(offset + 0, undefined);
|
|
32
|
-
table.set(offset + 1, null);
|
|
33
|
-
table.set(offset + 2, true);
|
|
34
|
-
table.set(offset + 3, false);
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
__proto__: null,
|
|
39
|
-
"./cpace_wasm_bg.js": import0,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
44
|
-
ptr = ptr >>> 0;
|
|
45
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function getStringFromWasm0(ptr, len) {
|
|
49
|
-
ptr = ptr >>> 0;
|
|
50
|
-
return decodeText(ptr, len);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let cachedUint8ArrayMemory0 = null;
|
|
54
|
-
function getUint8ArrayMemory0() {
|
|
55
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
56
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
57
|
-
}
|
|
58
|
-
return cachedUint8ArrayMemory0;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
62
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
63
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
64
|
-
WASM_VECTOR_LEN = arg.length;
|
|
65
|
-
return ptr;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function takeFromExternrefTable0(idx) {
|
|
69
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
70
|
-
wasm.__externref_table_dealloc(idx);
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
75
|
-
cachedTextDecoder.decode();
|
|
76
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
77
|
-
let numBytesDecoded = 0;
|
|
78
|
-
function decodeText(ptr, len) {
|
|
79
|
-
numBytesDecoded += len;
|
|
80
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
81
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
82
|
-
cachedTextDecoder.decode();
|
|
83
|
-
numBytesDecoded = len;
|
|
84
|
-
}
|
|
85
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let WASM_VECTOR_LEN = 0;
|
|
89
|
-
|
|
90
|
-
let wasmModule, wasm;
|
|
91
|
-
function __wbg_finalize_init(instance, module) {
|
|
92
|
-
wasm = instance.exports;
|
|
93
|
-
wasmModule = module;
|
|
94
|
-
cachedUint8ArrayMemory0 = null;
|
|
95
|
-
wasm.__wbindgen_start();
|
|
96
|
-
return wasm;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function __wbg_load(module, imports) {
|
|
100
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
101
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
102
|
-
try {
|
|
103
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
104
|
-
} catch (e) {
|
|
105
|
-
const validResponse = module.ok && expectedResponseType(module.type);
|
|
106
|
-
|
|
107
|
-
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
108
|
-
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);
|
|
109
|
-
|
|
110
|
-
} else { throw e; }
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const bytes = await module.arrayBuffer();
|
|
115
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
116
|
-
} else {
|
|
117
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
118
|
-
|
|
119
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
120
|
-
return { instance, module };
|
|
121
|
-
} else {
|
|
122
|
-
return instance;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function expectedResponseType(type) {
|
|
127
|
-
switch (type) {
|
|
128
|
-
case 'basic': case 'cors': case 'default': return true;
|
|
129
|
-
}
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function initSync(module) {
|
|
135
|
-
if (wasm !== undefined) return wasm;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (module !== undefined) {
|
|
139
|
-
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
140
|
-
({module} = module)
|
|
141
|
-
} else {
|
|
142
|
-
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const imports = __wbg_get_imports();
|
|
147
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
148
|
-
module = new WebAssembly.Module(module);
|
|
149
|
-
}
|
|
150
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
151
|
-
return __wbg_finalize_init(instance, module);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async function __wbg_init(module_or_path) {
|
|
155
|
-
if (wasm !== undefined) return wasm;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (module_or_path !== undefined) {
|
|
159
|
-
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
160
|
-
({module_or_path} = module_or_path)
|
|
161
|
-
} else {
|
|
162
|
-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (module_or_path === undefined) {
|
|
167
|
-
module_or_path = new URL('cpace_wasm_bg.wasm', import.meta.url);
|
|
168
|
-
}
|
|
169
|
-
const imports = __wbg_get_imports();
|
|
170
|
-
|
|
171
|
-
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
172
|
-
module_or_path = fetch(module_or_path);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
176
|
-
|
|
177
|
-
return __wbg_finalize_init(instance, module);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export { initSync, __wbg_init as default };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {Uint8Array} rep
|
|
3
|
-
* @returns {Uint8Array}
|
|
4
|
-
*/
|
|
5
|
-
export function elligator2_curve25519_u(rep) {
|
|
6
|
-
const ptr0 = passArray8ToWasm0(rep, wasm.__wbindgen_malloc);
|
|
7
|
-
const len0 = WASM_VECTOR_LEN;
|
|
8
|
-
const ret = wasm.elligator2_curve25519_u(ptr0, len0);
|
|
9
|
-
if (ret[3]) {
|
|
10
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
11
|
-
}
|
|
12
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
13
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
14
|
-
return v2;
|
|
15
|
-
}
|
|
16
|
-
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
17
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
18
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
19
|
-
return ret;
|
|
20
|
-
}
|
|
21
|
-
export function __wbindgen_init_externref_table() {
|
|
22
|
-
const table = wasm.__wbindgen_externrefs;
|
|
23
|
-
const offset = table.grow(4);
|
|
24
|
-
table.set(0, undefined);
|
|
25
|
-
table.set(offset + 0, undefined);
|
|
26
|
-
table.set(offset + 1, null);
|
|
27
|
-
table.set(offset + 2, true);
|
|
28
|
-
table.set(offset + 3, false);
|
|
29
|
-
}
|
|
30
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
31
|
-
ptr = ptr >>> 0;
|
|
32
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function getStringFromWasm0(ptr, len) {
|
|
36
|
-
ptr = ptr >>> 0;
|
|
37
|
-
return decodeText(ptr, len);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let cachedUint8ArrayMemory0 = null;
|
|
41
|
-
function getUint8ArrayMemory0() {
|
|
42
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
43
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
44
|
-
}
|
|
45
|
-
return cachedUint8ArrayMemory0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
49
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
50
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
51
|
-
WASM_VECTOR_LEN = arg.length;
|
|
52
|
-
return ptr;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function takeFromExternrefTable0(idx) {
|
|
56
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
57
|
-
wasm.__externref_table_dealloc(idx);
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
62
|
-
cachedTextDecoder.decode();
|
|
63
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
64
|
-
let numBytesDecoded = 0;
|
|
65
|
-
function decodeText(ptr, len) {
|
|
66
|
-
numBytesDecoded += len;
|
|
67
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
68
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
69
|
-
cachedTextDecoder.decode();
|
|
70
|
-
numBytesDecoded = len;
|
|
71
|
-
}
|
|
72
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let WASM_VECTOR_LEN = 0;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
let wasm;
|
|
79
|
-
export function __wbg_set_wasm(val) {
|
|
80
|
-
wasm = val;
|
|
81
|
-
}
|
|
Binary file
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const elligator2_curve25519_u: (a: number, b: number) => [number, number, number, number];
|
|
5
|
-
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
6
|
-
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
7
|
-
export const __externref_table_dealloc: (a: number) => void;
|
|
8
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
9
|
-
export const __wbindgen_start: () => void;
|
package/wasm/pkg/package.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cpace-wasm",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "0.1.0",
|
|
5
|
-
"files": [
|
|
6
|
-
"cpace_wasm_bg.wasm",
|
|
7
|
-
"cpace_wasm.js",
|
|
8
|
-
"cpace_wasm.d.ts"
|
|
9
|
-
],
|
|
10
|
-
"main": "cpace_wasm.js",
|
|
11
|
-
"types": "cpace_wasm.d.ts",
|
|
12
|
-
"sideEffects": [
|
|
13
|
-
"./snippets/*"
|
|
14
|
-
]
|
|
15
|
-
}
|