@fatsolutions/privacy-pools-core-circuits 1.0.3 → 1.0.5
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/dist/circuits.d.ts +33 -14
- package/dist/circuits.d.ts.map +1 -1
- package/dist/circuits.js +66 -62
- package/dist/circuits.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +15 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -9
- package/dist/types.js.map +1 -1
- package/package.json +27 -33
- package/CHANGELOG.md +0 -12
- package/README.md +0 -86
package/dist/circuits.d.ts
CHANGED
|
@@ -1,34 +1,53 @@
|
|
|
1
|
-
import { Binaries, CircuitArtifacts, CircuitNameString, CircuitsInterface, VersionString } from "./types.js";
|
|
1
|
+
import { Binaries, CircuitArtifacts, CircuitName, CircuitNameString, CircuitPaths, CircuitsInterface, VersionString } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default base URL for fetching circuit artifacts.
|
|
4
|
+
* Update this to point to the official hosted artifacts.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_ARTIFACTS_BASE_URL = "https://raw.githubusercontent.com/0xbow-io/privacy-pools-core/7bc392dad5fa483f53cf74e25d7ad19f0fc6d85f/packages/circuits";
|
|
2
7
|
interface CircuitOptions {
|
|
3
|
-
|
|
4
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Base URL for fetching circuit artifacts.
|
|
10
|
+
* Defaults to DEFAULT_ARTIFACTS_BASE_URL.
|
|
11
|
+
*/
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
[CircuitName.Withdraw]: CircuitPaths;
|
|
14
|
+
[CircuitName.Commitment]: CircuitPaths;
|
|
5
15
|
}
|
|
16
|
+
export declare const DefaultCircuitOptions: CircuitOptions;
|
|
6
17
|
export declare class Circuits implements CircuitsInterface {
|
|
7
|
-
|
|
18
|
+
readonly options: CircuitOptions;
|
|
8
19
|
protected version: VersionString;
|
|
9
|
-
protected binaries: Binaries
|
|
20
|
+
protected binaries: Partial<Binaries>;
|
|
10
21
|
protected baseUrl: string;
|
|
11
|
-
protected
|
|
22
|
+
protected deafultOptions: CircuitOptions;
|
|
12
23
|
constructor(options?: CircuitOptions);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Ensures a specific circuit's artifacts are loaded.
|
|
26
|
+
* Only fetches if not already cached.
|
|
27
|
+
*/
|
|
28
|
+
protected _ensureCircuitLoaded(circuitName: CircuitNameString): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Fetches a circuit artifact from the configured base URL.
|
|
31
|
+
*/
|
|
32
|
+
protected _fetchVersionedArtifact(artifactPath: string): Promise<Uint8Array>;
|
|
33
|
+
protected _downloadCircuitArtifacts(circuitName: CircuitNameString): Promise<CircuitArtifacts>;
|
|
18
34
|
downloadArtifacts(_version: VersionString): Promise<Binaries>;
|
|
19
35
|
initArtifacts(version: VersionString): Promise<void>;
|
|
20
36
|
/**
|
|
21
37
|
* Gets the verification key for a circuit.
|
|
38
|
+
* Lazily loads the circuit artifacts if not already cached.
|
|
22
39
|
*/
|
|
23
|
-
getVerificationKey(circuitName: CircuitNameString
|
|
40
|
+
getVerificationKey(circuitName: CircuitNameString): Promise<Uint8Array>;
|
|
24
41
|
/**
|
|
25
42
|
* Gets the proving key for a circuit.
|
|
43
|
+
* Lazily loads the circuit artifacts if not already cached.
|
|
26
44
|
*/
|
|
27
|
-
getProvingKey(circuitName: CircuitNameString
|
|
45
|
+
getProvingKey(circuitName: CircuitNameString): Promise<Uint8Array>;
|
|
28
46
|
/**
|
|
29
47
|
* Gets the WASM binary for a circuit.
|
|
48
|
+
* Lazily loads the circuit artifacts if not already cached.
|
|
30
49
|
*/
|
|
31
|
-
getWasm(circuitName: CircuitNameString
|
|
50
|
+
getWasm(circuitName: CircuitNameString): Promise<Uint8Array>;
|
|
32
51
|
}
|
|
33
52
|
export {};
|
|
34
53
|
//# sourceMappingURL=circuits.d.ts.map
|
package/dist/circuits.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circuits.d.ts","sourceRoot":"","sources":["../lib/circuits.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,gBAAgB,
|
|
1
|
+
{"version":3,"file":"circuits.d.ts","sourceRoot":"","sources":["../lib/circuits.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EAGjB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,eAAO,MAAM,0BAA0B,6HACqF,CAAC;AAE7H,UAAU,cAAc;IACtB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACrC,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC;CACxC;AAED,eAAO,MAAM,qBAAqB,EAAE,cAYnC,CAAC;AAEF,qBAAa,QAAS,YAAW,iBAAiB;IAMpC,QAAQ,CAAC,OAAO,EAAE,cAAc;IAL5C,SAAS,CAAC,OAAO,EAAE,aAAa,CAAkB;IAClD,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAM;IAC3C,SAAS,CAAC,OAAO,EAAE,MAAM,CAA8B;IACvD,SAAS,CAAC,cAAc,iBAAyB;gBAE5B,OAAO,GAAE,cAAsC;IAEpE;;;OAGG;cACa,oBAAoB,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAenF;;OAEG;cACa,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;cAUlE,yBAAyB,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAS9F,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQ7D,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1D;;;OAGG;IACG,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IAK7E;;;OAGG;IACG,aAAa,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IAKxE;;;OAGG;IACG,OAAO,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;CAInE"}
|
package/dist/circuits.js
CHANGED
|
@@ -1,55 +1,67 @@
|
|
|
1
1
|
import { CircuitInitialization, FetchArtifact } from "./errors.js";
|
|
2
|
-
import { CircuitName,
|
|
3
|
-
|
|
2
|
+
import { CircuitName, Version, } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Default base URL for fetching circuit artifacts.
|
|
5
|
+
* Update this to point to the official hosted artifacts.
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_ARTIFACTS_BASE_URL = "https://raw.githubusercontent.com/0xbow-io/privacy-pools-core/7bc392dad5fa483f53cf74e25d7ad19f0fc6d85f/packages/circuits";
|
|
8
|
+
export const DefaultCircuitOptions = {
|
|
9
|
+
baseUrl: DEFAULT_ARTIFACTS_BASE_URL,
|
|
10
|
+
[CircuitName.Withdraw]: {
|
|
11
|
+
wasm: "build/withdraw/withdraw_js/withdraw.wasm",
|
|
12
|
+
vkey: "trusted-setup/final-keys/withdraw.vkey",
|
|
13
|
+
zkey: "trusted-setup/final-keys/withdraw.zkey",
|
|
14
|
+
},
|
|
15
|
+
[CircuitName.Commitment]: {
|
|
16
|
+
wasm: "build/commitment/commitment_js/commitment.wasm",
|
|
17
|
+
vkey: "trusted-setup/final-keys/commitment.vkey",
|
|
18
|
+
zkey: "trusted-setup/final-keys/commitment.zkey",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
4
21
|
export class Circuits {
|
|
5
|
-
|
|
22
|
+
options;
|
|
6
23
|
version = Version.Latest;
|
|
7
|
-
binaries;
|
|
8
|
-
baseUrl =
|
|
9
|
-
|
|
10
|
-
constructor(options) {
|
|
11
|
-
|
|
12
|
-
|
|
24
|
+
binaries = {};
|
|
25
|
+
baseUrl = DEFAULT_ARTIFACTS_BASE_URL;
|
|
26
|
+
deafultOptions = DefaultCircuitOptions;
|
|
27
|
+
constructor(options = DefaultCircuitOptions) {
|
|
28
|
+
this.options = options;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Ensures a specific circuit's artifacts are loaded.
|
|
32
|
+
* Only fetches if not already cached.
|
|
33
|
+
*/
|
|
34
|
+
async _ensureCircuitLoaded(circuitName) {
|
|
35
|
+
if (this.binaries[circuitName]) {
|
|
36
|
+
return;
|
|
13
37
|
}
|
|
14
|
-
|
|
15
|
-
this.
|
|
38
|
+
try {
|
|
39
|
+
this.binaries[circuitName] = await this._downloadCircuitArtifacts(circuitName);
|
|
16
40
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
_initialize(binaries, version) {
|
|
22
|
-
this.binaries = binaries;
|
|
23
|
-
this.version = version;
|
|
24
|
-
this.initialized = true;
|
|
25
|
-
}
|
|
26
|
-
async _handleInitialization(version = Version.Latest) {
|
|
27
|
-
if (!this.initialized || this.binaries === undefined) {
|
|
28
|
-
try {
|
|
29
|
-
await this.initArtifacts(version);
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
if (e instanceof FetchArtifact) {
|
|
33
|
-
throw new CircuitInitialization(`${e.name}: ${e.message}`);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
console.error(e);
|
|
37
|
-
throw new CircuitInitialization(`UnknownError: ${e}`);
|
|
38
|
-
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
if (e instanceof FetchArtifact) {
|
|
43
|
+
throw new CircuitInitialization(`${e.name}: ${e.message}`);
|
|
39
44
|
}
|
|
45
|
+
throw new CircuitInitialization(`UnknownError: ${e}`);
|
|
40
46
|
}
|
|
41
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Fetches a circuit artifact from the configured base URL.
|
|
50
|
+
*/
|
|
42
51
|
async _fetchVersionedArtifact(artifactPath) {
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
52
|
+
const baseUrl = this.options.baseUrl.endsWith("/") ? this.options.baseUrl : this.options.baseUrl + "/";
|
|
53
|
+
const artifactUrl = new URL(artifactPath, baseUrl);
|
|
54
|
+
const res = await fetch(artifactUrl);
|
|
55
|
+
if (res.status !== 200) {
|
|
56
|
+
throw new FetchArtifact(artifactUrl);
|
|
57
|
+
}
|
|
58
|
+
return new Uint8Array(await res.arrayBuffer());
|
|
46
59
|
}
|
|
47
60
|
async _downloadCircuitArtifacts(circuitName) {
|
|
48
|
-
const assetName = circuitToAsset[circuitName];
|
|
49
61
|
const [wasm, vkey, zkey] = await Promise.all([
|
|
50
|
-
this._fetchVersionedArtifact([
|
|
51
|
-
this._fetchVersionedArtifact([
|
|
52
|
-
this._fetchVersionedArtifact([
|
|
62
|
+
this._fetchVersionedArtifact(this.options[circuitName].wasm),
|
|
63
|
+
this._fetchVersionedArtifact(this.options[circuitName].vkey),
|
|
64
|
+
this._fetchVersionedArtifact(this.options[circuitName].zkey),
|
|
53
65
|
]);
|
|
54
66
|
return { wasm, vkey, zkey };
|
|
55
67
|
}
|
|
@@ -62,40 +74,32 @@ export class Circuits {
|
|
|
62
74
|
}
|
|
63
75
|
async initArtifacts(version) {
|
|
64
76
|
const binaries = await this.downloadArtifacts(version);
|
|
65
|
-
this.
|
|
77
|
+
this.binaries = binaries;
|
|
78
|
+
this.version = version;
|
|
66
79
|
}
|
|
67
80
|
/**
|
|
68
81
|
* Gets the verification key for a circuit.
|
|
82
|
+
* Lazily loads the circuit artifacts if not already cached.
|
|
69
83
|
*/
|
|
70
|
-
async getVerificationKey(circuitName
|
|
71
|
-
await this.
|
|
72
|
-
|
|
73
|
-
if (!artifacts) {
|
|
74
|
-
throw new CircuitInitialization(`Circuit artifacts not found for ${circuitName}`);
|
|
75
|
-
}
|
|
76
|
-
return artifacts.vkey;
|
|
84
|
+
async getVerificationKey(circuitName) {
|
|
85
|
+
await this._ensureCircuitLoaded(circuitName);
|
|
86
|
+
return this.binaries[circuitName].vkey;
|
|
77
87
|
}
|
|
78
88
|
/**
|
|
79
89
|
* Gets the proving key for a circuit.
|
|
90
|
+
* Lazily loads the circuit artifacts if not already cached.
|
|
80
91
|
*/
|
|
81
|
-
async getProvingKey(circuitName
|
|
82
|
-
await this.
|
|
83
|
-
|
|
84
|
-
if (!artifacts) {
|
|
85
|
-
throw new CircuitInitialization(`Circuit artifacts not found for ${circuitName}`);
|
|
86
|
-
}
|
|
87
|
-
return artifacts.zkey;
|
|
92
|
+
async getProvingKey(circuitName) {
|
|
93
|
+
await this._ensureCircuitLoaded(circuitName);
|
|
94
|
+
return this.binaries[circuitName].zkey;
|
|
88
95
|
}
|
|
89
96
|
/**
|
|
90
97
|
* Gets the WASM binary for a circuit.
|
|
98
|
+
* Lazily loads the circuit artifacts if not already cached.
|
|
91
99
|
*/
|
|
92
|
-
async getWasm(circuitName
|
|
93
|
-
await this.
|
|
94
|
-
|
|
95
|
-
if (!artifacts) {
|
|
96
|
-
throw new CircuitInitialization(`Circuit artifacts not found for ${circuitName}`);
|
|
97
|
-
}
|
|
98
|
-
return artifacts.wasm;
|
|
100
|
+
async getWasm(circuitName) {
|
|
101
|
+
await this._ensureCircuitLoaded(circuitName);
|
|
102
|
+
return this.binaries[circuitName].wasm;
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
//# sourceMappingURL=circuits.js.map
|
package/dist/circuits.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circuits.js","sourceRoot":"","sources":["../lib/circuits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAGL,WAAW,
|
|
1
|
+
{"version":3,"file":"circuits.js","sourceRoot":"","sources":["../lib/circuits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAGL,WAAW,EAKX,OAAO,GAER,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACrC,0HAA0H,CAAC;AAY7H,MAAM,CAAC,MAAM,qBAAqB,GAAmB;IACnD,OAAO,EAAE,0BAA0B;IACnC,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;QACtB,IAAI,EAAE,0CAA0C;QAChD,IAAI,EAAE,wCAAwC;QAC9C,IAAI,EAAE,wCAAwC;KAC/C;IACD,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE;QACxB,IAAI,EAAE,gDAAgD;QACtD,IAAI,EAAE,0CAA0C;QAChD,IAAI,EAAE,0CAA0C;KACjD;CACF,CAAC;AAEF,MAAM,OAAO,QAAQ;IAME;IALX,OAAO,GAAkB,OAAO,CAAC,MAAM,CAAC;IACxC,QAAQ,GAAsB,EAAE,CAAC;IACjC,OAAO,GAAW,0BAA0B,CAAC;IAC7C,cAAc,GAAG,qBAAqB,CAAC;IAEjD,YAAqB,UAA0B,qBAAqB;QAA/C,YAAO,GAAP,OAAO,CAAwC;IAAG,CAAC;IAExE;;;OAGG;IACO,KAAK,CAAC,oBAAoB,CAAC,WAA8B;QACjE,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC;QACjF,CAAC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/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AACrE,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AACrE,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,13 +14,12 @@ export interface CircuitArtifacts {
|
|
|
14
14
|
vkey: Uint8Array;
|
|
15
15
|
zkey: Uint8Array;
|
|
16
16
|
}
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
17
|
+
export interface CircuitPaths {
|
|
18
|
+
wasm: string;
|
|
19
|
+
vkey: string;
|
|
20
|
+
zkey: string;
|
|
21
|
+
}
|
|
22
|
+
export type Circ2Asset = Record<CircuitName, CircuitPaths>;
|
|
24
23
|
export declare const circuitToAsset: Circ2Asset;
|
|
25
24
|
export interface Binaries {
|
|
26
25
|
commitment: CircuitArtifacts;
|
|
@@ -50,10 +49,10 @@ export type WithdrawInputSignals = {
|
|
|
50
49
|
readonly ASPSiblings: bigint[];
|
|
51
50
|
readonly ASPIndex: bigint;
|
|
52
51
|
};
|
|
53
|
-
export
|
|
52
|
+
export interface CircuitInputSignalsMap {
|
|
54
53
|
[CircuitName.Commitment]: CommitmentInputSignals;
|
|
55
54
|
[CircuitName.Withdraw]: WithdrawInputSignals;
|
|
56
|
-
}
|
|
55
|
+
}
|
|
57
56
|
export type WithdrawPublicInputSignals = "withdrawnValue" | "stateRoot" | "stateTreeDepth" | "ASPRoot" | "ASPTreeDepth" | "context";
|
|
58
57
|
export type WithdrawPublicSignals = {
|
|
59
58
|
readonly newCommitmentHash: bigint;
|
|
@@ -64,28 +63,28 @@ export type CommitmentPublicSignals = {
|
|
|
64
63
|
readonly commitment: bigint;
|
|
65
64
|
readonly nullifierHash: bigint;
|
|
66
65
|
} & Pick<CommitmentInputSignals, CommitmentPublicInputSignals>;
|
|
67
|
-
export
|
|
66
|
+
export interface CircuitPublicSignalsMap {
|
|
68
67
|
[CircuitName.Commitment]: CommitmentPublicSignals;
|
|
69
68
|
[CircuitName.Withdraw]: WithdrawPublicSignals;
|
|
70
|
-
}
|
|
69
|
+
}
|
|
71
70
|
export declare function CommitmentSignalMapper(publicSignals: (string | bigint)[]): CommitmentPublicSignals;
|
|
72
71
|
export declare function WithdrawSignalMapper(publicSignals: (string | bigint)[]): WithdrawPublicSignals;
|
|
73
72
|
export type WithdrawPublicSignalsStringArray = [string, string, string, string, string, string, string, string];
|
|
74
73
|
export declare function withdrawObjectToCircuitBus(signals: WithdrawPublicSignals): WithdrawPublicSignalsStringArray;
|
|
75
74
|
export type CommitmentPublicSignalsStringArray = [string, string, string, string];
|
|
76
75
|
export declare function commitmentObjectToCircuitBus(signals: CommitmentPublicSignals): CommitmentPublicSignalsStringArray;
|
|
77
|
-
export
|
|
76
|
+
export interface ContractProof {
|
|
78
77
|
pA: readonly [bigint, bigint];
|
|
79
78
|
pB: readonly [readonly [bigint, bigint], readonly [bigint, bigint]];
|
|
80
79
|
pC: readonly [bigint, bigint];
|
|
81
80
|
pubSignals: readonly [bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint];
|
|
82
|
-
}
|
|
81
|
+
}
|
|
83
82
|
export declare function snarkjsProofToSolidityFormat(proof: snarkjs.Groth16Proof): ContractProof;
|
|
84
83
|
export interface CircuitsInterface {
|
|
85
84
|
downloadArtifacts(version: VersionString): Promise<Binaries>;
|
|
86
85
|
initArtifacts(version: VersionString): Promise<void>;
|
|
87
|
-
getVerificationKey(circuitName: CircuitNameString
|
|
88
|
-
getProvingKey(circuitName: CircuitNameString
|
|
89
|
-
getWasm(circuitName: CircuitNameString
|
|
86
|
+
getVerificationKey(circuitName: CircuitNameString): Promise<Uint8Array>;
|
|
87
|
+
getProvingKey(circuitName: CircuitNameString): Promise<Uint8Array>;
|
|
88
|
+
getWasm(circuitName: CircuitNameString): Promise<Uint8Array>;
|
|
90
89
|
}
|
|
91
90
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO;;CAEV,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAC7D,MAAM,MAAM,aAAa,GAAG,GAAG,OAAO,EAAE,CAAC;AAEzC,eAAO,MAAM,WAAW;;;CAGd,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AACzE,MAAM,MA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AAE,MAAM,CAAC,CAAC;IAC9B,UAAU,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACvF;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,CAAC,YAAY,GAAG,aAAa,CAEvF;AAED,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACxE,aAAa,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACnE,OAAO,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC9D"}
|
package/dist/types.js
CHANGED
|
@@ -53,18 +53,11 @@ export function withdrawObjectToCircuitBus(signals) {
|
|
|
53
53
|
signals.ASPRoot,
|
|
54
54
|
signals.ASPTreeDepth,
|
|
55
55
|
signals.context,
|
|
56
|
-
].map(s => s.toString(10));
|
|
56
|
+
].map((s) => s.toString(10));
|
|
57
57
|
}
|
|
58
|
-
;
|
|
59
58
|
export function commitmentObjectToCircuitBus(signals) {
|
|
60
|
-
return [
|
|
61
|
-
signals.commitment,
|
|
62
|
-
signals.nullifierHash,
|
|
63
|
-
signals.value,
|
|
64
|
-
signals.label,
|
|
65
|
-
].map(s => s.toString(10));
|
|
59
|
+
return [signals.commitment, signals.nullifierHash, signals.value, signals.label].map((s) => s.toString(10));
|
|
66
60
|
}
|
|
67
|
-
;
|
|
68
61
|
export function snarkjsProofToSolidityFormat(proof) {
|
|
69
62
|
throw new Error("Not implemented");
|
|
70
63
|
}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,MAAM,EAAE,QAAQ;CACR,CAAC;AAKX,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAmBX,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE;QACxB,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,iBAAiB;KACxB;IACD,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;QACtB,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,eAAe;KACtB;CACO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,MAAM,EAAE,QAAQ;CACR,CAAC;AAKX,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAmBX,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE;QACxB,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,iBAAiB;KACxB;IACD,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;QACtB,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,eAAe;KACtB;CACO,CAAC;AAuEX,MAAM,UAAU,sBAAsB,CAAC,aAAkC;IACvE,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,kCA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QACf,OAAO,CAAC,YAAY;QACpB,OAAO,CAAC,OAAO;KAChB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAqC,CAAC;AACnE,CAAC;AAGD,MAAM,UAAU,4BAA4B,CAAC,OAAgC;IAC3E,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACzF,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CACuB,CAAC;AAC1C,CAAC;AASD,MAAM,UAAU,4BAA4B,CAAC,KAA2B;IACtE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fatsolutions/privacy-pools-core-circuits",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"description": "Circom circuits and pre-built artifacts for the Privacy Pool protocol",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/
|
|
8
|
+
"url": "git+https://github.com/fatlabsxyz/privacy-pools-circuits.git"
|
|
9
9
|
},
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
|
-
"author": "
|
|
11
|
+
"author": "FatSolutions",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "./dist/index.js",
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
@@ -23,48 +23,42 @@
|
|
|
23
23
|
"dist",
|
|
24
24
|
"artifacts"
|
|
25
25
|
],
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"stage-artifacts": "sh ./scripts/present.sh",
|
|
29
|
-
"compile": "npx ts-node -P tsconfig.json ./src/index.ts",
|
|
30
|
-
"test": "npx mocha",
|
|
31
|
-
"test:merkle": "npx mocha --ignore tests/commitment.test.ts --ignore tests/withdrawal.test.ts",
|
|
32
|
-
"test:withdraw": "npx mocha --ignore tests/commitment.test.ts --ignore tests/lean-imt.test.ts",
|
|
33
|
-
"test:commitment": "npx mocha --ignore tests/withdrawal.test.ts --ignore tests/lean-imt.test.ts",
|
|
34
|
-
"circomspect": "circomspect -L ../../node_modules/circomlib/circuits/comparators.circom -L ../../node_modules/circomlib/circuits/mux1.circom -L ../../node_modules/circomlib/circuits/poseidon.circom ./circuits/*",
|
|
35
|
-
"info:withdraw": "npx circomkit info withdraw",
|
|
36
|
-
"info:commitment": "npx circomkit info commitment",
|
|
37
|
-
"setup:ptau": "npx circomkit ptau withdraw",
|
|
38
|
-
"setup:all": "yarn setup:ptau && yarn setup:withdraw && yarn setup:merkle && yarn setup:commitment",
|
|
39
|
-
"setup:withdraw": "npx circomkit setup withdraw ptau/powersOfTau28_hez_final_16.ptau",
|
|
40
|
-
"setup:commitment": "npx circomkit setup commitment ptau/powersOfTau28_hez_final_16.ptau",
|
|
41
|
-
"setup:merkle": "npx circomkit setup merkleTree ptau/powersOfTau28_hez_final_16.ptau",
|
|
42
|
-
"present": "sh ./scripts/present.sh",
|
|
43
|
-
"prove:withdraw": "npx circomkit prove withdraw default",
|
|
44
|
-
"prove:commitment": "npx circomkit prove commitment default",
|
|
45
|
-
"verify:withdraw": "npx circomkit verify withdraw default",
|
|
46
|
-
"verify:commitment": "npx circomkit verify commitment default",
|
|
47
|
-
"gencontract:withdraw": "npx snarkjs zkey export solidityverifier trusted-setup/final-keys/withdraw.zkey WithdrawalVerifier.sol",
|
|
48
|
-
"gencontract:commitment": "npx snarkjs zkey export solidityverifier trusted-setup/final-keys/commitment.zkey CommitmentVerifier.sol"
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"snarkjs": "0.7.5"
|
|
49
28
|
},
|
|
50
29
|
"devDependencies": {
|
|
30
|
+
"@eslint/js": "9.39.2",
|
|
31
|
+
"@fatsolutions/ganchos": "*",
|
|
51
32
|
"@types/mocha": "^10.0.1",
|
|
52
|
-
"@types/node": "20.3.1",
|
|
33
|
+
"@types/node": "^20.3.1",
|
|
53
34
|
"@types/snarkjs": "0.7.9",
|
|
54
35
|
"@zk-kit/lean-imt": "2.2.2",
|
|
55
|
-
"chai": "5.1.2",
|
|
56
36
|
"circomkit": "0.3.2",
|
|
57
37
|
"circomlib": "2.0.5",
|
|
38
|
+
"eslint": "9.39.2",
|
|
39
|
+
"eslint-config-prettier": "10.1.8",
|
|
58
40
|
"maci-circuits": "2.5.0",
|
|
59
41
|
"maci-crypto": "2.5.0",
|
|
60
42
|
"mocha": "^10.2.0",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"viem": "2.21.57"
|
|
43
|
+
"typescript": "^5.5.4",
|
|
44
|
+
"typescript-eslint": "8.51.0",
|
|
45
|
+
"vitest": "4.0.18"
|
|
65
46
|
},
|
|
66
47
|
"publishConfig": {
|
|
67
48
|
"access": "public",
|
|
68
49
|
"registry": "https://registry.npmjs.org"
|
|
50
|
+
},
|
|
51
|
+
"ganchos": {
|
|
52
|
+
"languages": [
|
|
53
|
+
"typescript"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsc -p tsconfig.build.json",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest",
|
|
61
|
+
"clean": "rm -rf dist",
|
|
62
|
+
"stage-artifacts": "sh ./scripts/present.sh"
|
|
69
63
|
}
|
|
70
|
-
}
|
|
64
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [1.0.0] - 2025-07-03
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- Initial state of the code for upcoming releases
|
package/README.md
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# Privacy Pool Circuits
|
|
2
|
-
|
|
3
|
-
This package contains the zero-knowledge circuit implementations for the Privacy Pool protocol. The circuits are written in Circom and are designed to work together to enable private withdrawals with membership proofs.
|
|
4
|
-
|
|
5
|
-
## Circuit Architecture
|
|
6
|
-
|
|
7
|
-
The protocol implements three main circuits that work together:
|
|
8
|
-
|
|
9
|
-
### Withdrawal Circuit
|
|
10
|
-
|
|
11
|
-
The withdrawal circuit verifies that a user can privately withdraw funds from the protocol. It takes as input:
|
|
12
|
-
|
|
13
|
-
- The withdrawal amount and details
|
|
14
|
-
- The unique related commitments identifier (label)
|
|
15
|
-
- A state root and ASP (Association Set Provider) root
|
|
16
|
-
- A proof of inclusion in the state tree
|
|
17
|
-
- A proof of inclusion in the ASP tree
|
|
18
|
-
- Nullifier and commitment secrets
|
|
19
|
-
|
|
20
|
-
The circuit ensures the withdrawal is valid by verifying:
|
|
21
|
-
|
|
22
|
-
- The user knows the preimage of the commitment
|
|
23
|
-
- The commitment exists in the state tree
|
|
24
|
-
- The comimtment label is included in the ASP tree
|
|
25
|
-
- The withdrawal amount is valid and matches the commitment
|
|
26
|
-
|
|
27
|
-
### LeanIMT Circuit
|
|
28
|
-
|
|
29
|
-
The LeanIMT (Lean Incremental Merkle Tree) circuit handles merkle tree operations. It implements an optimized merkle tree that:
|
|
30
|
-
|
|
31
|
-
- Supports dynamic depth
|
|
32
|
-
- Optimizes node computations by propagating single child values
|
|
33
|
-
- Verifies inclusion proofs efficiently
|
|
34
|
-
|
|
35
|
-
### Commitment Circuit
|
|
36
|
-
|
|
37
|
-
The commitment circuit manages the hashing and verification of commitments. It:
|
|
38
|
-
|
|
39
|
-
- Computes commitment hashes from input values and secrets
|
|
40
|
-
- Generates nullifier hashes for preventing double-spending
|
|
41
|
-
- Creates precommitment hashes for privacy preservation
|
|
42
|
-
|
|
43
|
-
## Development
|
|
44
|
-
|
|
45
|
-
### Prerequisites
|
|
46
|
-
|
|
47
|
-
- Node.js 20+
|
|
48
|
-
- Yarn
|
|
49
|
-
- circom 2.2.0+
|
|
50
|
-
|
|
51
|
-
### Building
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
# Compile circuits
|
|
55
|
-
yarn compile
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Testing
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# Run circuit tests
|
|
62
|
-
yarn test
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Generating Groth16 Solidity verifiers
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
# Generate verifier for the withdrawal circuit
|
|
69
|
-
yarn gencontract:withdraw
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
# Generate verifier for the commitment circuit
|
|
74
|
-
yarn gencontract:commitment
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Directory Structure
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
circuits/
|
|
81
|
-
├── circuits/
|
|
82
|
-
│ ├── commitment.circom # Commitment circuit
|
|
83
|
-
│ ├── merkleTree.circom # LeanIMT circuit
|
|
84
|
-
│ └── withdraw.circom # Withdrawal circuit
|
|
85
|
-
└── tests/ # Circuit tests
|
|
86
|
-
```
|