{"id":31923893,"url":"https://github.com/chainsafe/spectre","last_synced_at":"2025-10-13T23:58:42.349Z","repository":{"id":217675772,"uuid":"675759774","full_name":"ChainSafe/Spectre","owner":"ChainSafe","description":"ZK coprocessor for verifying Beacon chain headers via Altair lightclient protocol  ","archived":false,"fork":false,"pushed_at":"2024-09-30T06:30:45.000Z","size":30746,"stargazers_count":61,"open_issues_count":3,"forks_count":12,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-10-02T02:53:34.619Z","etag":null,"topics":["consensus","cryptography","ethereum","halo2","zero-knowledge","zk"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChainSafe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-07T16:50:32.000Z","updated_at":"2025-03-23T11:46:25.000Z","dependencies_parsed_at":"2024-08-28T16:14:18.109Z","dependency_job_id":null,"html_url":"https://github.com/ChainSafe/Spectre","commit_stats":null,"previous_names":["chainsafe/spectre"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ChainSafe/Spectre","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2FSpectre","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2FSpectre/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2FSpectre/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2FSpectre/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChainSafe","download_url":"https://codeload.github.com/ChainSafe/Spectre/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2FSpectre/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017175,"owners_count":26086019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["consensus","cryptography","ethereum","halo2","zero-knowledge","zk"],"created_at":"2025-10-13T23:58:24.870Z","updated_at":"2025-10-13T23:58:42.344Z","avatar_url":"https://github.com/ChainSafe.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spectre\n\nSpectre is a Zero-Knowledge (ZK) coprocessor designed to offload intensive computations from the resource-limited execution layer of target chains. Iit offers a trust-minimized method for verifying block headers, adhering to the consensus rules of the originating chain.\n\nThe type of outsourced computation is specific to the arithmetic circuits. For Spectre, its primary function is to verify the Ethereum LightClient protocol introduced in the Altair hardfork.\n\n## Requirements\n- Rust `1.73.0-nightly`\n- Packages `build-essential` `clang` `pkg-config` `libssl-dev`\n- [Foundry](https://book.getfoundry.sh/getting-started/installation)\n- [Just](https://just.systems/man/en/)\n\n## Technical details\n\nSpectre prover utilizes the Halo2 proving stack ([`privacy-scaling-explorations/halo2`](https://github.com/privacy-scaling-explorations/halo2) fork).\n\nCircuits are implemented with the [`halo2-lib`](https://github.com/axiom-crypto/halo2-lib) circuit development framework. This library contains a number of non-trivial optimization tricks, while its readable SDK prevents most of the soundness bugs and improves auditability. Our team has contributed a number of features back to the halo2-lib repository, containing some foundational cryptographic primitives powering Ethereum consensus.\n\nVerifier contracts for consensus proofs are auto-generated via the [`privacy-scaling-explorations/snark-verifier`](https://github.com/privacy-scaling-explorations/snark-verifier). We aslo support [`privacy-scaling-explorations/halo2-solidity-verifier`](https://github.com/privacy-scaling-explorations/halo2-solidity-verifier) behind `experimental` flag. Supplemental contract logic has been introduced exclusively to manage intermediary states during proof verifications.\n\n## Usage\n\n### Before build\n\nSpectre uses `abigen` macro to generate smart contract types and `rstest` for consensus spec tests. To ensure that all the necessary data for macros expansion is present during first build or testing, please run:\n\n```\ngit submodule update --init --recursive\njust build-contracts\njust download-spec-tests\n``` \n\n### Setup circuits\n\n#### Step circuit\n\n```shell\ncargo run -r -p spectre-prover -- circuit sync-step-compressed -k 20 -p ./build/sync_step_20.pkey -K 23 -P ./build/sync_step_verifier_23.pkey -L 19 setup\n```\nFlags `-k` and `-K` are circuit degrees for first and aggregation (compression) stage respectively. `-L` is the number lookup bits used in aggregation stage.\n\n#### Committee update circuit\n\n```shell\ncargo run -r -p spectre-prover -- circuit committee-update -k 20 -p ./build/committee_update_20.pkey -K 24 -P ./build/committee_update_verifier_20.pkey setup\n```\n\nAlternatively, you can use `just` recipes as shown below.\n\n```shell\njust setup-step-compressed testnet\njust setup-committee-update testnet\n```\n\n### Generates verifier contracts\n\n#### Step proof\n\n```shell\ncargo run -r -p spectre-prover -- circuit sync-step-compressed -p ./build/sync_step_20.pkey -P ./build/sync_step_verifier_23.pkey gen-verifier -o ./contracts/snark-verifiers/sync_step_verifier.sol\n```\n\n#### Committee update proof\n\n```shell\ncargo run -r -p spectre-prover -- circuit committee-update -p ./build/committee_update_20.pkey -P ./build/committee_update_verifier_24.pkey gen-verifier -o ./contracts/snark-verifiers/committee_update_verifier.sol\n```\n\nOr use `just` recipes as shown below.\n\n```shell\njust gen-verifier-step-compressed testnet\njust gen-verifier-committee-update testnet\n```\n\n### Deploying contracts\n\nJust scripts are provided to deploy the contracts either to a local testnet, or public networks.\n\nFor either make a copy of the `.env.example` file called `.env`. Set the `INITIAL_SYNC_PERIOD`, `INITIAL_COMMITTEE_POSEIDON` and `SLOTS_PER_PERIOD` variables according to the network you want Spectre to act as a light-client for and the starting point.\n\nTo get the `INITIAL_COMMITTEE_POSEIDON` value, run:\n\n```shell\ncargo run -r -p spectre-prover -- utils committee-poseidon --beacon-api https://lodestar-sepolia.chainsafe.io\n```\n\n`--beacon-api` is a URL of the RPC of the targeted Beacon chain.\n\n#### Deploying locally\n\n1. Start a local anvil instance with:\n\n```shell\nanvil\n```\n\n2. Copy one of the private key strings printed into the `DEPLOYER_PRIVATE_KEY` in the `.env` file then run \n\n```shell\njust deploy-contracts-local\n```\n\n#### Deploying to a public network\n\n1. Obtain the required gas token and obtain the private key for the deployer account. Set the `DEPLOYER_PRIVATE_KEY` in the `.env` file.\n2. Obtain a public RPC URL for the network and set the variable `\u003cNETWORK\u003e_RPC_URL` in the `.env` file (If using Infura this will require an API key)\n3. Run\n\n```shell\njust deploy-contracts \u003cNETWORK\u003e\n```\n\nwhere `\u003cNETWORK\u003e` is one of `[\"GOERLI\", \"SEPOLIA\", \"MAINNET\"]`.\n\n### Running the prover\n\nProver is accessible via JSON RPC interface. To start it, run:\n\n```shell\ncargo run -r -p spectre-prover -- rpc --port 3000 --spec testnet\n```\nwhere `--spec` is one of `[\"testnet\", \"mainnet\"]`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainsafe%2Fspectre","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainsafe%2Fspectre","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainsafe%2Fspectre/lists"}