@stellar-registry/perch-artifacts 0.0.0-stage → 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 +202 -0
- package/README.md +88 -2
- package/circuits/Nargo.toml +3 -0
- package/circuits/artifacts/perch_zk_recovery.json +104 -0
- package/circuits/artifacts/perch_zk_recovery_d24.json +104 -0
- package/circuits/manifest.json +101 -0
- package/circuits/perch_zk/Nargo.toml +9 -0
- package/circuits/perch_zk/src/lib.nr +126 -0
- package/circuits/perch_zk/src/tests.nr +145 -0
- package/circuits/perch_zk_recovery/Nargo.toml +7 -0
- package/circuits/perch_zk_recovery/src/main.nr +34 -0
- package/circuits/perch_zk_recovery_d24/Nargo.toml +7 -0
- package/circuits/perch_zk_recovery_d24/src/main.nr +38 -0
- package/circuits/vendor/poseidon/CHECKSUMS.sha256 +13 -0
- package/circuits/vendor/poseidon/LICENSE +201 -0
- package/circuits/vendor/poseidon/NOTICE +25 -0
- package/circuits/vendor/poseidon/Nargo.toml +7 -0
- package/circuits/vendor/poseidon/README.md +28 -0
- package/circuits/vendor/poseidon/src/bench.nr +6 -0
- package/circuits/vendor/poseidon/src/lib.nr +8 -0
- package/circuits/vendor/poseidon/src/oracle_tests.nr +20 -0
- package/circuits/vendor/poseidon/src/poseidon/bn254/consts.nr +24965 -0
- package/circuits/vendor/poseidon/src/poseidon/bn254/perm.nr +115 -0
- package/circuits/vendor/poseidon/src/poseidon/bn254.nr +173 -0
- package/circuits/vendor/poseidon/src/poseidon/mod.nr +359 -0
- package/circuits/vendor/poseidon/src/poseidon2.nr +98 -0
- package/circuits/vendor/poseidon/src/tests.nr +34 -0
- package/constants.json +14 -0
- package/deployments/testnet-exercise.json +2469 -0
- package/deployments/testnet.json +129 -0
- package/dist/cli/derive-id.d.ts +2 -0
- package/dist/cli/derive-id.js +17 -0
- package/dist/cli/fetch-infra-wasm.d.ts +2 -0
- package/dist/cli/fetch-infra-wasm.js +5 -0
- package/dist/cli/zk-toolchain.d.ts +2 -0
- package/dist/cli/zk-toolchain.js +5 -0
- package/dist/derive.d.ts +6 -0
- package/dist/derive.js +79 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +31 -0
- package/dist/script.d.ts +1 -0
- package/dist/script.js +12 -0
- package/package.json +53 -4
- package/scripts/fetch-infra-wasm.sh +114 -0
- package/scripts/zk-toolchain.sh +91 -0
- package/vectors/auth-vectors.json +143 -0
- package/vectors/diagnostic-events.json +37 -0
- package/vectors/eval-vectors.json +2244 -0
- package/vectors/rule-hashes.json +60 -0
- package/vectors/statement-v2.json +230 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": 1,
|
|
3
|
+
"network": "testnet",
|
|
4
|
+
"network_passphrase": "Test SDF Network ; September 2015",
|
|
5
|
+
"rpc_url": "https://soroban-testnet.stellar.org",
|
|
6
|
+
"channel": "beta",
|
|
7
|
+
"deployed_at": "2026-10-12T17:27:53Z",
|
|
8
|
+
"deployed_ledger": 5160473,
|
|
9
|
+
"source": {
|
|
10
|
+
"commit": "7b164b6ea99119569c9ceacdf2860713212f00a9",
|
|
11
|
+
"dirty": false
|
|
12
|
+
},
|
|
13
|
+
"toolchain": {
|
|
14
|
+
"builder": "scaffold",
|
|
15
|
+
"rustc": "rustc 1.97.1 (8bab26f4f 2026-07-14)",
|
|
16
|
+
"stellar": "stellar 27.0.0 (5a7c5fe76530bf4248477ac812fc757146b98cc4)",
|
|
17
|
+
"scaffold": "scaffold 0.0.27 (stellar-scaffold-cli-v0.0.27-0-g6f1f06c3e8d2cf82573ec214b20d1550e9ce326b)"
|
|
18
|
+
},
|
|
19
|
+
"registry": {
|
|
20
|
+
"id": "CAR2DSSOBJB76GGD6MAAKWUK36Y7I7O3NDWTN7HTIRV5I3XZ27U3ZBVZ",
|
|
21
|
+
"wasm_hash": "4b2d9ea4148474715076e81067cff06b765248d9c4cd7d0e99e53df3e368adec",
|
|
22
|
+
"admin": "GBQQGD4AEWBBAU3TIH56XRHQI5CONAEIOPFMWASOKQMLUEITPZOWQLE7",
|
|
23
|
+
"manager": "GBQQGD4AEWBBAU3TIH56XRHQI5CONAEIOPFMWASOKQMLUEITPZOWQLE7",
|
|
24
|
+
"root": "CAAXJETKPYAATU4HVVQUTE2FFBULNFGZNEOC3MS635U5K3GZLAY2HI4M"
|
|
25
|
+
},
|
|
26
|
+
"zk": {
|
|
27
|
+
"circuit_id": "9e39c41f4f35aad43e64b255dfe3ba13f10e8c9d36d6f56fce23c2d97c0a0b4a",
|
|
28
|
+
"tree_depth": 32,
|
|
29
|
+
"circuit_manifest": "circuits/manifest.json"
|
|
30
|
+
},
|
|
31
|
+
"contracts": {
|
|
32
|
+
"perch-doc-compiler": {
|
|
33
|
+
"version": "0.3.2",
|
|
34
|
+
"wasm": "perch_doc_compiler.wasm",
|
|
35
|
+
"sha256": "ccea12cd4b2f23d9bce07e3d9d3aaf93c43df79416b22a8c9a122d467b707853",
|
|
36
|
+
"bytes": 108386,
|
|
37
|
+
"tier": 0,
|
|
38
|
+
"pins": {},
|
|
39
|
+
"address": "CCYSZHRHY7GKT2OYXF6JW332GA2BL6ZKPAWIV6RVC5JW2RNPHQPSW5ZI"
|
|
40
|
+
},
|
|
41
|
+
"perch-interpreter": {
|
|
42
|
+
"version": "0.1.3",
|
|
43
|
+
"wasm": "perch_interpreter.wasm",
|
|
44
|
+
"sha256": "2254f17dd722e5113caee901be96849c13e5a6853a6213d62473abe637ae33e1",
|
|
45
|
+
"bytes": 16954,
|
|
46
|
+
"tier": 0,
|
|
47
|
+
"pins": {},
|
|
48
|
+
"address": "CA5JLPEVA3E5X7YEDVABMEM3TML33ZS3I6WL5NDBFIZZAXFYNZPBBWTO"
|
|
49
|
+
},
|
|
50
|
+
"perch-spending-limit": {
|
|
51
|
+
"version": "0.1.2",
|
|
52
|
+
"wasm": "perch_spending_limit.wasm",
|
|
53
|
+
"sha256": "f2f0560ce501ab59144ed71a10349b30bcefaf344ca121c0bd9841577b83c2b7",
|
|
54
|
+
"bytes": 12571,
|
|
55
|
+
"tier": 0,
|
|
56
|
+
"pins": {},
|
|
57
|
+
"address": "CD3FGRDBG7L5KNJAOQZW5WWKK4E5CQ63DNC3W25B63WEIGYX25NQDN4K"
|
|
58
|
+
},
|
|
59
|
+
"perch-ed25519-verifier": {
|
|
60
|
+
"version": "10.0.0",
|
|
61
|
+
"wasm": "perch_ed25519_verifier.wasm",
|
|
62
|
+
"sha256": "851cb7bc36f7917548431cc1490880488f165264516aaf6bd72b93c31b6b39cc",
|
|
63
|
+
"bytes": 1411,
|
|
64
|
+
"tier": 0,
|
|
65
|
+
"pins": {},
|
|
66
|
+
"address": "CCKJXEVN6GS4NWDGK5PIPPQSVR4FBR3QSZLCIEYSOVYH2PA7BJLUIUOJ"
|
|
67
|
+
},
|
|
68
|
+
"perch-webauthn-verifier": {
|
|
69
|
+
"version": "0.1.0",
|
|
70
|
+
"wasm": "perch_webauthn_verifier.wasm",
|
|
71
|
+
"sha256": "9e9fbe7886d9bb149a6e3ee10de15954c57bbdf20f817ed94e1370c01b9c669e",
|
|
72
|
+
"bytes": 11783,
|
|
73
|
+
"tier": 0,
|
|
74
|
+
"pins": {},
|
|
75
|
+
"address": "CAL7IEAJO7S3SJI4EXESMUNPOEYW6QNR3PQTO7AVHD75YGURSZ5CW27Z"
|
|
76
|
+
},
|
|
77
|
+
"perch-zk-pool": {
|
|
78
|
+
"version": "0.1.1",
|
|
79
|
+
"wasm": "perch_zk_pool.wasm",
|
|
80
|
+
"sha256": "5389aef52582831184715bd06ff34e6265800e4b439536af6664882498626105",
|
|
81
|
+
"bytes": 46179,
|
|
82
|
+
"tier": 0,
|
|
83
|
+
"pins": {},
|
|
84
|
+
"address": "CB3IOX2VW7C5VYKVQMNLQ5DPMNC5WSPEOVJSIRBZKXVHURGXBHII6EP7"
|
|
85
|
+
},
|
|
86
|
+
"perch-zk-adapter": {
|
|
87
|
+
"version": "0.1.1",
|
|
88
|
+
"wasm": "perch_zk_adapter.wasm",
|
|
89
|
+
"sha256": "8a1deec2bbc9ec5d43dbbea7ed91bbd1b4c75397d1f6231e403ff520c8255057",
|
|
90
|
+
"bytes": 68502,
|
|
91
|
+
"tier": 0,
|
|
92
|
+
"pins": {},
|
|
93
|
+
"address": "CDLOOCAYOLNIVLGD4ZT6CYCRN23SM7OPO7FOSDUASFPHNAW3VWBMY2WH"
|
|
94
|
+
},
|
|
95
|
+
"perch-recovery": {
|
|
96
|
+
"version": "0.1.2",
|
|
97
|
+
"wasm": "perch_recovery.wasm",
|
|
98
|
+
"sha256": "d6e8bfc3b91f7c15b9738a3425f0c321f1badc0896e9a5f062e6f32646c895b0",
|
|
99
|
+
"bytes": 67119,
|
|
100
|
+
"tier": 0,
|
|
101
|
+
"pins": {},
|
|
102
|
+
"address": "CDBIZB3MP7ANOFKIYBRKFX4AODLRODCDZUWMMYVTCFAXA4W2OH6D6LV2"
|
|
103
|
+
},
|
|
104
|
+
"perch-account": {
|
|
105
|
+
"version": "0.3.2",
|
|
106
|
+
"wasm": "perch_account.wasm",
|
|
107
|
+
"sha256": "d3d4c28a01b37660c23ac03622b712608d2c0f853b634a597f3cd617e7b66df5",
|
|
108
|
+
"bytes": 70050,
|
|
109
|
+
"tier": 1,
|
|
110
|
+
"pins": {
|
|
111
|
+
"perch-doc-compiler": "ccea12cd4b2f23d9bce07e3d9d3aaf93c43df79416b22a8c9a122d467b707853",
|
|
112
|
+
"perch-interpreter": "2254f17dd722e5113caee901be96849c13e5a6853a6213d62473abe637ae33e1",
|
|
113
|
+
"perch-spending-limit": "f2f0560ce501ab59144ed71a10349b30bcefaf344ca121c0bd9841577b83c2b7"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"perch-account-factory": {
|
|
117
|
+
"version": "0.1.2",
|
|
118
|
+
"wasm": "perch_account_factory.wasm",
|
|
119
|
+
"sha256": "f3b55f61a395768e428ad7728fbbddd1f61302666ecdd7ed4e8db8b98ac8d37c",
|
|
120
|
+
"bytes": 4696,
|
|
121
|
+
"tier": 2,
|
|
122
|
+
"pins": {
|
|
123
|
+
"perch-account": "d3d4c28a01b37660c23ac03622b712608d2c0f853b634a597f3cd617e7b66df5",
|
|
124
|
+
"perch-webauthn-verifier": "9e9fbe7886d9bb149a6e3ee10de15954c57bbdf20f817ed94e1370c01b9c669e"
|
|
125
|
+
},
|
|
126
|
+
"address": "CC2W6KK6VBAAE2QPZ7GOZMOLUJBMSKMB6A4W4ZOAPBVCMCITRNA7DW5E"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// perch-derive-id content <registry-C-id> <wasm-hash-hex> <network-passphrase>
|
|
3
|
+
//
|
|
4
|
+
// deployer(registry, salt = wasm_hash): a `deploy_stateless` address, as
|
|
5
|
+
// crates/perch-derive-id's `content` mode prints it.
|
|
6
|
+
import { contentAddress } from '../derive.js';
|
|
7
|
+
const [mode, registry, hash, passphrase, ...rest] = process.argv.slice(2);
|
|
8
|
+
if (mode !== 'content' || !registry || !hash || passphrase === undefined || rest.length) {
|
|
9
|
+
const usage = 'usage: perch-derive-id content <registry> <wasm-hash-hex> <passphrase>';
|
|
10
|
+
if (mode === '--help' || mode === '-h') {
|
|
11
|
+
console.log(usage);
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
console.error(usage);
|
|
15
|
+
process.exit(2);
|
|
16
|
+
}
|
|
17
|
+
console.log(contentAddress(registry, hash, passphrase));
|
package/dist/derive.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The 32-byte contract id a `C…` strkey encodes. Throws on a malformed key. */
|
|
2
|
+
export declare function decodeContract(strkey: string): Uint8Array;
|
|
3
|
+
/** `deployer(parent, salt)`: the address the contract `parent` deploys to under `salt`. */
|
|
4
|
+
export declare function deployedAddress(parent: string, salt: Uint8Array, passphrase: string): string;
|
|
5
|
+
/** A `deploy_stateless` address: `deployer(registry, salt = wasm hash)`. */
|
|
6
|
+
export declare function contentAddress(registry: string, wasmHash: string, passphrase: string): string;
|
package/dist/derive.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Offline contract-id derivation, the computation crates/perch-derive-id
|
|
2
|
+
// runs through soroban's `Env`, so the packaged fetch-infra-wasm.sh checks
|
|
3
|
+
// content addresses without a Rust toolchain:
|
|
4
|
+
//
|
|
5
|
+
// id = sha256(HashIdPreimage::ContractId {
|
|
6
|
+
// network_id: sha256(passphrase),
|
|
7
|
+
// preimage: FromAddress { address: deployer, salt } })
|
|
8
|
+
import { createHash } from 'node:crypto';
|
|
9
|
+
const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
|
10
|
+
const CONTRACT_VERSION = 2 << 3; // strkey version byte for 'C'
|
|
11
|
+
const ENVELOPE_TYPE_CONTRACT_ID = 8;
|
|
12
|
+
const CONTRACT_ID_PREIMAGE_FROM_ADDRESS = 0;
|
|
13
|
+
const SC_ADDRESS_TYPE_CONTRACT = 1;
|
|
14
|
+
const sha256 = (...parts) => {
|
|
15
|
+
const h = createHash('sha256');
|
|
16
|
+
for (const p of parts)
|
|
17
|
+
h.update(p);
|
|
18
|
+
return new Uint8Array(h.digest());
|
|
19
|
+
};
|
|
20
|
+
function crc16(bytes) {
|
|
21
|
+
let crc = 0;
|
|
22
|
+
for (const b of bytes) {
|
|
23
|
+
crc ^= b << 8;
|
|
24
|
+
for (let i = 0; i < 8; i++)
|
|
25
|
+
crc = crc & 0x8000 ? ((crc << 1) ^ 0x1021) & 0xffff : (crc << 1) & 0xffff;
|
|
26
|
+
}
|
|
27
|
+
return crc;
|
|
28
|
+
}
|
|
29
|
+
function encodeContract(id) {
|
|
30
|
+
const crc = crc16(Uint8Array.of(CONTRACT_VERSION, ...id));
|
|
31
|
+
const data = Uint8Array.of(CONTRACT_VERSION, ...id, crc & 0xff, crc >> 8);
|
|
32
|
+
let out = '';
|
|
33
|
+
let bits = 0;
|
|
34
|
+
let acc = 0;
|
|
35
|
+
for (const b of data) {
|
|
36
|
+
acc = (acc << 8) | b;
|
|
37
|
+
bits += 8;
|
|
38
|
+
while (bits >= 5)
|
|
39
|
+
out += ALPHABET[(acc >> (bits -= 5)) & 31];
|
|
40
|
+
}
|
|
41
|
+
return bits ? out + ALPHABET[(acc << (5 - bits)) & 31] : out;
|
|
42
|
+
}
|
|
43
|
+
/** The 32-byte contract id a `C…` strkey encodes. Throws on a malformed key. */
|
|
44
|
+
export function decodeContract(strkey) {
|
|
45
|
+
if (strkey.length !== 56)
|
|
46
|
+
throw new Error(`not a contract strkey: ${strkey}`);
|
|
47
|
+
const data = [];
|
|
48
|
+
let bits = 0;
|
|
49
|
+
let acc = 0;
|
|
50
|
+
for (const c of strkey) {
|
|
51
|
+
const v = ALPHABET.indexOf(c);
|
|
52
|
+
if (v < 0)
|
|
53
|
+
throw new Error(`not a contract strkey: ${strkey}`);
|
|
54
|
+
acc = (acc << 5) | v;
|
|
55
|
+
bits += 5;
|
|
56
|
+
if (bits >= 8)
|
|
57
|
+
data.push((acc >> (bits -= 8)) & 0xff);
|
|
58
|
+
}
|
|
59
|
+
const id = Uint8Array.from(data.slice(1, 33));
|
|
60
|
+
if (data[0] !== CONTRACT_VERSION || encodeContract(id) !== strkey) {
|
|
61
|
+
throw new Error(`not a contract strkey: ${strkey}`);
|
|
62
|
+
}
|
|
63
|
+
return id;
|
|
64
|
+
}
|
|
65
|
+
function parseHash(hex) {
|
|
66
|
+
const h = hex.replace(/^0x/, '');
|
|
67
|
+
if (!/^[0-9a-fA-F]{64}$/.test(h))
|
|
68
|
+
throw new Error(`not a 32-byte hex hash: ${hex}`);
|
|
69
|
+
return Uint8Array.from(Buffer.from(h, 'hex'));
|
|
70
|
+
}
|
|
71
|
+
/** `deployer(parent, salt)`: the address the contract `parent` deploys to under `salt`. */
|
|
72
|
+
export function deployedAddress(parent, salt, passphrase) {
|
|
73
|
+
const u32 = (n) => Uint8Array.of(n >>> 24, (n >>> 16) & 0xff, (n >>> 8) & 0xff, n & 0xff);
|
|
74
|
+
return encodeContract(sha256(u32(ENVELOPE_TYPE_CONTRACT_ID), sha256(new TextEncoder().encode(passphrase)), u32(CONTRACT_ID_PREIMAGE_FROM_ADDRESS), u32(SC_ADDRESS_TYPE_CONTRACT), decodeContract(parent), salt));
|
|
75
|
+
}
|
|
76
|
+
/** A `deploy_stateless` address: `deployer(registry, salt = wasm hash)`. */
|
|
77
|
+
export function contentAddress(registry, wasmHash, passphrase) {
|
|
78
|
+
return deployedAddress(registry, parseHash(wasmHash), passphrase);
|
|
79
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export { contentAddress, decodeContract, deployedAddress } from './derive.js';
|
|
2
|
+
/** The installed package's directory. */
|
|
3
|
+
export declare const root: string;
|
|
4
|
+
/** Absolute paths to the shipped artifacts. */
|
|
5
|
+
export declare const paths: {
|
|
6
|
+
/** `deployments/<network>.json`, one manifest per network. */
|
|
7
|
+
deployments: string;
|
|
8
|
+
/** The Noir workspace (`nargo compile --workspace` runs here), with `manifest.json` and the compiled `artifacts/`. */
|
|
9
|
+
circuits: string;
|
|
10
|
+
vectors: string;
|
|
11
|
+
constants: string;
|
|
12
|
+
/** The repository's scripts/fetch-infra-wasm.sh (`perch-fetch-infra-wasm`). */
|
|
13
|
+
fetchInfraWasm: string;
|
|
14
|
+
/** The repository's scripts/zk-toolchain.sh (`perch-zk-toolchain`). */
|
|
15
|
+
zkToolchain: string;
|
|
16
|
+
};
|
|
17
|
+
/** The vectors under `vectors/`, each a copy of one in the repository's testdata/. */
|
|
18
|
+
export type VectorName = 'auth-vectors.json' | 'diagnostic-events.json' | 'statement-v2.json' | 'rule-hashes.json' | 'eval-vectors.json';
|
|
19
|
+
export declare const vectorPath: (name: VectorName) => string;
|
|
20
|
+
export declare const deploymentPath: (network: string) => string;
|
|
21
|
+
/** A deployed contract in a deployment manifest. */
|
|
22
|
+
export interface DeployedContract {
|
|
23
|
+
version: string;
|
|
24
|
+
/** sha256 of the deployed wasm. */
|
|
25
|
+
sha256: string;
|
|
26
|
+
/** The content address under the manifest's registry; absent for the
|
|
27
|
+
* account, which is installed for the factory, not deployed. */
|
|
28
|
+
address?: string;
|
|
29
|
+
tier: number;
|
|
30
|
+
bytes: number;
|
|
31
|
+
wasm: string;
|
|
32
|
+
/** sha256 of every contract this one was built against. */
|
|
33
|
+
pins: Record<string, string>;
|
|
34
|
+
}
|
|
35
|
+
/** A deployment manifest (`deployments/<network>.json`, written by scripts/deploy-stack.sh). */
|
|
36
|
+
export interface Deployment {
|
|
37
|
+
schema: number;
|
|
38
|
+
network: string;
|
|
39
|
+
network_passphrase: string;
|
|
40
|
+
rpc_url: string;
|
|
41
|
+
channel: string;
|
|
42
|
+
deployed_at: string;
|
|
43
|
+
/** The first ledger an indexer needs to scan. */
|
|
44
|
+
deployed_ledger: number;
|
|
45
|
+
source: {
|
|
46
|
+
commit: string;
|
|
47
|
+
dirty: boolean;
|
|
48
|
+
};
|
|
49
|
+
toolchain: Record<string, string>;
|
|
50
|
+
registry: {
|
|
51
|
+
id: string;
|
|
52
|
+
wasm_hash: string;
|
|
53
|
+
admin: string;
|
|
54
|
+
manager: string;
|
|
55
|
+
root: string;
|
|
56
|
+
};
|
|
57
|
+
zk: {
|
|
58
|
+
circuit_id: string;
|
|
59
|
+
tree_depth: number;
|
|
60
|
+
circuit_manifest: string;
|
|
61
|
+
};
|
|
62
|
+
contracts: Record<string, DeployedContract>;
|
|
63
|
+
}
|
|
64
|
+
/** The parsed manifest for `network`. */
|
|
65
|
+
export declare const deployment: (network?: string) => Deployment;
|
|
66
|
+
/** `circuits/manifest.json`. Its paths are repository-relative: the
|
|
67
|
+
* `circuits/` ones resolve against {@link root}; the `vk` files are not
|
|
68
|
+
* shipped (the ZK adapter compiles them in). */
|
|
69
|
+
export interface CircuitManifest {
|
|
70
|
+
circuits: Record<string, {
|
|
71
|
+
acir_bytecode_sha256: string;
|
|
72
|
+
artifact: string;
|
|
73
|
+
artifact_sha256: string;
|
|
74
|
+
circuit_size: number;
|
|
75
|
+
depth: number;
|
|
76
|
+
public_inputs: string[];
|
|
77
|
+
vk: string;
|
|
78
|
+
vk_sha256: string;
|
|
79
|
+
}>;
|
|
80
|
+
fixtures: Record<string, {
|
|
81
|
+
action: string;
|
|
82
|
+
proof_sha256: string;
|
|
83
|
+
public_inputs_sha256: string;
|
|
84
|
+
}>;
|
|
85
|
+
/** sha256 of every circuit source file, by repository path. */
|
|
86
|
+
sources: Record<string, string>;
|
|
87
|
+
toolchain: Record<string, string>;
|
|
88
|
+
}
|
|
89
|
+
export declare const circuitManifest: CircuitManifest;
|
|
90
|
+
/** Limits no contract view reports, written from the crates' own constants
|
|
91
|
+
* by crates/integration-tests/tests/artifact_constants.rs. */
|
|
92
|
+
export interface Constants {
|
|
93
|
+
doc_compiler: {
|
|
94
|
+
MAX_DOC_SIGNERS: number;
|
|
95
|
+
MAX_DOC_RULES: number;
|
|
96
|
+
MAX_DOC_CANONICAL_BYTES: number;
|
|
97
|
+
MAX_RULE_NAME_BYTES: number;
|
|
98
|
+
};
|
|
99
|
+
program: {
|
|
100
|
+
PROGRAM_VERSION: number;
|
|
101
|
+
MAX_PROGRAM_LEN: number;
|
|
102
|
+
MAX_STACK_DEPTH: number;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export declare const constants: Constants;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Perch's consumable artifacts as files: the deployment manifests, the ZK
|
|
2
|
+
// recovery circuits, the test vectors, and the program and compiler limits.
|
|
3
|
+
// Import a JSON file directly
|
|
4
|
+
// (`@stellar-registry/perch-artifacts/deployments/testnet.json`), or take a
|
|
5
|
+
// path from here for tools that want one on disk.
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
export { contentAddress, decodeContract, deployedAddress } from './derive.js';
|
|
10
|
+
/** The installed package's directory. */
|
|
11
|
+
export const root = fileURLToPath(new URL('..', import.meta.url));
|
|
12
|
+
const json = (rel) => JSON.parse(readFileSync(join(root, rel), 'utf8'));
|
|
13
|
+
/** Absolute paths to the shipped artifacts. */
|
|
14
|
+
export const paths = {
|
|
15
|
+
/** `deployments/<network>.json`, one manifest per network. */
|
|
16
|
+
deployments: join(root, 'deployments'),
|
|
17
|
+
/** The Noir workspace (`nargo compile --workspace` runs here), with `manifest.json` and the compiled `artifacts/`. */
|
|
18
|
+
circuits: join(root, 'circuits'),
|
|
19
|
+
vectors: join(root, 'vectors'),
|
|
20
|
+
constants: join(root, 'constants.json'),
|
|
21
|
+
/** The repository's scripts/fetch-infra-wasm.sh (`perch-fetch-infra-wasm`). */
|
|
22
|
+
fetchInfraWasm: join(root, 'scripts', 'fetch-infra-wasm.sh'),
|
|
23
|
+
/** The repository's scripts/zk-toolchain.sh (`perch-zk-toolchain`). */
|
|
24
|
+
zkToolchain: join(root, 'scripts', 'zk-toolchain.sh'),
|
|
25
|
+
};
|
|
26
|
+
export const vectorPath = (name) => join(paths.vectors, name);
|
|
27
|
+
export const deploymentPath = (network) => join(paths.deployments, `${network}.json`);
|
|
28
|
+
/** The parsed manifest for `network`. */
|
|
29
|
+
export const deployment = (network = 'testnet') => json(`deployments/${network}.json`);
|
|
30
|
+
export const circuitManifest = json('circuits/manifest.json');
|
|
31
|
+
export const constants = json('constants.json');
|
package/dist/script.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runScript(name: string): never;
|
package/dist/script.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Runs one of the repository scripts this package ships with bash. npm links
|
|
2
|
+
// a bin into node_modules/.bin, where the script would resolve its own
|
|
3
|
+
// directory wrong, so each bin is this wrapper.
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { root } from './index.js';
|
|
7
|
+
export function runScript(name) {
|
|
8
|
+
const run = spawnSync('bash', [join(root, 'scripts', name), ...process.argv.slice(2)], { stdio: 'inherit' });
|
|
9
|
+
if (run.error)
|
|
10
|
+
throw run.error;
|
|
11
|
+
process.exit(run.status ?? 1);
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stellar-registry/perch-artifacts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Perch's consumable artifacts as files: deployment manifests, the Noir ZK recovery circuits and their manifest, test vectors, document and program limits, and the scripts that fetch the deployed wasm and install the pinned ZK toolchain",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"perch-derive-id": "./dist/cli/derive-id.js",
|
|
11
|
+
"perch-fetch-infra-wasm": "./dist/cli/fetch-infra-wasm.js",
|
|
12
|
+
"perch-zk-toolchain": "./dist/cli/zk-toolchain.js"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./constants.json": "./constants.json",
|
|
20
|
+
"./deployments/*": "./deployments/*",
|
|
21
|
+
"./circuits/*": "./circuits/*",
|
|
22
|
+
"./vectors/*": "./vectors/*",
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"constants.json",
|
|
28
|
+
"deployments",
|
|
29
|
+
"circuits",
|
|
30
|
+
"vectors",
|
|
31
|
+
"scripts",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.build.json && node tools/stage.mjs",
|
|
40
|
+
"prepare": "npm run build",
|
|
41
|
+
"prepack": "npm run build",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"check": "tsc --noEmit"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^22.10.0",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"vitest": "^4.1.7"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/stellar-registry/perch",
|
|
53
|
+
"directory": "packages/perch-artifacts"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Populate the git-ignored build-time pin caches from a deployment manifest
|
|
3
|
+
# (deployments/<network>.json, written by scripts/deploy-stack.sh):
|
|
4
|
+
#
|
|
5
|
+
# crates/perch-smart-account/wasm/ stateless.id, perch-doc-compiler.wasm,
|
|
6
|
+
# perch-interpreter.wasm,
|
|
7
|
+
# perch-spending-limit.wasm
|
|
8
|
+
# crates/perch-account-factory/wasm/ stateless.id, perch-account.wasm,
|
|
9
|
+
# perch-webauthn-verifier.wasm
|
|
10
|
+
#
|
|
11
|
+
# Each wasm is fetched from the chain by the exact address (or, for the
|
|
12
|
+
# account, the exact wasm hash) the manifest records, and refused unless
|
|
13
|
+
# - its sha256 is the manifest's hash, and
|
|
14
|
+
# - the address is the offline content-address derivation
|
|
15
|
+
# deployer(registry, sha256(wasm)) under the manifest's registry,
|
|
16
|
+
# so a consumer built from this cache pins exactly the deployed contracts.
|
|
17
|
+
# Nothing is resolved by name: the earlier name-salted lookup served a stale
|
|
18
|
+
# pre-cap compiler for months (#95).
|
|
19
|
+
#
|
|
20
|
+
# Usage: scripts/fetch-infra-wasm.sh [--manifest <path>] [--stack <dir>]
|
|
21
|
+
# --manifest default deployments/${STELLAR_NETWORK:-testnet}.json
|
|
22
|
+
# --stack also fetch every manifest contract into <dir> and write
|
|
23
|
+
# <dir>/build.json, so tests/release_stack.rs runs against the
|
|
24
|
+
# deployed bytes
|
|
25
|
+
#
|
|
26
|
+
# Requires the Stellar CLI. After a redeploy, run
|
|
27
|
+
# `cargo test -p perch-integration-tests --test testnet_pins`.
|
|
28
|
+
#
|
|
29
|
+
# The npm package @stellar-registry/perch-artifacts ships this script as
|
|
30
|
+
# `perch-fetch-infra-wasm`, beside a copy of deployments/. There is no crate
|
|
31
|
+
# tree to pin there, so it needs --stack, fills only that, and checks content
|
|
32
|
+
# addresses with the package's own perch-derive-id.
|
|
33
|
+
set -euo pipefail
|
|
34
|
+
|
|
35
|
+
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
36
|
+
manifest="$repo_root/deployments/${STELLAR_NETWORK:-testnet}.json"
|
|
37
|
+
stack=""
|
|
38
|
+
while [ $# -gt 0 ]; do
|
|
39
|
+
case "$1" in
|
|
40
|
+
--manifest) manifest="$2"; shift 2 ;;
|
|
41
|
+
--stack) stack="$2"; shift 2 ;;
|
|
42
|
+
-h|--help) sed -n '2,32p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
43
|
+
*) echo "unknown option: $1" >&2; exit 1 ;;
|
|
44
|
+
esac
|
|
45
|
+
done
|
|
46
|
+
[ -f "$manifest" ] || { echo "error: no manifest at $manifest" >&2; exit 1; }
|
|
47
|
+
# A perch checkout has the crates to pin; the npm package does not.
|
|
48
|
+
checkout=false
|
|
49
|
+
[ -f "$repo_root/Cargo.toml" ] && checkout=true
|
|
50
|
+
$checkout || [ -n "$stack" ] || { echo "error: outside a perch checkout there are no pin caches to fill; pass --stack <dir>" >&2; exit 1; }
|
|
51
|
+
command -v stellar >/dev/null || { echo "error: 'stellar' CLI not found." >&2; exit 1; }
|
|
52
|
+
command -v jq >/dev/null || { echo "error: jq not found" >&2; exit 1; }
|
|
53
|
+
|
|
54
|
+
m() { jq -r "$1" "$manifest"; }
|
|
55
|
+
net=(--rpc-url "$(m .rpc_url)" --network-passphrase "$(m .network_passphrase)")
|
|
56
|
+
registry="$(m .registry.id)"
|
|
57
|
+
[[ "$registry" =~ ^C[A-Z2-7]{55}$ ]] || { echo "error: bad registry id '$registry'" >&2; exit 1; }
|
|
58
|
+
|
|
59
|
+
sha256() { if command -v sha256sum >/dev/null; then sha256sum "$1" | cut -d' ' -f1; else shasum -a 256 "$1" | cut -d' ' -f1; fi; }
|
|
60
|
+
if $checkout; then
|
|
61
|
+
(cd "$repo_root" && cargo build -q -p perch-derive-id)
|
|
62
|
+
derive() { "$repo_root/target/debug/perch-derive-id" content "$registry" "$1" "$(m .network_passphrase)"; }
|
|
63
|
+
else
|
|
64
|
+
derive() { node "$repo_root/dist/cli/derive-id.js" content "$registry" "$1" "$(m .network_passphrase)"; }
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
fetch() { # contract-name out-file
|
|
68
|
+
local name="$1" out="$2" hash addr
|
|
69
|
+
hash="$(jq -r --arg n "$name" '.contracts[$n].sha256 // empty' "$manifest")"
|
|
70
|
+
[ -n "$hash" ] || { echo "error: $name is not in the manifest" >&2; exit 1; }
|
|
71
|
+
addr="$(jq -r --arg n "$name" '.contracts[$n].address // empty' "$manifest")"
|
|
72
|
+
if [ -n "$addr" ]; then
|
|
73
|
+
[ "$(derive "$hash")" = "$addr" ] || {
|
|
74
|
+
echo "error: $name: $addr is not the content address of $hash under $registry" >&2
|
|
75
|
+
exit 1
|
|
76
|
+
}
|
|
77
|
+
stellar contract fetch "${net[@]}" --id "$addr" --out-file "$out"
|
|
78
|
+
else
|
|
79
|
+
stellar contract fetch "${net[@]}" --wasm-hash "$hash" --out-file "$out"
|
|
80
|
+
fi
|
|
81
|
+
[ "$(sha256 "$out")" = "$hash" ] || {
|
|
82
|
+
echo "error: $name: fetched $(sha256 "$out"), manifest says $hash" >&2
|
|
83
|
+
rm -f "$out"
|
|
84
|
+
exit 1
|
|
85
|
+
}
|
|
86
|
+
printf ' %s %s\n' "$hash" "${out#"$repo_root"/}" >&2
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
pin() { # crate names...
|
|
90
|
+
local dir="$repo_root/crates/$1/wasm" name
|
|
91
|
+
shift
|
|
92
|
+
mkdir -p "$dir"
|
|
93
|
+
printf '%s' "$registry" >"$dir/stateless.id"
|
|
94
|
+
for name in "$@"; do fetch "$name" "$dir/$name.wasm"; done
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if $checkout; then
|
|
98
|
+
echo "fetching pins from $(basename "$manifest") (registry $registry) ..." >&2
|
|
99
|
+
pin perch-smart-account perch-doc-compiler perch-interpreter perch-spending-limit
|
|
100
|
+
pin perch-account-factory perch-account perch-webauthn-verifier
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
if [ -n "$stack" ]; then
|
|
104
|
+
mkdir -p "$stack"
|
|
105
|
+
for name in $(m '.contracts | keys[]'); do
|
|
106
|
+
fetch "$name" "$stack/${name//-/_}.wasm"
|
|
107
|
+
done
|
|
108
|
+
jq '{registry: .registry.id, source, toolchain,
|
|
109
|
+
artifacts: [.contracts | to_entries[] |
|
|
110
|
+
{package: .key, version: .value.version, wasm: (.key | gsub("-"; "_") + ".wasm"),
|
|
111
|
+
sha256: .value.sha256, bytes: .value.bytes, tier: .value.tier,
|
|
112
|
+
pins: (.value.pins // {})}]}' "$manifest" >"$stack/build.json"
|
|
113
|
+
echo "wrote ${stack%/}/build.json" >&2
|
|
114
|
+
fi
|