@zktable/circuits 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 +21 -0
- package/README.md +40 -0
- package/card_membership/Nargo.toml +8 -0
- package/card_membership/src/main.nr +106 -0
- package/dice_valid/Nargo.toml +8 -0
- package/dice_valid/src/main.nr +104 -0
- package/dist/index.cjs +304 -0
- package/dist/index.d.cts +89 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +265 -0
- package/move_along/Nargo.toml +8 -0
- package/move_along/fixtures/test_graph.json +13 -0
- package/move_along/src/main.nr +73 -0
- package/move_along/target/move_along.json +1 -0
- package/move_along/target/vk +0 -0
- package/move_along/target/vk_fields.json +1 -0
- package/package.json +42 -0
- package/scripts/build_all.sh +174 -0
- package/scripts/build_one.sh +11 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
NOIR_VERSION="1.0.0-beta.9"
|
|
5
|
+
BB_VERSION="v0.87.0"
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
9
|
+
REPO_ROOT="$(cd "${ROOT}/.." && pwd)"
|
|
10
|
+
|
|
11
|
+
export PATH="$HOME/.nargo/bin:$HOME/.bb/bin:$PATH"
|
|
12
|
+
|
|
13
|
+
install_nargo() {
|
|
14
|
+
if command -v nargo >/dev/null 2>&1; then return; fi
|
|
15
|
+
|
|
16
|
+
echo "• installing nargo ${NOIR_VERSION}"
|
|
17
|
+
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | \
|
|
18
|
+
NOIR_VERSION="${NOIR_VERSION}" bash
|
|
19
|
+
export PATH="$HOME/.nargo/bin:$PATH"
|
|
20
|
+
[ -n "${GITHUB_PATH:-}" ] && echo "$HOME/.nargo/bin" >> "$GITHUB_PATH"
|
|
21
|
+
noirup -v "${NOIR_VERSION}"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
install_bb() {
|
|
25
|
+
if command -v bb >/dev/null 2>&1; then return; fi
|
|
26
|
+
|
|
27
|
+
echo "• installing bb ${BB_VERSION}"
|
|
28
|
+
mkdir -p "$HOME/.bb/bin"
|
|
29
|
+
|
|
30
|
+
uname_s=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
31
|
+
uname_m=$(uname -m)
|
|
32
|
+
case "${uname_s}_${uname_m}" in
|
|
33
|
+
linux_x86_64) file="barretenberg-amd64-linux.tar.gz" ;;
|
|
34
|
+
darwin_arm64) file="barretenberg-arm64-darwin.tar.gz" ;;
|
|
35
|
+
darwin_x86_64) file="barretenberg-amd64-darwin.tar.gz" ;;
|
|
36
|
+
*) echo "unsupported platform"; exit 1 ;;
|
|
37
|
+
esac
|
|
38
|
+
|
|
39
|
+
url="https://github.com/AztecProtocol/aztec-packages/releases/download/${BB_VERSION}/${file}"
|
|
40
|
+
curl -L "$url" -o /tmp/bb.tar.gz
|
|
41
|
+
tar -xzf /tmp/bb.tar.gz -C "$HOME/.bb/bin"
|
|
42
|
+
chmod +x "$HOME/.bb/bin/bb"
|
|
43
|
+
export PATH="$HOME/.bb/bin:$PATH"
|
|
44
|
+
[ -n "${GITHUB_PATH:-}" ] && echo "$HOME/.bb/bin" >> "$GITHUB_PATH"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
run_tornado_public_inputs_generation() {
|
|
48
|
+
local manifest_path="${REPO_ROOT}/contracts/tornado_classic/contracts/Cargo.toml"
|
|
49
|
+
if [[ ! -f "${manifest_path}" ]]; then
|
|
50
|
+
echo "skip tornado public input generation (missing ${manifest_path})"
|
|
51
|
+
return
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
echo "[tornado] generating Prover.toml inputs (seed=${TORNADO_SEED:-1})"
|
|
55
|
+
(
|
|
56
|
+
cd "${REPO_ROOT}"
|
|
57
|
+
TORNADO_GENERATE=1 TORNADO_SEED="${TORNADO_SEED:-1}" \
|
|
58
|
+
cargo run \
|
|
59
|
+
--example populate_publics \
|
|
60
|
+
--manifest-path contracts/tornado_classic/contracts/Cargo.toml \
|
|
61
|
+
--features std
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
build_circuit() {
|
|
66
|
+
local name="$1"
|
|
67
|
+
local dir="${ROOT}/${name}"
|
|
68
|
+
local nargo_bin bb_bin project_name json gz
|
|
69
|
+
|
|
70
|
+
[[ -f "${dir}/Nargo.toml" ]] || {
|
|
71
|
+
echo "skip ${name} (no Nargo.toml)"
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
echo "=== Building ${name} ==="
|
|
76
|
+
pushd "${dir}" >/dev/null
|
|
77
|
+
|
|
78
|
+
if [[ "${name}" == "tornado" && "${GENERATE_PROVER:-1}" != "0" ]]; then
|
|
79
|
+
run_tornado_public_inputs_generation
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
nargo_bin="${NARGO:-$(command -v nargo || true)}"
|
|
83
|
+
bb_bin="${BB:-$(command -v bb || true)}"
|
|
84
|
+
if [[ -z "${nargo_bin}" || -z "${bb_bin}" ]]; then
|
|
85
|
+
echo "missing nargo or bb in PATH"
|
|
86
|
+
popd >/dev/null
|
|
87
|
+
exit 1
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
if [[ ! -f Prover.toml ]]; then
|
|
91
|
+
"${nargo_bin}" check --overwrite
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
"${nargo_bin}" compile
|
|
95
|
+
"${nargo_bin}" execute
|
|
96
|
+
|
|
97
|
+
project_name=$(grep -E '^name\s*=\s*"' Nargo.toml | head -n1 | sed -E 's/.*"([^"]+)".*/\1/')
|
|
98
|
+
json="target/${project_name}.json"
|
|
99
|
+
gz="target/${project_name}.gz"
|
|
100
|
+
|
|
101
|
+
if [[ ! -f "${json}" || ! -f "${gz}" ]]; then
|
|
102
|
+
echo "missing ACIR (${json}) or witness (${gz})"
|
|
103
|
+
popd >/dev/null
|
|
104
|
+
exit 1
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
"${bb_bin}" prove \
|
|
108
|
+
--scheme ultra_honk \
|
|
109
|
+
--oracle_hash keccak \
|
|
110
|
+
--bytecode_path "${json}" \
|
|
111
|
+
--witness_path "${gz}" \
|
|
112
|
+
--output_path target \
|
|
113
|
+
--output_format bytes_and_fields
|
|
114
|
+
|
|
115
|
+
"${bb_bin}" write_vk \
|
|
116
|
+
--scheme ultra_honk \
|
|
117
|
+
--oracle_hash keccak \
|
|
118
|
+
--bytecode_path "${json}" \
|
|
119
|
+
--output_path target \
|
|
120
|
+
--output_format bytes_and_fields
|
|
121
|
+
|
|
122
|
+
if [[ "${name}" == "tornado" && "${GENERATE_PROVER:-1}" != "0" ]]; then
|
|
123
|
+
echo "=== Generating E2E artifacts for tornado ==="
|
|
124
|
+
(
|
|
125
|
+
cd "${REPO_ROOT}"
|
|
126
|
+
TORNADO_EMPTY_TREE=1 cargo run \
|
|
127
|
+
--example populate_publics \
|
|
128
|
+
--manifest-path contracts/tornado_classic/contracts/Cargo.toml \
|
|
129
|
+
--features std
|
|
130
|
+
)
|
|
131
|
+
"${nargo_bin}" execute
|
|
132
|
+
"${bb_bin}" prove \
|
|
133
|
+
--scheme ultra_honk \
|
|
134
|
+
--oracle_hash keccak \
|
|
135
|
+
--bytecode_path "${json}" \
|
|
136
|
+
--witness_path "${gz}" \
|
|
137
|
+
--output_path target/e2e \
|
|
138
|
+
--output_format bytes_and_fields
|
|
139
|
+
fi
|
|
140
|
+
|
|
141
|
+
if [[ -d target/vk_fields.json && -f target/vk_fields.json/vk_fields.json ]]; then
|
|
142
|
+
mv target/vk_fields.json/vk_fields.json target/vk_fields.json.tmp
|
|
143
|
+
rmdir target/vk_fields.json
|
|
144
|
+
mv target/vk_fields.json.tmp target/vk_fields.json
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
if [[ -d target/vk && -f target/vk/vk ]]; then
|
|
148
|
+
mv target/vk/vk target/vk.tmp
|
|
149
|
+
rmdir target/vk
|
|
150
|
+
mv target/vk.tmp target/vk
|
|
151
|
+
fi
|
|
152
|
+
|
|
153
|
+
popd >/dev/null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
install_nargo
|
|
157
|
+
install_bb
|
|
158
|
+
|
|
159
|
+
if [[ "$#" -gt 0 ]]; then
|
|
160
|
+
TARGETS=("$@")
|
|
161
|
+
else
|
|
162
|
+
TARGETS=()
|
|
163
|
+
while IFS= read -r line; do
|
|
164
|
+
TARGETS+=("$line")
|
|
165
|
+
done < <(
|
|
166
|
+
find "$ROOT" -mindepth 1 -maxdepth 1 -type d \
|
|
167
|
+
! -name scripts \
|
|
168
|
+
-exec sh -c '[ -f "$1/Nargo.toml" ] && basename "$1"' _ {} \;
|
|
169
|
+
)
|
|
170
|
+
fi
|
|
171
|
+
|
|
172
|
+
for name in "${TARGETS[@]}"; do
|
|
173
|
+
build_circuit "$name"
|
|
174
|
+
done
|