@coordination-network/zk-artifacts 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +122 -0
- package/credential/circuit.json +1 -0
- package/credential/vk +0 -0
- package/dist/browser.js +31 -0
- package/dist/index.cjs +40 -0
- package/dist/index.js +34 -0
- package/package.json +81 -0
- package/src/browser.ts +37 -0
- package/src/index.ts +39 -0
- package/src/types.ts +23 -0
- package/types/browser.d.ts +30 -0
- package/types/index.d.ts +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ethereum Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# zk-artifacts
|
|
2
|
+
|
|
3
|
+
The compiled zero-knowledge artifacts for the coordination network. The Noir
|
|
4
|
+
sources that produce them live in
|
|
5
|
+
[`@coordination-network/circuits`](../circuits); this package exists so an
|
|
6
|
+
application can prove and verify without installing nargo or barretenberg.
|
|
7
|
+
|
|
8
|
+
## Contents
|
|
9
|
+
|
|
10
|
+
| File | What it is |
|
|
11
|
+
| ------------------------- | ----------------------------------------------------------------------------------- |
|
|
12
|
+
| `credential/circuit.json` | The credential circuit's ACIR bytecode, ABI and debug symbols, from `nargo compile` |
|
|
13
|
+
| `credential/vk` | Its UltraHonk verification key, in barretenberg's binary encoding |
|
|
14
|
+
|
|
15
|
+
`bb write_vk` can also emit the key as a JSON array of field elements, and a
|
|
16
|
+
`vk_hash` beside it. Neither is published: `UltraHonkVerifierBackend.verifyProof`
|
|
17
|
+
takes the key as a `Uint8Array`, so the binary `vk` is the only form anything on
|
|
18
|
+
the verification path reads, and its hash is already derivable from it.
|
|
19
|
+
|
|
20
|
+
## Loading them
|
|
21
|
+
|
|
22
|
+
Reading a packaged file means `fs` on a server and `fetch` in a browser, so the
|
|
23
|
+
package ships an entry point for each. Both expose the same loaders, and neither
|
|
24
|
+
parses an artifact until you ask for it. The circuit, at two megabytes, stays a
|
|
25
|
+
separate file your runtime reads or fetches. The verification key is small
|
|
26
|
+
enough that a bundler may inline it as a `data:` URL instead, which `fetch`
|
|
27
|
+
handles the same way; raise `assetsInlineLimit` past 3680 bytes if you would
|
|
28
|
+
rather it stayed a file.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { getCredentialCircuit, getCredentialVerificationKey } from "@coordination-network/zk-artifacts"
|
|
32
|
+
|
|
33
|
+
const circuit = await getCredentialCircuit() // CredentialCircuit
|
|
34
|
+
const vk = await getCredentialVerificationKey() // Uint8Array
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
A bundler picks the browser build through the `browser` export condition. Import
|
|
38
|
+
`@coordination-network/zk-artifacts/browser` to ask for it outright, which is
|
|
39
|
+
worth doing in a file that only ever runs in a worker or a page.
|
|
40
|
+
|
|
41
|
+
| Export | Node | Browser | Returns |
|
|
42
|
+
| ---------------------------------- | ---- | ------- | ------------------------------------------------------------------------------ |
|
|
43
|
+
| `getCredentialCircuit()` | ✓ | ✓ | `Promise<CredentialCircuit>` |
|
|
44
|
+
| `getCredentialVerificationKey()` | ✓ | ✓ | `Promise<Uint8Array>` |
|
|
45
|
+
| `credentialArtifactUrl(artifact)` | ✓ | ✓ | `URL`, a `file:` one on Node and the bundler's asset URL in a browser |
|
|
46
|
+
| `credentialArtifactPath(artifact)` | ✓ | no | `string`, an absolute path, for callers that take one rather than the contents |
|
|
47
|
+
|
|
48
|
+
The browser build has no `credentialArtifactPath`: there is no filesystem to
|
|
49
|
+
point at, so use `credentialArtifactUrl` there instead.
|
|
50
|
+
|
|
51
|
+
`CredentialCircuit` is noir_js's `CompiledCircuit` plus the `noir_version` and
|
|
52
|
+
`hash` nargo records but noir_js does not model, so a caller can see which
|
|
53
|
+
compiler produced the artifact it is proving against. `artifact` is
|
|
54
|
+
`"circuit.json"` or `"vk"`. The raw files also stay addressable as
|
|
55
|
+
`@coordination-network/zk-artifacts/credential/circuit.json` and
|
|
56
|
+
`.../credential/vk` for tooling that wants to resolve them itself.
|
|
57
|
+
|
|
58
|
+
`@coordination-network/credential` consumes the circuit as its
|
|
59
|
+
`ZkCredentialCircuit`. It builds its backend with `new UltraHonkBackend(bytecode)`,
|
|
60
|
+
which derives the verification key from the bytecode on every run, so nothing in
|
|
61
|
+
this repository reads `vk` yet. It is published for verifiers that would rather
|
|
62
|
+
pin the circuit's identity than recompute it from 1.8MB of bytecode.
|
|
63
|
+
|
|
64
|
+
## Regenerating
|
|
65
|
+
|
|
66
|
+
The artifacts are committed. The release workflow publishes with Node alone, so
|
|
67
|
+
nothing in CI can rebuild them, and pinning them keeps every consumer proving
|
|
68
|
+
against the same circuit the maintainers verified.
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
yarn sync:zk-artifacts
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
That runs `scripts/sync.ts`, which compiles `packages/circuits`, copies the
|
|
75
|
+
result here, writes the verification key, and checks `bb --version` and the
|
|
76
|
+
compiled circuit's `noir_version` against the `@aztec/bb.js` and
|
|
77
|
+
`@noir-lang/noir_js` versions `@coordination-network/credential` pins. A
|
|
78
|
+
mismatched pair fails inside barretenberg's deserializer at proving time rather
|
|
79
|
+
than here, so the check refuses to ship one.
|
|
80
|
+
|
|
81
|
+
nargo records an absolute path for every source file it reads. The script
|
|
82
|
+
rewrites those to be relative to the repository and to `~/nargo`, which keeps
|
|
83
|
+
the debug call stacks working, keeps the maintainer's home directory out of a
|
|
84
|
+
published package, and makes the artifact byte-identical across machines.
|
|
85
|
+
|
|
86
|
+
Run it, and commit the result, whenever the circuit or the toolchain changes.
|
|
87
|
+
|
|
88
|
+
## Verifying
|
|
89
|
+
|
|
90
|
+
Regenerating the artifacts from the circuit should reproduce exactly what is
|
|
91
|
+
published here. This needs the pinned toolchain, nargo 1.0.0-beta.22 and bb
|
|
92
|
+
5.0.0: a different nargo compiles different bytecode, and a different bb writes
|
|
93
|
+
a different key from the very same circuit.
|
|
94
|
+
|
|
95
|
+
`credential/vk` must come out byte-identical, and so must
|
|
96
|
+
`credential/circuit.json` apart from one thing: the `path` values inside
|
|
97
|
+
`file_map`, which nargo records as each file's location on the machine that
|
|
98
|
+
compiled it and the published copy carries relative to the repository.
|
|
99
|
+
Everything else matches, `bytecode` and `abi` included.
|
|
100
|
+
|
|
101
|
+
How you check that depends on how you regenerated. `yarn sync:zk-artifacts`
|
|
102
|
+
overwrites this package's own `packages/zk-artifacts/credential/`, so git is
|
|
103
|
+
the comparison: a clean `git diff -- credential` means both artifacts came
|
|
104
|
+
out identical, `file_map` paths included, since the script rewrites those
|
|
105
|
+
itself.
|
|
106
|
+
|
|
107
|
+
Running nargo and bb yourself leaves the output somewhere else, and sha256 is
|
|
108
|
+
a short way to compare the two copies. Each pair below has to print the same
|
|
109
|
+
digest. `shasum -a 256`, or `sha256sum` on Linux, over the key on each side:
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
shasum -a 256 credential/vk /path/to/your/vk
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The circuit needs its `path` values dropped first. Run `jq` over both copies
|
|
116
|
+
and compare the two outputs, never an output against a raw file: `jq` reprints
|
|
117
|
+
the JSON in its own formatting, which changes the hash on its own.
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
jq -cS 'del(.file_map[].path)' credential/circuit.json | shasum -a 256
|
|
121
|
+
jq -cS 'del(.file_map[].path)' ../circuits/target/credential.json | shasum -a 256
|
|
122
|
+
```
|