tiny.reticulum.destination
Defined in tiny.reticulum.
How a party is named on a Reticulum mesh and everything that name carries: building the name, cutting it down to the address a header holds, the four kinds of party a name can stand for, the announcement that publishes a name, the ciphers each kind uses, and the list of names one node answers for.
API (9)
Actions
Public operations.
expandName: Writes the dotted name intooutputand returns it: the application name, then each aspect after a dot, then the identity hash in lowercase hex after another dot when the caller passes one, so a caller shows a person the full name of a destination (expanded name), following Reticulum@1.5.0 RNS/Destination.py:96-112.hash: Returns the first 16 bytes of one digest taken over the name hash followed by the identity hash, and over the name hash alone when the caller passes no identity, so a sender works out the 16-byte address to put in a packet header from the name and the owner's identity hash, following Reticulum@1.5.0 RNS/Destination.…nameHash: Returns the first 10 bytes of the SHA-256 digest of the dotted name (name hash), with no identity bytes in it, so a caller works out the ten bytes an announce publishes for a name, the same for every owner of that name, following Reticulum@1.5.0 RNS/Destination.py:120.
Types and contracts
Public types and contracts.
LimitsNameErrorType: Which of four kinds of party a destination stands for, two bits wide: one identity, a group that shares one key, a plain destination whose payload travels unsealed, or a link, following Reticulum@1.5.0 RNS/Destination.py:62-67.
Namespaces
Public namespaces.
Source
Source: lib/reticulum/src/destination/name.zig:4
pub const Limits = struct { name_bytes_max: u16,};Source: lib/reticulum/src/destination/name.zig:8
pub const NameError = error{ DotInAppName, DotInAspect, NameTooLong, OutputTooSmall,};Source: lib/reticulum/src/destination/type.zig:5
/// Which of four kinds of party a destination stands for, two bits wide: one/// identity, a group that shares one key, a plain destination whose payload/// travels unsealed, or a link, following Reticulum@1.5.0/// RNS/Destination.py:62-67.pub const Type = enum(u2) { single = 0, group = 1, plain = 2, link = 3,};Source: lib/reticulum/src/destination/name.zig:83
/// Writes the dotted name into `output` and returns it: the application name,/// then each aspect after a dot, then the identity hash in lowercase hex after/// another dot when the caller passes one, so a caller shows a person the full/// name of a destination (*expanded name*), following Reticulum@1.5.0/// RNS/Destination.py:96-112. The call returns `error.DotInAppName` or/// `error.DotInAspect` for a label holding a dot, `error.NameTooLong` when the/// name passes the caller's byte maximum, and `error.OutputTooSmall` when/// `output` is shorter than the name.pub fn expandName( limits: Limits, app: []const u8, aspects: []const []const u8, identity_hash: ?[reticulum.hash.truncated_bytes]u8, output: []u8,) NameError![]u8 { const layout = try plan(limits, app, aspects, identity_hash != null); if (output.len < layout.expanded_bytes) return error.OutputTooSmall; var cursor = writeBase(app, aspects, output); std.debug.assert(cursor == layout.base_bytes); if (identity_hash) |identity| { const encoded = std.fmt.bytesToHex(identity, .lower); append(output, &cursor, "."); append(output, &cursor, &encoded); } std.debug.assert(cursor == layout.expanded_bytes); return output[0..cursor];}Source: lib/reticulum/src/destination/name.zig:132
/// Returns the first 16 bytes of one digest taken over the name hash followed/// by the identity hash, and over the name hash alone when the caller passes no/// identity, so a sender works out the 16-byte address to put in a packet/// header from the name and the owner's identity hash, following/// Reticulum@1.5.0 RNS/Destination.py:116-130. Folding the owner's identity/// hash in gives two parties using the same dotted name two different/// addresses. The call returns `error.DotInAppName`, `error.DotInAspect`, or/// `error.NameTooLong` on the same terms as expanding a name.pub fn hash( limits: Limits, app: []const u8, aspects: []const []const u8, identity_hash: ?[reticulum.hash.truncated_bytes]u8,) NameError![reticulum.hash.truncated_bytes]u8 { const name_hash = try nameHash(limits, app, aspects); var hasher = reticulum.hash.Hasher.init(); hasher.update(&name_hash); if (identity_hash) |identity| hasher.update(&identity); return hasher.finalTruncated();}Source: lib/reticulum/src/destination/name.zig:109
/// Returns the first 10 bytes of the SHA-256 digest of the dotted name (*name/// hash*), with no identity bytes in it, so a caller works out the ten bytes an/// announce publishes for a name, the same for every owner of that name,/// following Reticulum@1.5.0 RNS/Destination.py:120. The call returns/// `error.DotInAppName`, `error.DotInAspect`, or `error.NameTooLong` on the/// same terms as expanding a name.pub fn nameHash( limits: Limits, app: []const u8, aspects: []const []const u8,) NameError![reticulum.hash.name_bytes]u8 { _ = try plan(limits, app, aspects, false); var hasher = reticulum.hash.Hasher.init(); hasher.update(app); for (aspects) |aspect| { hasher.update("."); hasher.update(aspect); } return hasher.finalName();}Source: lib/reticulum/src/destination/root.zig
//! How a party is named on a Reticulum mesh and everything that name carries://! building the name, cutting it down to the address a header holds, the four//! kinds of party a name can stand for, the announcement that publishes a name,//! the ciphers each kind uses, and the list of names one node answers for.//!//! A sender has to reach a party by a name it can work out for itself, without//! being told where that party is attached. That name has to fit in a packet//! capped at 500 bytes, beside everything else a header carries. A node has to//! know which names it answers for, in memory fixed before the program starts.//!//! A name a person can read runs to dozens of bytes, which is too much to//! repeat in every header. A name anyone can compute is a name anyone can//! claim, unless the owner's key material goes into it. A party that wants to//! be found has to say so out loud, and any node that hears it has to be able//! to check the claim without asking anyone.//!//! The subtree follows Reticulum 1.5.0, the reference implementation, pinned to//! one upstream commit by the package README and the generated conformance//! corpus. What it takes is the naming rule of Reticulum@1.5.0//! RNS/Destination.py:96-130, the four kinds of Reticulum@1.5.0//! RNS/Destination.py:62-67, the announce payload of Reticulum@1.5.0//! RNS/Destination.py:244-304, and the encryption dispatch of Reticulum@1.5.0//! RNS/Destination.py:596-665. The package generates destination and announce//! vectors from that release and replays them in tests, so each of those claims//! is checkable from this tree.//!//! The address a header carries for a party (a *destination*) is the first 16//! bytes of one digest over a 10-byte hash of the dotted name and, for a party//! with a single owner, a 16-byte hash of the owner's public key, so working//! out the address takes the dotted name and the owner's public key and nothing//! else. The signed packet a party sends to make itself known (an *announce*)//! signs bytes that open with that address, so the same signed bytes cannot be//! presented under another address. Checking an announcement recomputes the//! address from the announce's own name hash and public key and compares it//! against the address the packet was sent to. The list of names a node answers//! for is carved out of caller storage, and a duplicate or a full list is//! refused before the list changes. The subtree names its pieces: the four//! kinds, the naming rule and its hashes, announcements, the ciphers, and the//! registry.//!//! - *destination type*: which of the four kinds of party a packet addresses, a//! single identity, a group sharing one key, a plain unencrypted destination,//! or a link.//! - *name hash*: the first 10 bytes of a SHA-256 digest, the width a//! destination's announced name takes.//! - *identity hash*: the first 16 bytes of the SHA-256 digest of an owner's 64//! public key bytes, which names the owner inside a destination name.const naming = @import("name.zig");pub const Type = @import("type.zig").Type;pub const Limits = naming.Limits;pub const NameError = naming.NameError;pub const expandName = naming.expandName;pub const nameHash = naming.nameHash;pub const hash = naming.hash;pub const announce = @import("announce.zig");pub const cipher = @import("cipher.zig");pub const registry = @import("registry.zig");Source: lib/reticulum/src/root.zig:61
pub const destination = @import("destination/root.zig");Audit
| Definitions | 7 |
|---|---|
| Public names | 7 |
| Members | 9 |
| Version | 26.7.0 |
| Revision | daab053ee433 |