# 0x44-labs/rs-pbcp architecture

> Architecture diagram of the GitHub repository 0x44-labs/rs-pbcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0x44-labs/rs-pbcp
- Repository: https://github.com/0x44-labs/rs-pbcp

## Overview

PBCP is a Rust library for proof-bound claims: an issuer configures a verifier and issues an authenticated, expiring challenge; a claimant supplies claims and mines a proof; the verifier checks the challenge and proof and can reject replayed challenges. Challenges can travel as pbcp:// URIs, while claims use canonical JSON bytes and proofs/challenges use CBOR bytes. The graph reflects documented API flow and sampled calls; replay-store backend details and some serialization paths are represented only where the README or excerpts support them.

Main entry points: [`src/prover/prover.rs`](https://github.com/0x44-labs/rs-pbcp/blob/main/src/prover/prover.rs) (Prover), [`src/verifier/verifier.rs`](https://github.com/0x44-labs/rs-pbcp/blob/main/src/verifier/verifier.rs) (Verifier), [`src/verifier/challenge.rs`](https://github.com/0x44-labs/rs-pbcp/blob/main/src/verifier/challenge.rs) (Challenge model), [`src/prover/proof.rs`](https://github.com/0x44-labs/rs-pbcp/blob/main/src/prover/proof.rs) (Proof)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Protocol API"]
  node_context["PBCP context<br/>[lib.rs]"]
end

subgraph group_challenge["Challenges"]
  node_challenge_model["Challenge model<br/>[challenge.rs]"]
  node_challenge_uri["Challenge URI<br/>[challenge.rs]"]
end

subgraph group_proving["Claims And Proofs"]
  node_claims["Claims set<br/>[claims.rs]"]
  node_prover["Prover<br/>[prover.rs]"]
  node_proof["Proof<br/>[proof.rs]"]
  node_traversev["TraverseV engine"]
end

subgraph group_verification["Verification And Replay"]
  node_verifier["Verifier<br/>[verifier.rs]"]
  node_replay_store[("Replay store<br/>[store.rs]")]
end

subgraph group_common["Shared Formats"]
  node_wire["Wire serialization<br/>[wire.rs]"]
  node_counter["Work counter<br/>[counter.rs]"]
  node_errors["Protocol errors<br/>[errors.rs]"]
end

node_issuer(("Challenge issuer"))
node_claimant(("Claims claimant"))

node_issuer -->|"configures"| node_context
node_context -->|"creates"| node_verifier
node_context -->|"creates"| node_prover
node_issuer -->|"issues challenge"| node_verifier
node_verifier -->|"issues"| node_challenge_model
node_challenge_model -->|"serializes as"| node_challenge_uri
node_challenge_uri -.->|"delivers challenge"| node_claimant
node_claimant -.->|"provides"| node_claims
node_claimant -->|"uses"| node_prover
node_prover -->|"uses"| node_challenge_model
node_prover -->|"serializes"| node_claims
node_prover -->|"mines with"| node_traversev
node_prover -->|"starts counter"| node_counter
node_prover -->|"constructs"| node_proof
node_proof -->|"contains"| node_claims
node_proof -->|"contains"| node_challenge_model
node_proof -->|"encodes fields"| node_wire
node_verifier -->|"verifies"| node_proof
node_verifier -->|"authenticates"| node_challenge_model
node_verifier -->|"checks work"| node_traversev
node_verifier -.->|"checks replay"| node_replay_store
node_challenge_model -->|"encodes fields"| node_wire
node_claims -->|"returns errors"| node_errors

click node_context "https://github.com/0x44-labs/rs-pbcp/blob/main/src/lib.rs"
click node_verifier "https://github.com/0x44-labs/rs-pbcp/blob/main/src/verifier/verifier.rs"
click node_challenge_model "https://github.com/0x44-labs/rs-pbcp/blob/main/src/verifier/challenge.rs"
click node_challenge_uri "https://github.com/0x44-labs/rs-pbcp/blob/main/src/verifier/challenge.rs"
click node_claims "https://github.com/0x44-labs/rs-pbcp/blob/main/src/common/claims.rs"
click node_prover "https://github.com/0x44-labs/rs-pbcp/blob/main/src/prover/prover.rs"
click node_proof "https://github.com/0x44-labs/rs-pbcp/blob/main/src/prover/proof.rs"
click node_replay_store "https://github.com/0x44-labs/rs-pbcp/blob/main/src/verifier/store.rs"
click node_wire "https://github.com/0x44-labs/rs-pbcp/blob/main/src/common/wire.rs"
click node_counter "https://github.com/0x44-labs/rs-pbcp/blob/main/src/common/counter.rs"
click node_errors "https://github.com/0x44-labs/rs-pbcp/blob/main/src/errors.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_context toneBlue
class node_challenge_model,node_challenge_uri toneAmber
class node_claims,node_prover,node_proof,node_traversev toneMint
class node_verifier,node_replay_store toneRose
class node_wire,node_counter,node_errors,node_issuer,node_claimant toneIndigo
```

## Components

### Protocol API

- [PBCP context](https://github.com/0x44-labs/rs-pbcp/blob/main/src/lib.rs): `src/lib.rs`

### Challenges

- [Challenge model](https://github.com/0x44-labs/rs-pbcp/blob/main/src/verifier/challenge.rs): `src/verifier/challenge.rs`
- [Challenge URI](https://github.com/0x44-labs/rs-pbcp/blob/main/src/verifier/challenge.rs): `src/verifier/challenge.rs`

### Claims And Proofs

- [Claims set](https://github.com/0x44-labs/rs-pbcp/blob/main/src/common/claims.rs): `src/common/claims.rs`
- [Prover](https://github.com/0x44-labs/rs-pbcp/blob/main/src/prover/prover.rs): `src/prover/prover.rs`
- [Proof](https://github.com/0x44-labs/rs-pbcp/blob/main/src/prover/proof.rs): `src/prover/proof.rs`
- **TraverseV engine**

### Verification And Replay

- [Verifier](https://github.com/0x44-labs/rs-pbcp/blob/main/src/verifier/verifier.rs): `src/verifier/verifier.rs`
- [Replay store](https://github.com/0x44-labs/rs-pbcp/blob/main/src/verifier/store.rs): `src/verifier/store.rs`

### Shared Formats

- [Wire serialization](https://github.com/0x44-labs/rs-pbcp/blob/main/src/common/wire.rs): `src/common/wire.rs`
- [Work counter](https://github.com/0x44-labs/rs-pbcp/blob/main/src/common/counter.rs): `src/common/counter.rs`
- [Protocol errors](https://github.com/0x44-labs/rs-pbcp/blob/main/src/errors.rs): `src/errors.rs`

### Other components

- **Challenge issuer**
- **Claims claimant**

## Connections

- Challenge issuer → PBCP context: configures (evidence: `src/lib.rs`)
- PBCP context → Verifier: creates (evidence: `src/lib.rs`)
- PBCP context → Prover: creates (evidence: `src/lib.rs`)
- Challenge issuer → Verifier: issues challenge (evidence: `README.md`)
- Verifier → Challenge model: issues (evidence: `src/verifier/verifier.rs`)
- Challenge model → Challenge URI: serializes as (evidence: `src/verifier/challenge.rs`)
- Challenge URI → Claims claimant: delivers challenge (evidence: `README.md`)
- Claims claimant → Claims set: provides (evidence: `README.md`)
- Claims claimant → Prover: uses
- Prover → Challenge model: uses (evidence: `src/prover/prover.rs`)
- Prover → Claims set: serializes (evidence: `src/prover/prover.rs`)
- Prover → TraverseV engine: mines with (evidence: `src/prover/prover.rs`)
- Prover → Work counter: starts counter (evidence: `src/prover/prover.rs`)
- Prover → Proof: constructs (evidence: `src/prover/prover.rs`)
- Proof → Claims set: contains (evidence: `src/prover/proof.rs`)
- Proof → Challenge model: contains (evidence: `src/prover/proof.rs`)
- Proof → Wire serialization: encodes fields (evidence: `src/prover/proof.rs`)
- Verifier → Proof: verifies (evidence: `src/verifier/verifier.rs`)
- Verifier → Challenge model: authenticates (evidence: `src/verifier/verifier.rs`)
- Verifier → TraverseV engine: checks work (evidence: `src/verifier/verifier.rs`)
- Verifier → Replay store: checks replay (evidence: `README.md`)
- Challenge model → Wire serialization: encodes fields (evidence: `src/verifier/challenge.rs`)
- Claims set → Protocol errors: returns errors (evidence: `src/common/claims.rs`)
