-
Notifications
You must be signed in to change notification settings - Fork 41
ci: field-separation guard + per-backend standalone builds #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BornPsych
wants to merge
2
commits into
main
Choose a base branch
from
ci/field-separation-guard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+135
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Field-backend dependency-separation guard (fail-closed): the 64-bit Goldilocks | ||
| # backend must never pull a bn254/256-bit crate, and neither backend may depend on | ||
| # the other. A --all-features build cannot catch this; this can. | ||
| set -euo pipefail | ||
|
|
||
| # Workspace-local crates the Goldilocks graph may contain (field-agnostic spine + | ||
| # the backend itself). Every bn254-specific workspace crate is a local path dep, | ||
| # so any one leaking in trips this allowlist with zero list maintenance. | ||
| ALLOWED_LOCAL='provekit-backend-goldilocks provekit-common provekit-prover provekit-verifier' | ||
|
|
||
| # External bn254/256-bit families the allowlist can't see (crates.io / git deps): | ||
| # curve stacks and the Noir/Mavros frontend. Defense-in-depth; extend as needed. | ||
| FORBIDDEN_EXTERNAL='^(ark-bn254|ark-ec|ark-poly|ark-grumpkin|grumpkin|k256|p256|ecdsa|elliptic-curve|crypto-bigint|primefield|primeorder|sec1|rfc6979|acir|acir_field|acvm|acvm_blackbox_solver|brillig|brillig_vm|nargo|noirc_abi|noirc_printable_type|noirc_span|mavros-vm|mavros-artifacts|mavros-opcode-gen) ' | ||
|
|
||
| backend_tree() { | ||
| # Fail closed: a cargo-tree error or empty graph means we never inspected it. | ||
| local pkg="$1" out | ||
| if ! out=$(cargo tree -p "$pkg" -e normal --prefix none); then | ||
| echo "ERROR: 'cargo tree -p $pkg' failed; cannot verify field separation." >&2 | ||
| exit 1 | ||
| fi | ||
| if [[ -z "$out" ]]; then | ||
| echo "ERROR: 'cargo tree -p $pkg' returned an empty graph." >&2 | ||
| exit 1 | ||
| fi | ||
| printf '%s\n' "$out" | ||
| } | ||
|
|
||
| gold=$(backend_tree provekit-backend-goldilocks) | ||
| bn254=$(backend_tree provekit-backend-bn254) | ||
|
|
||
| fail=0 | ||
|
|
||
| # (1) Allowlist: local path deps render as "name vX.Y.Z (/abs/path)". | ||
| while read -r name; do | ||
| [[ -z "$name" ]] && continue | ||
| if [[ " $ALLOWED_LOCAL " != *" $name "* ]]; then | ||
| echo "ERROR: goldilocks backend pulls a non-spine workspace crate: $name" >&2 | ||
| fail=1 | ||
| fi | ||
| done < <(grep -E ' \(/' <<<"$gold" | awk '{print $1}' | sort -u) | ||
|
|
||
| # (2) Denylist: external bn254/256-bit families. | ||
| leak=$(sort -u <<<"$gold" | grep -E "$FORBIDDEN_EXTERNAL" || true) | ||
| if [[ -n "$leak" ]]; then | ||
| echo "ERROR: goldilocks backend leaked bn254/256-bit external crates:" >&2 | ||
| printf '%s\n' "$leak" >&2 | ||
| fail=1 | ||
| fi | ||
|
|
||
| # (3) Cross-backend: neither may depend on the other. | ||
| if grep -qE '^provekit-backend-bn254 ' <<<"$gold"; then | ||
| echo 'ERROR: goldilocks backend depends on the bn254 backend.' >&2 | ||
| fail=1 | ||
| fi | ||
| if grep -qE '^provekit-backend-goldilocks ' <<<"$bn254"; then | ||
| echo 'ERROR: bn254 backend depends on the goldilocks backend.' >&2 | ||
| fail=1 | ||
| fi | ||
|
|
||
| if [[ "$fail" -ne 0 ]]; then | ||
| exit 1 | ||
| fi | ||
| echo 'OK: field-backend dependency separation holds.' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.