@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/credential/vk
ADDED
|
Binary file
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Vite and webpack only rewrite `new URL(<string literal>, import.meta.url)`, so each
|
|
2
|
+
// artifact needs its own literal: build one from a variable and the bundler emits no
|
|
3
|
+
// asset and the URL is wrong at runtime.
|
|
4
|
+
const URLS = {
|
|
5
|
+
"circuit.json": new URL("../credential/circuit.json", import.meta.url),
|
|
6
|
+
vk: new URL("../credential/vk", import.meta.url)
|
|
7
|
+
};
|
|
8
|
+
/** Where the bundler placed `artifact`. */
|
|
9
|
+
function credentialArtifactUrl(artifact) {
|
|
10
|
+
return new URL(URLS[artifact]);
|
|
11
|
+
}
|
|
12
|
+
const fetchArtifact = async (artifact) => {
|
|
13
|
+
const response = await fetch(URLS[artifact]);
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new Error(`failed to fetch ${artifact}: ${response.status} ${response.statusText}`);
|
|
16
|
+
}
|
|
17
|
+
return response;
|
|
18
|
+
};
|
|
19
|
+
/** Fetches the compiled credential circuit. */
|
|
20
|
+
async function getCredentialCircuit() {
|
|
21
|
+
return (await (await fetchArtifact("circuit.json")).json());
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fetches the credential circuit's UltraHonk verification key, in the binary encoding
|
|
25
|
+
* `UltraHonkVerifierBackend.verifyProof` takes.
|
|
26
|
+
*/
|
|
27
|
+
async function getCredentialVerificationKey() {
|
|
28
|
+
return new Uint8Array(await (await fetchArtifact("vk")).arrayBuffer());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { credentialArtifactUrl, getCredentialCircuit, getCredentialVerificationKey };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var promises = require('node:fs/promises');
|
|
4
|
+
var node_url = require('node:url');
|
|
5
|
+
|
|
6
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
|
+
// Written as separate literals rather than a template so a bundler that resolves this
|
|
8
|
+
// entry can still see which files are referenced. The URLs are relative to the built
|
|
9
|
+
// module in `dist/`, which sits at the same depth as `src/`, so both resolve alike.
|
|
10
|
+
const URLS = {
|
|
11
|
+
"circuit.json": new URL("../credential/circuit.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),
|
|
12
|
+
vk: new URL("../credential/vk", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))
|
|
13
|
+
};
|
|
14
|
+
/** Where this package keeps `artifact`, as a `file:` URL. */
|
|
15
|
+
function credentialArtifactUrl(artifact) {
|
|
16
|
+
return new URL(URLS[artifact]);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Where this package keeps `artifact`, as an absolute path, for callers that take a
|
|
20
|
+
* path rather than the file's contents.
|
|
21
|
+
*/
|
|
22
|
+
function credentialArtifactPath(artifact) {
|
|
23
|
+
return node_url.fileURLToPath(URLS[artifact]);
|
|
24
|
+
}
|
|
25
|
+
/** Reads the compiled credential circuit. */
|
|
26
|
+
async function getCredentialCircuit() {
|
|
27
|
+
return JSON.parse(await promises.readFile(URLS["circuit.json"], "utf8"));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reads the credential circuit's UltraHonk verification key, in the binary encoding
|
|
31
|
+
* `UltraHonkVerifierBackend.verifyProof` takes.
|
|
32
|
+
*/
|
|
33
|
+
async function getCredentialVerificationKey() {
|
|
34
|
+
return new Uint8Array(await promises.readFile(URLS.vk));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.credentialArtifactPath = credentialArtifactPath;
|
|
38
|
+
exports.credentialArtifactUrl = credentialArtifactUrl;
|
|
39
|
+
exports.getCredentialCircuit = getCredentialCircuit;
|
|
40
|
+
exports.getCredentialVerificationKey = getCredentialVerificationKey;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
// Written as separate literals rather than a template so a bundler that resolves this
|
|
5
|
+
// entry can still see which files are referenced. The URLs are relative to the built
|
|
6
|
+
// module in `dist/`, which sits at the same depth as `src/`, so both resolve alike.
|
|
7
|
+
const URLS = {
|
|
8
|
+
"circuit.json": new URL("../credential/circuit.json", import.meta.url),
|
|
9
|
+
vk: new URL("../credential/vk", import.meta.url)
|
|
10
|
+
};
|
|
11
|
+
/** Where this package keeps `artifact`, as a `file:` URL. */
|
|
12
|
+
function credentialArtifactUrl(artifact) {
|
|
13
|
+
return new URL(URLS[artifact]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Where this package keeps `artifact`, as an absolute path, for callers that take a
|
|
17
|
+
* path rather than the file's contents.
|
|
18
|
+
*/
|
|
19
|
+
function credentialArtifactPath(artifact) {
|
|
20
|
+
return fileURLToPath(URLS[artifact]);
|
|
21
|
+
}
|
|
22
|
+
/** Reads the compiled credential circuit. */
|
|
23
|
+
async function getCredentialCircuit() {
|
|
24
|
+
return JSON.parse(await readFile(URLS["circuit.json"], "utf8"));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Reads the credential circuit's UltraHonk verification key, in the binary encoding
|
|
28
|
+
* `UltraHonkVerifierBackend.verifyProof` takes.
|
|
29
|
+
*/
|
|
30
|
+
async function getCredentialVerificationKey() {
|
|
31
|
+
return new Uint8Array(await readFile(URLS.vk));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { credentialArtifactPath, credentialArtifactUrl, getCredentialCircuit, getCredentialVerificationKey };
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@coordination-network/zk-artifacts",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Compiled zero-knowledge artifacts for the coordination network: the credential circuit's ACIR bytecode and ABI, and its Barretenberg UltraHonk verification key.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/zk-kit/coordination-network.git",
|
|
9
|
+
"directory": "packages/zk-artifacts"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/zk-kit/coordination-network/tree/main/packages/zk-artifacts",
|
|
12
|
+
"bugs": "https://github.com/zk-kit/coordination-network/issues",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/index.cjs",
|
|
16
|
+
"module": "dist/index.js",
|
|
17
|
+
"types": "types/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"browser": {
|
|
21
|
+
"types": "./types/browser.d.ts",
|
|
22
|
+
"default": "./dist/browser.js"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./types/index.d.ts",
|
|
26
|
+
"default": "./dist/index.cjs"
|
|
27
|
+
},
|
|
28
|
+
"default": {
|
|
29
|
+
"types": "./types/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"./browser": {
|
|
34
|
+
"types": "./types/browser.d.ts",
|
|
35
|
+
"default": "./dist/browser.js"
|
|
36
|
+
},
|
|
37
|
+
"./credential/circuit.json": "./credential/circuit.json",
|
|
38
|
+
"./credential/vk": "./credential/vk",
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"credential/",
|
|
43
|
+
"dist/",
|
|
44
|
+
"types/",
|
|
45
|
+
"src/",
|
|
46
|
+
"README.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"keywords": [
|
|
50
|
+
"noir",
|
|
51
|
+
"barretenberg",
|
|
52
|
+
"ultrahonk",
|
|
53
|
+
"zero-knowledge",
|
|
54
|
+
"circuit",
|
|
55
|
+
"verification-key",
|
|
56
|
+
"verifiable-credentials"
|
|
57
|
+
],
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"@noir-lang/noir_js": "1.0.0-beta.22"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "rimraf dist types && rollup -c rollup.config.mjs",
|
|
66
|
+
"sync": "tsx scripts/sync.ts",
|
|
67
|
+
"test": "tsc --noEmit && tsx --test tests/*.test.ts"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@noir-lang/noir_js": "1.0.0-beta.22",
|
|
71
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
72
|
+
"@types/node": "^24.0.0",
|
|
73
|
+
"rimraf": "^6.1.3",
|
|
74
|
+
"rollup": "^4.62.2",
|
|
75
|
+
"rollup-plugin-cleanup": "^3.2.1",
|
|
76
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
77
|
+
"tslib": "^2.8.0",
|
|
78
|
+
"tsx": "^4.23.0",
|
|
79
|
+
"typescript": "^6.0.3"
|
|
80
|
+
}
|
|
81
|
+
}
|
package/src/browser.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CompiledCircuit, CredentialArtifact, CredentialCircuit } from "./types"
|
|
2
|
+
|
|
3
|
+
export type { CompiledCircuit, CredentialArtifact, CredentialCircuit }
|
|
4
|
+
|
|
5
|
+
// Vite and webpack only rewrite `new URL(<string literal>, import.meta.url)`, so each
|
|
6
|
+
// artifact needs its own literal: build one from a variable and the bundler emits no
|
|
7
|
+
// asset and the URL is wrong at runtime.
|
|
8
|
+
const URLS: Record<CredentialArtifact, URL> = {
|
|
9
|
+
"circuit.json": new URL("../credential/circuit.json", import.meta.url),
|
|
10
|
+
vk: new URL("../credential/vk", import.meta.url)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Where the bundler placed `artifact`. */
|
|
14
|
+
export function credentialArtifactUrl(artifact: CredentialArtifact): URL {
|
|
15
|
+
return new URL(URLS[artifact])
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const fetchArtifact = async (artifact: CredentialArtifact): Promise<Response> => {
|
|
19
|
+
const response = await fetch(URLS[artifact])
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
throw new Error(`failed to fetch ${artifact}: ${response.status} ${response.statusText}`)
|
|
22
|
+
}
|
|
23
|
+
return response
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Fetches the compiled credential circuit. */
|
|
27
|
+
export async function getCredentialCircuit(): Promise<CredentialCircuit> {
|
|
28
|
+
return (await (await fetchArtifact("circuit.json")).json()) as CredentialCircuit
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Fetches the credential circuit's UltraHonk verification key, in the binary encoding
|
|
33
|
+
* `UltraHonkVerifierBackend.verifyProof` takes.
|
|
34
|
+
*/
|
|
35
|
+
export async function getCredentialVerificationKey(): Promise<Uint8Array> {
|
|
36
|
+
return new Uint8Array(await (await fetchArtifact("vk")).arrayBuffer())
|
|
37
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises"
|
|
2
|
+
import { fileURLToPath } from "node:url"
|
|
3
|
+
import type { CompiledCircuit, CredentialArtifact, CredentialCircuit } from "./types"
|
|
4
|
+
|
|
5
|
+
export type { CompiledCircuit, CredentialArtifact, CredentialCircuit }
|
|
6
|
+
|
|
7
|
+
// Written as separate literals rather than a template so a bundler that resolves this
|
|
8
|
+
// entry can still see which files are referenced. The URLs are relative to the built
|
|
9
|
+
// module in `dist/`, which sits at the same depth as `src/`, so both resolve alike.
|
|
10
|
+
const URLS: Record<CredentialArtifact, URL> = {
|
|
11
|
+
"circuit.json": new URL("../credential/circuit.json", import.meta.url),
|
|
12
|
+
vk: new URL("../credential/vk", import.meta.url)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Where this package keeps `artifact`, as a `file:` URL. */
|
|
16
|
+
export function credentialArtifactUrl(artifact: CredentialArtifact): URL {
|
|
17
|
+
return new URL(URLS[artifact])
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Where this package keeps `artifact`, as an absolute path, for callers that take a
|
|
22
|
+
* path rather than the file's contents.
|
|
23
|
+
*/
|
|
24
|
+
export function credentialArtifactPath(artifact: CredentialArtifact): string {
|
|
25
|
+
return fileURLToPath(URLS[artifact])
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Reads the compiled credential circuit. */
|
|
29
|
+
export async function getCredentialCircuit(): Promise<CredentialCircuit> {
|
|
30
|
+
return JSON.parse(await readFile(URLS["circuit.json"], "utf8")) as CredentialCircuit
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Reads the credential circuit's UltraHonk verification key, in the binary encoding
|
|
35
|
+
* `UltraHonkVerifierBackend.verifyProof` takes.
|
|
36
|
+
*/
|
|
37
|
+
export async function getCredentialVerificationKey(): Promise<Uint8Array> {
|
|
38
|
+
return new Uint8Array(await readFile(URLS.vk))
|
|
39
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CompiledCircuit } from "@noir-lang/noir_js"
|
|
2
|
+
|
|
3
|
+
/** The files this package publishes for the credential circuit. */
|
|
4
|
+
export type CredentialArtifact = "circuit.json" | "vk"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What nargo actually writes. `CompiledCircuit` covers the four fields
|
|
8
|
+
* `@noir-lang/noir_js` consumes; these two record which compiler produced the
|
|
9
|
+
* artifact and the program hash it settled on, and are the only provenance the
|
|
10
|
+
* package carries.
|
|
11
|
+
*/
|
|
12
|
+
export type CredentialCircuit = CompiledCircuit & {
|
|
13
|
+
/** The nargo release that compiled it, as `1.0.0-beta.22+<commit>`. */
|
|
14
|
+
readonly noir_version: string
|
|
15
|
+
/** nargo's own hash of the compiled program, a u64 serialised as a string. */
|
|
16
|
+
readonly hash: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The compiled credential circuit, as `@noir-lang/noir_js` and
|
|
21
|
+
* `@coordination-network/credential` consume it.
|
|
22
|
+
*/
|
|
23
|
+
export type { CompiledCircuit }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CompiledCircuit } from '@noir-lang/noir_js';
|
|
2
|
+
export { CompiledCircuit } from '@noir-lang/noir_js';
|
|
3
|
+
|
|
4
|
+
/** The files this package publishes for the credential circuit. */
|
|
5
|
+
type CredentialArtifact = "circuit.json" | "vk";
|
|
6
|
+
/**
|
|
7
|
+
* What nargo actually writes. `CompiledCircuit` covers the four fields
|
|
8
|
+
* `@noir-lang/noir_js` consumes; these two record which compiler produced the
|
|
9
|
+
* artifact and the program hash it settled on, and are the only provenance the
|
|
10
|
+
* package carries.
|
|
11
|
+
*/
|
|
12
|
+
type CredentialCircuit = CompiledCircuit & {
|
|
13
|
+
/** The nargo release that compiled it, as `1.0.0-beta.22+<commit>`. */
|
|
14
|
+
readonly noir_version: string;
|
|
15
|
+
/** nargo's own hash of the compiled program, a u64 serialised as a string. */
|
|
16
|
+
readonly hash: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Where the bundler placed `artifact`. */
|
|
20
|
+
declare function credentialArtifactUrl(artifact: CredentialArtifact): URL;
|
|
21
|
+
/** Fetches the compiled credential circuit. */
|
|
22
|
+
declare function getCredentialCircuit(): Promise<CredentialCircuit>;
|
|
23
|
+
/**
|
|
24
|
+
* Fetches the credential circuit's UltraHonk verification key, in the binary encoding
|
|
25
|
+
* `UltraHonkVerifierBackend.verifyProof` takes.
|
|
26
|
+
*/
|
|
27
|
+
declare function getCredentialVerificationKey(): Promise<Uint8Array>;
|
|
28
|
+
|
|
29
|
+
export { credentialArtifactUrl, getCredentialCircuit, getCredentialVerificationKey };
|
|
30
|
+
export type { CredentialArtifact, CredentialCircuit };
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CompiledCircuit } from '@noir-lang/noir_js';
|
|
2
|
+
export { CompiledCircuit } from '@noir-lang/noir_js';
|
|
3
|
+
|
|
4
|
+
/** The files this package publishes for the credential circuit. */
|
|
5
|
+
type CredentialArtifact = "circuit.json" | "vk";
|
|
6
|
+
/**
|
|
7
|
+
* What nargo actually writes. `CompiledCircuit` covers the four fields
|
|
8
|
+
* `@noir-lang/noir_js` consumes; these two record which compiler produced the
|
|
9
|
+
* artifact and the program hash it settled on, and are the only provenance the
|
|
10
|
+
* package carries.
|
|
11
|
+
*/
|
|
12
|
+
type CredentialCircuit = CompiledCircuit & {
|
|
13
|
+
/** The nargo release that compiled it, as `1.0.0-beta.22+<commit>`. */
|
|
14
|
+
readonly noir_version: string;
|
|
15
|
+
/** nargo's own hash of the compiled program, a u64 serialised as a string. */
|
|
16
|
+
readonly hash: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Where this package keeps `artifact`, as a `file:` URL. */
|
|
20
|
+
declare function credentialArtifactUrl(artifact: CredentialArtifact): URL;
|
|
21
|
+
/**
|
|
22
|
+
* Where this package keeps `artifact`, as an absolute path, for callers that take a
|
|
23
|
+
* path rather than the file's contents.
|
|
24
|
+
*/
|
|
25
|
+
declare function credentialArtifactPath(artifact: CredentialArtifact): string;
|
|
26
|
+
/** Reads the compiled credential circuit. */
|
|
27
|
+
declare function getCredentialCircuit(): Promise<CredentialCircuit>;
|
|
28
|
+
/**
|
|
29
|
+
* Reads the credential circuit's UltraHonk verification key, in the binary encoding
|
|
30
|
+
* `UltraHonkVerifierBackend.verifyProof` takes.
|
|
31
|
+
*/
|
|
32
|
+
declare function getCredentialVerificationKey(): Promise<Uint8Array>;
|
|
33
|
+
|
|
34
|
+
export { credentialArtifactPath, credentialArtifactUrl, getCredentialCircuit, getCredentialVerificationKey };
|
|
35
|
+
export type { CredentialArtifact, CredentialCircuit };
|