@vouch-protocol-official/core-wasm 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,198 @@
1
+ Apache License 2.0
2
+ ==================
3
+
4
+ Copyright 2025 Vouch Protocol Contributors
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+
18
+ NOTE: The Vouch Protocol specification may be contributed to W3C
19
+ Verifiable Credentials Working Group as a separate standards track.
20
+
21
+ ================================================================================
22
+
23
+ Apache License
24
+ Version 2.0, January 2004
25
+ http://www.apache.org/licenses/
26
+
27
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
28
+
29
+ 1. Definitions.
30
+
31
+ "License" shall mean the terms and conditions for use, reproduction,
32
+ and distribution as defined by Sections 1 through 9 of this document.
33
+
34
+ "Licensor" shall mean the copyright owner or entity authorized by
35
+ the copyright owner that is granting the License.
36
+
37
+ "Legal Entity" shall mean the union of the acting entity and all
38
+ other entities that control, are controlled by, or are under common
39
+ control with that entity. For the purposes of this definition,
40
+ "control" means (i) the power, direct or indirect, to cause the
41
+ direction or management of such entity, whether by contract or
42
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
43
+ outstanding shares, or (iii) beneficial ownership of such entity.
44
+
45
+ "You" (or "Your") shall mean an individual or Legal Entity
46
+ exercising permissions granted by this License.
47
+
48
+ "Source" form shall mean the preferred form for making modifications,
49
+ including but not limited to software source code, documentation
50
+ source, and configuration files.
51
+
52
+ "Object" form shall mean any form resulting from mechanical
53
+ transformation or translation of a Source form, including but
54
+ not limited to compiled object code, generated documentation,
55
+ and conversions to other media types.
56
+
57
+ "Work" shall mean the work of authorship, whether in Source or
58
+ Object form, made available under the License, as indicated by a
59
+ copyright notice that is included in or attached to the work
60
+ (an example is provided in the Appendix below).
61
+
62
+ "Derivative Works" shall mean any work, whether in Source or Object
63
+ form, that is based on (or derived from) the Work and for which the
64
+ editorial revisions, annotations, elaborations, or other modifications
65
+ represent, as a whole, an original work of authorship. For the purposes
66
+ of this License, Derivative Works shall not include works that remain
67
+ separable from, or merely link (or bind by name) to the interfaces of,
68
+ the Work and Derivative Works thereof.
69
+
70
+ "Contribution" shall mean any work of authorship, including
71
+ the original version of the Work and any modifications or additions
72
+ to that Work or Derivative Works thereof, that is intentionally
73
+ submitted to Licensor for inclusion in the Work by the copyright owner
74
+ or by an individual or Legal Entity authorized to submit on behalf of
75
+ the copyright owner. For the purposes of this definition, "submitted"
76
+ means any form of electronic, verbal, or written communication sent
77
+ to the Licensor or its representatives, including but not limited to
78
+ communication on electronic mailing lists, source code control systems,
79
+ and issue tracking systems that are managed by, or on behalf of, the
80
+ Licensor for the purpose of discussing and improving the Work, but
81
+ excluding communication that is conspicuously marked or otherwise
82
+ designated in writing by the copyright owner as "Not a Contribution."
83
+
84
+ "Contributor" shall mean Licensor and any individual or Legal Entity
85
+ on behalf of whom a Contribution has been received by Licensor and
86
+ subsequently incorporated within the Work.
87
+
88
+ 2. Grant of Copyright License. Subject to the terms and conditions of
89
+ this License, each Contributor hereby grants to You a perpetual,
90
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
91
+ copyright license to reproduce, prepare Derivative Works of,
92
+ publicly display, publicly perform, sublicense, and distribute the
93
+ Work and such Derivative Works in Source or Object form.
94
+
95
+ 3. Grant of Patent License. Subject to the terms and conditions of
96
+ this License, each Contributor hereby grants to You a perpetual,
97
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
98
+ (except as stated in this section) patent license to make, have made,
99
+ use, offer to sell, sell, import, and otherwise transfer the Work,
100
+ where such license applies only to those patent claims licensable
101
+ by such Contributor that are necessarily infringed by their
102
+ Contribution(s) alone or by combination of their Contribution(s)
103
+ with the Work to which such Contribution(s) was submitted. If You
104
+ institute patent litigation against any entity (including a
105
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
106
+ or a Contribution incorporated within the Work constitutes direct
107
+ or contributory patent infringement, then any patent licenses
108
+ granted to You under this License for that Work shall terminate
109
+ as of the date such litigation is filed.
110
+
111
+ 4. Redistribution. You may reproduce and distribute copies of the
112
+ Work or Derivative Works thereof in any medium, with or without
113
+ modifications, and in Source or Object form, provided that You
114
+ meet the following conditions:
115
+
116
+ (a) You must give any other recipients of the Work or
117
+ Derivative Works a copy of this License; and
118
+
119
+ (b) You must cause any modified files to carry prominent notices
120
+ stating that You changed the files; and
121
+
122
+ (c) You must retain, in the Source form of any Derivative Works
123
+ that You distribute, all copyright, patent, trademark, and
124
+ attribution notices from the Source form of the Work,
125
+ excluding those notices that do not pertain to any part of
126
+ the Derivative Works; and
127
+
128
+ (d) If the Work includes a "NOTICE" text file as part of its
129
+ distribution, then any Derivative Works that You distribute must
130
+ include a readable copy of the attribution notices contained
131
+ within such NOTICE file, excluding those notices that do not
132
+ pertain to any part of the Derivative Works, in at least one
133
+ of the following places: within a NOTICE text file distributed
134
+ as part of the Derivative Works; within the Source form or
135
+ documentation, if provided along with the Derivative Works; or,
136
+ within a display generated by the Derivative Works, if and
137
+ wherever such third-party notices normally appear. The contents
138
+ of the NOTICE file are for informational purposes only and
139
+ do not modify the License. You may add Your own attribution
140
+ notices within Derivative Works that You distribute, alongside
141
+ or as an addendum to the NOTICE text from the Work, provided
142
+ that such additional attribution notices cannot be construed
143
+ as modifying the License.
144
+
145
+ You may add Your own copyright statement to Your modifications and
146
+ may provide additional or different license terms and conditions
147
+ for use, reproduction, or distribution of Your modifications, or
148
+ for any such Derivative Works as a whole, provided Your use,
149
+ reproduction, and distribution of the Work otherwise complies with
150
+ the conditions stated in this License.
151
+
152
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
153
+ any Contribution intentionally submitted for inclusion in the Work
154
+ by You to the Licensor shall be under the terms and conditions of
155
+ this License, without any additional terms or conditions.
156
+ Notwithstanding the above, nothing herein shall supersede or modify
157
+ the terms of any separate license agreement you may have executed
158
+ with Licensor regarding such Contributions.
159
+
160
+ 6. Trademarks. This License does not grant permission to use the trade
161
+ names, trademarks, service marks, or product names of the Licensor,
162
+ except as required for reasonable and customary use in describing the
163
+ origin of the Work and reproducing the content of the NOTICE file.
164
+
165
+ 7. Disclaimer of Warranty. Unless required by applicable law or
166
+ agreed to in writing, Licensor provides the Work (and each
167
+ Contributor provides its Contributions) on an "AS IS" BASIS,
168
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
169
+ implied, including, without limitation, any warranties or conditions
170
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
171
+ PARTICULAR PURPOSE. You are solely responsible for determining the
172
+ appropriateness of using or redistributing the Work and assume any
173
+ risks associated with Your exercise of permissions under this License.
174
+
175
+ 8. Limitation of Liability. In no event and under no legal theory,
176
+ whether in tort (including negligence), contract, or otherwise,
177
+ unless required by applicable law (such as deliberate and grossly
178
+ negligent acts) or agreed to in writing, shall any Contributor be
179
+ liable to You for damages, including any direct, indirect, special,
180
+ incidental, or consequential damages of any character arising as a
181
+ result of this License or out of the use or inability to use the
182
+ Work (including but not limited to damages for loss of goodwill,
183
+ work stoppage, computer failure or malfunction, or any and all
184
+ other commercial damages or losses), even if such Contributor
185
+ has been advised of the possibility of such damages.
186
+
187
+ 9. Accepting Warranty or Additional Liability. While redistributing
188
+ the Work or Derivative Works thereof, You may choose to offer,
189
+ and charge a fee for, acceptance of support, warranty, indemnity,
190
+ or other liability obligations and/or rights consistent with this
191
+ License. However, in accepting such obligations, You may act only
192
+ on Your own behalf and on Your sole responsibility, not on behalf
193
+ of any other Contributor, and only if You agree to indemnify,
194
+ defend, and hold each Contributor harmless for any liability
195
+ incurred by, or claims asserted against, such Contributor by reason
196
+ of your accepting any such warranty or additional liability.
197
+
198
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # @vouch-protocol-official/core-wasm
2
+
3
+ The canonical Vouch Protocol core, compiled to WebAssembly for browsers and
4
+ Node.js. It is a thin wrapper over one byte-exact Rust crate (`vouch-core`), the
5
+ same core that powers the native and mobile SDKs, so every platform produces and
6
+ verifies identical bytes. No JCS or proof logic is re-implemented per language.
7
+
8
+ Apache-2.0. Part of the Vouch Protocol (https://vouch-protocol.com).
9
+
10
+ ## What it does
11
+
12
+ - **JCS canonicalization** (RFC 8785)
13
+ - **Ed25519** keygen, sign, verify
14
+ - **did:key** and **multikey** (Ed25519, ML-DSA-44) encode/decode
15
+ - **Data Integrity proofs**, cryptosuite `eddsa-jcs-2022` (build/verify)
16
+ - **Vouch credentials** build and verify (with validity-window checks)
17
+ - **Delegation** time-bound chain validation
18
+ - **Post-quantum**: ML-DSA-44 (FIPS 204) and dual proofs (Ed25519 + ML-DSA, two
19
+ independent proofs), plus verification of the v1.6.x composite profile
20
+ - **Revocation**: BitstringStatusList status checks
21
+
22
+ ## Install
23
+
24
+ ```
25
+ npm install @vouch-protocol-official/core-wasm
26
+ ```
27
+
28
+ ## Usage (browser)
29
+
30
+ The package is built with the `web` target, so you initialize the WASM module
31
+ once, then call the functions. Binary values (keys, messages, signatures) are
32
+ base64 strings; credentials and proofs are JSON strings.
33
+
34
+ ```js
35
+ import init, * as core from '@vouch-protocol-official/core-wasm';
36
+
37
+ await init(); // fetches the .wasm next to the module
38
+
39
+ const kp = JSON.parse(core.generateEd25519());
40
+ const signed = core.signCredential(
41
+ JSON.stringify(myCredential),
42
+ kp.seed_b64,
43
+ kp.did_key + '#key-1',
44
+ '2026-04-26T10:00:00Z'
45
+ );
46
+ const ok = core.verifyProof(signed, kp.public_b64); // true
47
+ ```
48
+
49
+ ## Usage (Node.js, ESM)
50
+
51
+ Two Node-specific notes:
52
+
53
+ 1. Pass the wasm bytes to `init` (no fetch in Node):
54
+
55
+ ```js
56
+ import init, * as core from '@vouch-protocol-official/core-wasm';
57
+ import { readFileSync } from 'fs';
58
+ import { createRequire } from 'module';
59
+ const require = createRequire(import.meta.url);
60
+ const wasmPath = require.resolve('@vouch-protocol-official/core-wasm/vouch_core_wasm_bg.wasm');
61
+ await init({ module_or_path: readFileSync(wasmPath) });
62
+ ```
63
+
64
+ 2. Key generation and ML-DSA signing need a CSPRNG. Browsers expose it natively;
65
+ under Node ESM you must make Web Crypto global before calling those functions
66
+ (verification and deterministic signing do not need this):
67
+
68
+ ```js
69
+ import { webcrypto } from 'node:crypto';
70
+ if (!globalThis.crypto) globalThis.crypto = webcrypto;
71
+ ```
72
+
73
+ ## Next.js / bundlers
74
+
75
+ This is a WASM module. With the App Router, call `init()` in a client component
76
+ (or a server action) before using the API, and ensure your bundler serves the
77
+ `.wasm` asset. With Webpack set `experiments.asyncWebAssembly = true`; with
78
+ Turbopack and Vite the default wasm handling works.
79
+
80
+ ## API
81
+
82
+ All functions return strings (JSON or base64) or booleans, and throw on bad
83
+ input. Highlights:
84
+
85
+ - `canonicalize(json) -> string`
86
+ - `generateEd25519() -> {seed_b64, public_b64, multikey, did_key}` (JSON)
87
+ - `ed25519Sign(seed_b64, message_b64) -> string`, `ed25519Verify(public_b64, message_b64, signature_b64) -> bool`
88
+ - `encodeEd25519Multikey(public_b64) -> string`, `decodeMultikey(mk) -> {algorithm, raw_b64}`
89
+ - `didKeyFromEd25519(public_b64) -> string`, `ed25519FromDidKey(did) -> string`
90
+ - `buildProof(credentialJson, seed_b64, verificationMethod, createdIso) -> proofJson`
91
+ - `signCredential(...)`, `verifyProof(credentialJson, public_b64) -> bool`
92
+ - `verifyCredential(credentialJson, public_b64, nowIso, clockSkewSeconds) -> {proofValid, timeValid, valid}`
93
+ - `verifyChainTimeBound(chainJson, nowIso, clockSkewSeconds) -> bool`
94
+ - `generateMldsa44() -> {secret_b64, public_b64}`, `mldsa44Sign(...)`, `mldsa44Verify(...)`
95
+ - `signDual(...)`, `verifyDual(...)`, `verifyComposite(...)`
96
+ - `verifyStatus(credentialStatusJson, statusListCredentialJson) -> bool`
97
+ - `version() -> string`
98
+
99
+ ## Interop
100
+
101
+ Output is verified byte-for-byte against shared cross-language vectors in
102
+ `test-vectors/` (JCS, eddsa-jcs-2022, hybrid ML-DSA, BitstringStatusList). A
103
+ proof built here verifies in the TypeScript, Python, and Go SDKs and vice versa.
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@vouch-protocol-official/core-wasm",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "Ramprasad Anandam Gaddam"
6
+ ],
7
+ "description": "Vouch Protocol canonical core (WASM): JCS canonicalization, Ed25519, did:key/multikey, Data Integrity (eddsa-jcs-2022), credentials, delegation, dual-proof ML-DSA-44, and BitstringStatusList revocation. One byte-exact Rust implementation shared across every Vouch SDK.",
8
+ "version": "0.1.0",
9
+ "license": "Apache-2.0",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/vouch-protocol/vouch",
13
+ "directory": "core/wasm"
14
+ },
15
+ "files": [
16
+ "vouch_core_wasm_bg.wasm",
17
+ "vouch_core_wasm.js",
18
+ "vouch_core_wasm.d.ts",
19
+ "vouch_core_wasm_bg.wasm.d.ts",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "main": "vouch_core_wasm.js",
24
+ "types": "vouch_core_wasm.d.ts",
25
+ "sideEffects": [
26
+ "./snippets/*"
27
+ ],
28
+ "homepage": "https://vouch-protocol.com",
29
+ "publishConfig": {
30
+ "access": "public"
31
+ }
32
+ }
@@ -0,0 +1,123 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Build a delegation link. Pass null/undefined for the optional validFrom,
6
+ * validUntil, parentProofValue. Returns the link as a JSON string.
7
+ */
8
+ export function buildDelegationLink(issuer: string, subject: string, intent_json: string, valid_from?: string | null, valid_until?: string | null, parent_proof_value?: string | null): string;
9
+
10
+ export function buildProof(credential_json: string, seed_b64: string, verification_method: string, created: string): string;
11
+
12
+ /**
13
+ * RFC 8785 canonicalization of a JSON string.
14
+ */
15
+ export function canonicalize(json_str: string): string;
16
+
17
+ export function decodeMultikey(multikey_str: string): string;
18
+
19
+ export function didKeyFromEd25519(public_b64: string): string;
20
+
21
+ export function ed25519FromDidKey(did: string): string;
22
+
23
+ export function ed25519Sign(seed_b64: string, message_b64: string): string;
24
+
25
+ export function ed25519Verify(public_b64: string, message_b64: string, signature_b64: string): boolean;
26
+
27
+ export function encodeEd25519Multikey(public_b64: string): string;
28
+
29
+ /**
30
+ * Generate an Ed25519 key pair. Returns {seed_b64, public_b64, multikey, did_key}.
31
+ */
32
+ export function generateEd25519(): string;
33
+
34
+ /**
35
+ * Generate an ML-DSA-44 key pair. Returns {secret_b64, public_b64}.
36
+ */
37
+ export function generateMldsa44(): string;
38
+
39
+ export function mldsa44Sign(secret_b64: string, public_b64: string, message_b64: string): string;
40
+
41
+ export function mldsa44Verify(public_b64: string, message_b64: string, signature_b64: string): boolean;
42
+
43
+ export function signCredential(credential_json: string, seed_b64: string, verification_method: string, created: string): string;
44
+
45
+ /**
46
+ * Build a dual proof (Ed25519 + ML-DSA-44) and attach it to the credential.
47
+ */
48
+ export function signDual(credential_json: string, ed25519_seed_b64: string, mldsa_secret_b64: string, mldsa_public_b64: string, ed25519_vm: string, mldsa_vm: string, created: string): string;
49
+
50
+ /**
51
+ * Validate the time-bound rule over a delegation chain (JSON array of links).
52
+ */
53
+ export function verifyChainTimeBound(chain_json: string, now_iso: string, clock_skew_seconds: number): boolean;
54
+
55
+ export function verifyComposite(credential_json: string, ed25519_public_b64: string, mldsa_public_b64: string): boolean;
56
+
57
+ export function verifyCredential(credential_json: string, public_b64: string, now_iso: string, clock_skew_seconds: number): string;
58
+
59
+ export function verifyDual(credential_json: string, ed25519_public_b64: string, mldsa_public_b64: string): boolean;
60
+
61
+ export function verifyProof(credential_json: string, public_b64: string): boolean;
62
+
63
+ export function verifyStatus(credential_status_json: string, status_list_credential_json: string): boolean;
64
+
65
+ /**
66
+ * Library version (matches the crate version).
67
+ */
68
+ export function version(): string;
69
+
70
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
71
+
72
+ export interface InitOutput {
73
+ readonly memory: WebAssembly.Memory;
74
+ readonly buildDelegationLink: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
75
+ readonly buildProof: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
76
+ readonly canonicalize: (a: number, b: number, c: number) => void;
77
+ readonly decodeMultikey: (a: number, b: number, c: number) => void;
78
+ readonly didKeyFromEd25519: (a: number, b: number, c: number) => void;
79
+ readonly ed25519FromDidKey: (a: number, b: number, c: number) => void;
80
+ readonly ed25519Sign: (a: number, b: number, c: number, d: number, e: number) => void;
81
+ readonly ed25519Verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
82
+ readonly encodeEd25519Multikey: (a: number, b: number, c: number) => void;
83
+ readonly generateEd25519: (a: number) => void;
84
+ readonly generateMldsa44: (a: number) => void;
85
+ readonly mldsa44Sign: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
86
+ readonly mldsa44Verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
87
+ readonly signCredential: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
88
+ readonly signDual: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => void;
89
+ readonly verifyChainTimeBound: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
90
+ readonly verifyComposite: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
91
+ readonly verifyCredential: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
92
+ readonly verifyDual: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
93
+ readonly verifyProof: (a: number, b: number, c: number, d: number, e: number) => void;
94
+ readonly verifyStatus: (a: number, b: number, c: number, d: number, e: number) => void;
95
+ readonly version: (a: number) => void;
96
+ readonly __wbindgen_export: (a: number) => void;
97
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
98
+ readonly __wbindgen_export2: (a: number, b: number) => number;
99
+ readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
100
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
101
+ }
102
+
103
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
104
+
105
+ /**
106
+ * Instantiates the given `module`, which can either be bytes or
107
+ * a precompiled `WebAssembly.Module`.
108
+ *
109
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
110
+ *
111
+ * @returns {InitOutput}
112
+ */
113
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
114
+
115
+ /**
116
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
117
+ * for everything else, calls `WebAssembly.instantiate` directly.
118
+ *
119
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
120
+ *
121
+ * @returns {Promise<InitOutput>}
122
+ */
123
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;