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