Skip to main content

zeropx-layercomp

Algebraic composition of defense-in-depth layers. Pick the right operator (min, sum-dB, or max) based on the threat model — not by habit.

Why

There is a subtle but consequential inconsistency in how the literature composes layered defenses:

  • ZK / cryptographic security uses λ_efetiva = min{λ_alg, λ_FRI, λ_hash, ...} — the weakest link.
  • EM shielding / passive attenuation uses SE_total_dB = SE_1 + SE_2 + ... — additive in decibels (product in linear).
  • Consensus systems use max — you fail only if the majority does.

The same word "defense-in-depth" describes all three, but the arithmetic is different, and the wrong choice can inflate a bound by orders of magnitude.

layercomp implements the decision tree and lets you feed a stack description and get the correctly composed score, with an explanation of which operator was used and why.

Install

pip install zeropx-layercomp

(Python import module: layercomp | CLI command: layercomp)

Zero runtime dependencies. Python 3.10+.

Quick start

Describe your stack in a JSON file:

{
  "layers": [
    { "name": "arithmetization", "score": 128, "unit": "bits", "threat_model": "adversarial" },
    { "name": "FRI",              "score": 100, "unit": "bits", "threat_model": "adversarial" },
    { "name": "Poseidon2",        "score":  95, "unit": "bits", "threat_model": "adversarial",
      "notes": "BBLP22 instance ~2^95, marked Unresolved by Least Authority" }
  ]
}

Then:

layercomp score my-zk-stack.json

Output:

layercomp v0.1.0

Composition result
  operator:   min
  total:      95 bits
  determined: Poseidon2

Rationale: adversarial threat model — attacker selects weakest layer.
Composition is the minimum score across layers.

Per-layer:
   arithmetization: 128 bits [adversarial, indep=True]
   FRI: 100 bits [adversarial, indep=True]
 * Poseidon2: 95 bits [adversarial, indep=True] — BBLP22 instance ~2^95, marked Unresolved by Least Authority

Decision tree

layercomp explain

Prints:

1. Any layer ADVERSARIAL or mixed → min (most conservative)
2. All CONSENSUS → max (honest-majority)
3. All PASSIVE and all independent → sum-in-dB
4. PASSIVE but dependent → downgrade to min with warning

The common mistake this fixes

Two frameworks routinely conflate these operators:

  • Container hardening scored with SE_container = SE_ns + SE_cgroup + SE_seccomp + SE_net is wrong under the adversarial model (attacker needs to escape one namespace, not all). It should be min(...).
  • Meanwhile, sum-in-dB is the right composition for a Faraday cage against a passive EM leakage — the field really is attenuated through every layer in series.

The distinction is who is choosing the attack path: an adversary chooses the weakest link; nature/noise flows through everything.

As a library

from layercomp import Layer, ThreatModel, ScoreUnit, compose

result = compose([
    Layer("arithmetization", 128, ScoreUnit.BITS, ThreatModel.ADVERSARIAL),
    Layer("FRI",              100, ScoreUnit.BITS, ThreatModel.ADVERSARIAL),
    Layer("Poseidon2",         95, ScoreUnit.BITS, ThreatModel.ADVERSARIAL),
])

print(result.total)              # 95
print(result.operator_used)      # 'min'
print(result.layer_that_determined)  # 'Poseidon2'
print(result.rationale)          # human-readable explanation

Testing

pip install -e ".[test]"
python -m pytest tests/ -v

Companion tools

zeropx-layercomp is part of the ZeroPx Auditor's Toolkit of zero-dependency Python packages:

  • zeropx-gguf-inspect — static read-only inspection of GGUF model files without loading them
  • zeropx-corpus-scan — byte-honest SHA-256 inventory of a document corpus
  • zeropx-receipt-chain — append-only tamper-evident event ledger
  • zeropx-poseidon2-goldilocks — pure-Python Poseidon2 reference implementation over Goldilocks

Author & Provenance

Sole Author: Dr. Vander Geraldo Rodrigues da Cunha Júnior (vgrcjr@gmail.com).

Technical & AI-Assisted Provenance Disclosure: Auxiliary computational/LLM tooling was used strictly for boilerplate and test-harness scaffolding under 1:1 human architectural design, algebraic verification, code review, and sole human authorship. Zero runtime third-party or AI dependencies.

License

MIT.

Metadata

Release files for zeropx-layercomp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zeropx-layercomp 0.1.0
File Size Uploaded Provenance Actions
zeropx_layercomp-0.1.0.tar.gz 8.8 kB Without provenance Details for zeropx_layercomp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zeropx-layercomp 0.1.0
File Interpreter ABI Platform Actions
zeropx_layercomp-0.1.0-py3-none-any.whl Python 3 none any Details for zeropx_layercomp-0.1.0-py3-none-any.whl

Total release size: 17.9 kB

Release files / zeropx_layercomp-0.1.0.tar.gz

Download URL zeropx_layercomp-0.1.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
499efb28a0ef5600bbe7f1c9ef949ce5737dd4fc79fbb5dc9bb2e337a2fb59c9
BLAKE2b-256 checksum
How to use checksums
d909853f6f13b959b40436934cf3059a76ccdc574a9aaeacbbafac7fb986168a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / zeropx_layercomp-0.1.0-py3-none-any.whl

Download URL zeropx_layercomp-0.1.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36e8742eedb3df6baa091782bb4eee94a8a34d74b7f43e52f1c3ed8bc361d8a8
BLAKE2b-256 checksum
How to use checksums
43883a336090183ae323424346314d3434ad2c2377fa4023798005fae57591f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for zeropx-layercomp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page