Skip to content

How it works

How Tell works

Midnight proves a circuit ran correctly over private inputs. The proof hides the inputs, but the transaction still carries a public transcript: every ledger read and write, with its operands. Tell asks one question of each contract: what can someone reading that transcript work out about the private inputs?

  1. 01

    Compile with the real compiler

    Tell reads the contract’s pragma and runs the Compact compiler that accepts it, preferring 0.31.1 for Ledger 8 contracts and using 0.36.0 for Ledger 9 (mainnet since November 6, 2026: events and cross-contract calls), and falling back through every other version the pragma allows. No proving keys are built, so this takes about a second.

    compactc --trace-passes --skip-zk contract.compact
  2. 02

    Take the compiler’s own circuit form

    Among the compiler’s passes is reduce-to-circuit: helper circuits inlined, loops unrolled, every step a guarded binding. Tell reads exactly this, so it sees the contract the way the proof does, never a re-implementation of Compact. Constructors are not proved and never reach that pass, so Tell takes them from drop-safe-casts and lowers them to the same form.

    (= %guard %t.12 (public-ledger %ballots insert %tag %h))
  3. 03

    Trace every private input

    Witness results and circuit arguments are private by Compact’s rules. Tell follows each one through hashes, commitments, comparisons, struct fields and branches, keeping track of how much of it survives: the value itself, a guessable function of it, a yes/no fact, or nothing.

    c = choice(): Uint<8>; assert(c < 4) → persistentHash → 2 unknown bits
  4. 04

    Read the public transcript

    Every ledger operation is public: its operands, and whether it ran at all. So are the initial state a constructor writes, events (emit) and the arguments of cross-contract calls on Ledger 9. Each operand and each branch guard is checked against the traced inputs.

    ballots.insert(tag, hash(choice)) → guessable, 4 guesses
  5. 05

    Grade and report

    Findings are grouped per idea, pinned to a source line, graded A to F, and exported as text, JSON or SARIF for GitHub code scanning. For guessable hashes, secrets in the clear, the same tag on every action, branches and personal values, Tell also writes a patch, compiles it and scans it again; it offers the patch only if the finding is gone and nothing new appears at medium or worse.

    grade F · 1 critical · ballot-leaky.compact:36

What Tell reports

FindingSeverityMeaning
Guessable hashcritical / highA hash or commitment whose only unknown input is small: a vote, an age, a salary, a location. Brute force recovers it. Critical up to 40 bits. assert(x < N) counts: a vote among four candidates is 2 bits, whatever its type.
Secret in the clearcritical / highA secret key reaches the ledger as a readable value, or is returned from a circuit; or a value the contract hashes as a key somewhere is written raw somewhere else.
Private bytes or personal data in the clearmediumA seed or private key written as-is (seed, key, secret, sk: not a public key, id or commitment); a salary, an age or a location written as a readable value.
Secret-dependent branchmedium / lowWhich ledger operations run depends on a private value. Includes count leaks: a fixed-size loop that only touches the ledger for used slots. Low when nothing in the circuit identifies the caller (an anonymous tally).
Same tag on every actionmediumEach repeated action stores the same hash of a key, so one identified action unmasks the rest.
Wallet key publishedmedium / lowA user’s ownPublicKey() is stored, tying all their activity to one wallet. Low when it is an officer key set once (owner, authority).
Linkable taglow / infoThe same hash of a key is published by several circuits, tying a user’s transactions together. Fine for registrations and nullifiers.
Published valuelow / infoA private input is written as a readable value. Usually on purpose; listed so nothing is hidden.
Published yes/no factinfoA comparison over a private value is stored: one bit per call.

Grades: F for any critical, D for any high, C for any medium, B for low notes only, A otherwise.

What Tell deliberately does not flag

Each of these rules came from reading real contracts in the survey and removing a false alarm.

  • An officer key set once (owner, authority) and access checks against it: the usual admin design.
  • A branch that runs the same operation, with the same public operands, on both paths: the transcript looks the same either way.
  • A branch on a value the circuit already publishes in the clear: nothing new is learned.
  • A commitment whose randomness is a strong private value: hiding and unlinkable.
  • Shielded-coin plumbing (coin commitments, nullifiers): the protocol’s own privacy. Whether a receive or spend happened at all is still checked, and a mint’s amount is public.
  • A Merkle root passed to checkRoot: it must equal a public root anyway.
  • An input the same call already publishes: it adds no secrecy to a hash, and is not reported twice.
  • Hashes that mix in a per-use nonce, salt or a changing counter: one-time values link nothing.
  • Branches on tree positions, division hints and the current time: public in practice, reported as low.
  • Caller-supplied arguments: as private as witnesses in Compact, but usually public inputs, so they rank one step lower. A hash of a small or personal argument is still high; one the source writes as disclose(arg) is public on purpose.

