How signor1/cairo-programs works
Project type and purpose
• This is a mono-repo of example Cairo programs (“data_integrity_check”, “set_proof”, “square_root”), each defined as its own Scarb package/crate.
• Purpose: show how each program is configured, built, tested, and run (including proof generation) using the Cairo toolchain.
File structure
• Top-level: README.md describing the repo.
• Three subdirectories, each a Scarb/Cairo crate:
• data_integrity_check (has Scarb.toml, args.json, src/lib.cairo)
• set_proof (has Scarb.toml, snfoundry.toml, src/lib.cairo, tests/)
• square_root (has Scarb.toml, src/lib.cairo)
• Common patterns: every crate has a config (Scarb.toml + Scarb.lock), a src/lib.cairo, optional tests or input files.
README for additional insights
• Single-line description: “Writing provable programs utilizing cairo programming language.”
How to represent the architecture
a. Main components
• Developer Machine (IDE, CLI)
• Scarb toolchain (CLI, dependency resolver, compiler)
• Three Cairo Crates (data_integrity_check, set_proof, square_root)
• Cairo VM / Prover runtime
• (Optional) Starknet or external verifier if proofs are verified on-chain
b. Relationships & interactions
1. Developer invokes Scarb CLI on the repo root
2. Scarb reads each crate’s Scarb.toml → compiles src/lib.cairo → emits compiled artifacts (Cairo Assembly + ABI)
3. Tests folder (if present) triggers Scarb test harness, which executes Cairo VM in test mode
4. Programs (when run) feed input (e.g., args.json) into the Cairo VM → VM produces execution trace → Prover consumes trace → outputs a STARK proof
5. (Optional) Proof is submitted to or verified by an external verifier (e.g., Starknet contract)
c. Architectural patterns / design principles
• Monorepo with isolated crates
• Standard build-test pipeline via Scarb
• Clear separation between config (Toml), code (src), and tests/resources
• Data-in/out pipelined through the Cairo VM & Prover
d. Key technologies
• Cairo language (src/lib.cairo)
• Scarb – Cairo package manager / build tool (Scarb.toml, Scarb.lock)
• snfoundry (in set_proof) – test/deployment config for Starknet
• Cairo VM & STARK prover (runtime components)
Detailed component breakdown (to include
• Repository Root
• README.md
• Crate “data_integrity_check”
• Scarb.toml / Scarb.lock
• args.json (input)
• src/lib.cairo (algorithm)
• Crate “set_proof”
• Scarb.toml / Scarb.lock
• snfoundry.toml (Starknet/test config)
• src/lib.cairo
• tests/test_contract.cairo
• Crate “square_root”
• Scarb.toml / Scarb.lock
• src/lib.cairo
• Build/Test Flow
• Developer uses scarb build / scarb test → per-crate pipelines
• Runtime / Proof Flow
• Input → Cairo VM → Prover → Proof output → (Verifier)