Skip to main content

ant_node/pointer/
mod.rs

1//! Pointers — paid mutable references with an immutable owner.
2//!
3//! Implements `docs/adr/ADR-0016-pointers-immutable-owner.md`.
4//!
5//! A pointer is a mutable, owner-signed reference stored at an address derived
6//! from the owner's public key. Ownership is fixed at creation: there is no
7//! transfer, no lineage, no certificates and no key rotation. That choice is
8//! what lets the design be this small — the owner key is inlined in the
9//! record, so validating a pointer needs nothing but the pointer.
10//!
11//! # What lives here
12//!
13//! The record itself is a **wire type** and lives in
14//! [`ant_protocol::pointer`]: its encoding, identifiers and merge rule are
15//! things the client and the node must agree on byte for byte. This module is
16//! the node's half.
17//!
18//! - [`store`] — durable storage with merge-on-put, which is the part the
19//!   immutable chunk store cannot do.
20//! - [`service`] — the request handler: validate, check payment, merge.
21//!
22//! # The two identifiers
23//!
24//! | Name | Derivation | Job |
25//! |---|---|---|
26//! | `A` | `derive_key("autonomi.pointer.address.v1", owner)` | routes, and decides which nodes are responsible |
27//! | `state_id` | `derive_key("autonomi.pointer.state.v1", body)` | names the state, and is what a quote is paid against |
28//!
29//! BLAKE3's derive-key mode, not a hash of a prefix and the input. A chunk is
30//! addressed by a plain hash of its content, so a prefix would put both of
31//! these inside the chunk address space for anyone who could write the
32//! preimage — squatting an address before its owner used it, or buying a
33//! pointer and a chunk with one payment. The two modes still share a 32-byte
34//! range; what changed is that crossing it is a preimage problem.
35//!
36//! They are separate because `A` must be stable for the pointer's life while
37//! the paid identifier must change with every update, or updates after the
38//! first would be free — the 1.0 defect this design exists to fix.
39//!
40//! # Why the merge rule ignores signature bytes
41//!
42//! ML-DSA signing in `saorsa-pqc` is randomized and exposes no deterministic
43//! mode, so one authenticated state has unboundedly many valid encodings. A
44//! merge rule that ordered record *bytes* would let an owner sign one paid
45//! state repeatedly, sort worst-first, and have every submission win —
46//! unbounded storage, replication and Merkle-rebuild work for a single
47//! payment. So equal state never replaces, and replicas may legitimately hold
48//! different encodings of one state. Nothing compares record bytes across
49//! replicas; `state_id` is compared instead.
50
51pub mod service;
52pub mod store;
53
54pub use ant_protocol::pointer::{
55    pointer_address, state_id_for_body, ParsedPointer, Pointer, PointerError, PointerState,
56    PointerTarget, PointerTargetKind, DATA_TYPE_POINTER, POINTER_BODY_LEN, POINTER_FORMAT_VERSION,
57    POINTER_WIRE_LEN, TARGET_WIRE_LEN,
58};
59pub use service::PointerService;
60pub use store::{PointerStore, PutOutcome};