Limits

  • Tell sees the contract, not the dApp around it. A frontend that logs a secret, or a server that sees it, is out of scope.
  • It cannot read intent. A value published on purpose looks like a leak; that is why published values are info and why suppression exists.
  • Entropy comes from types, narrowed by assert(x < N) bounds and by names that mark personal data. A Bytes<32> with an unremarkable name that holds a short string is still treated as 256 bits.
  • Constructors, circuits, return values, events and cross-contract call arguments are analysed. Tell treats call arguments as public, as the compiler does; whether the callee publishes them is a question for the callee’s own scan.
  • Names still matter at the edges: officer fields (owner, authority) and personal words (salary, age) adjust severity. Raw private bytes are always listed, but are raised to medium only when the name reads as key material (seed, key, secret); a key under a neutral name shows as a published value.
  • Branches where nothing in the circuit identifies the caller are rated low. If the transaction itself identifies the caller, that rating is too low.
  • Verified patches cover guessable hashes, secrets in the clear, the same tag on every action, branches outside loops and personal values. Wallet keys, returned secrets and token operations get a fix in words only. A branch patch changes behaviour (the other path is rejected), and the report says so.
  • Tell looks for privacy leaks only. Authorization, Merkle binding and mint caps are other bug classes; Nightshade and compact-lint cover them.
  • Contracts must compile with a released compiler. Tell cannot analyse code the compiler rejects, and unreleased language versions are reported, not guessed at.

Command line

Needs Node 22+ and the Compact toolchain (compact update 0.31.1).

git clone https://github.com/RohanGlitched/tell && cd tell && npm install
npx tsx engine/src/cli.ts path/to/your/contracts          # readable report
npx tsx engine/src/cli.ts . --json > tell.json             # machine-readable
npx tsx engine/src/cli.ts . --sarif tell.sarif --fail-on high

In CI

The repository is a GitHub Action. Findings appear in the pull request and the Security tab.

# .github/workflows/tell.yml
on: [push, pull_request]
permissions: { contents: read, security-events: write }
jobs:
  tell:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: RohanGlitched/tell@v1
        with:
          path: contract
          fail-on: high

Marking a finding intended

Put tell:allow in a comment on the line Tell points at, or the line above. Name the kind to silence only that kind. Suppressed findings still appear in JSON, marked, so a reviewer can see what was waived.

// the reveal phase publishes the seed by design
seeds.insert(slot, s); // tell:allow published

Declaring intent with tell.json

Tell guesses intent from shape and names. Where you know better, say so once in a tell.json next to your contracts or at the repository root: which witnesses are secret or public, which circuits run once, which disclosures are intended and why. The CLI, the GitHub Action and the MCP server read the nearest one (--policy to choose a file, --no-policy to ignore it). In the benchmark, one line of it removed Tell’s only false alarm. The web scanner does not read a policy yet; it scans with the defaults.

{
  "witnesses": { "deviceKey": "secret", "now": "public" },
  "circuits": { "enroll": { "once": true } },
  "intended": [{ "kind": "published", "field": "winner", "reason": "the draw result is public" }]
}

Changelog

  • 2026-11Benchmark against Nightshade, compact-guard, compact-lint and OpenZeppelin’s Compact detectors on 79 files, with the bias stated first (bench/): run on the Wave 2 engine, then again on the Wave 3 engine. Tell also ran on Nightshade’s published corpus of 465 contracts without a crash.
  • 2026-11tell.json: declare which inputs are secret or public, which circuits run once and which disclosures are intended, in one file the CLI, the Action and the MCP server read.
  • 2026-11Radar: a privacy scan of Preprod contracts from chain data alone, no source needed (radar/).
  • 2026-11MCP server for coding agents (scan, explain a finding, propose a fix) and a VS Code extension that shows findings in the editor.
  • 2026-11Tell Desk: a Compact contract on Preprod for sealed, provable disclosure of a leak and an on-chain registry of grades keyed by code hash.
  • 2026-11Pull-request review in the GitHub Action: a comment on each changed line with the bits revealed and the verified fix as a suggestion, and the grade before and after in the job summary.
  • 2026-11Verified auto-fix: --fix and --fix-dry-run, and Apply fix on this site. A patch is offered only if it compiles with the same compiler, the finding is gone and nothing new appears at medium or worse.
  • 2026-11Token rules: shielded coins minted with a public nonce, private values used as public token amounts, wallet keys taken from private state.
  • 2026-11Constructors analysed: what a constructor writes is the initial public state, taken from the compiler’s drop-safe-casts pass.
  • 2026-11Compact 0.36 and Ledger 9: events and cross-contract call arguments are public sinks; a branch that picks the callee is a secret-dependent branch. The zoo gains a Ledger 9 poll pair, and CI checks the zoo under 0.30, 0.31.1, 0.34, 0.35 and 0.36.
  • 2026-10-12Severity follows what is revealed, not names: assert bounds, raw private bytes and personal data, circuit return values, guarded shielded receives, balanced and anonymous branches. Regression tests from three reviews; the zoo is checked under compilers 0.30 to 0.35 in CI; SARIF severity on rules for GitHub.
  • 2026-10-12Unshielded transfers, mints and ownPublicKey() analysed; casts are no longer read as hashes; officer keys and access checks reported low.
  • 2026-10-12Survey of every public Midnight Buildathon repository; compiler fallback across pragma ranges; count-leak wording; per-use nonce and struct-field rules.
  • 2026-10-12Web scanner with leak map; SARIF export; suppression comments.
  • 2026-10-11Engine: compiler trace reader, information flow, five finding kinds; leak zoo with attack tests.

Scan a contract · See the leak zoo