Updated documentation

This commit is contained in:
Mark Qvist 2026-11-07 13:25:25 +01:00
parent acb38a8a1c
commit 65a7208a9d
No known key found for this signature in database
37 changed files with 1648 additions and 144 deletions

View file

@ -805,6 +805,9 @@ def server(configpath):
"linkexample"
)
# We can optionally configure a link request stamp cost
server_destination.set_link_cost(14.2)
# We configure a function that will get called every time
# a new client creates a link to this destination.
server_destination.set_link_established_callback(client_connected)

View file

@ -130,6 +130,14 @@ to participate in the development of Reticulum itself.
* [Improving System Configuration](using.md#improving-system-configuration)
* [Fixed Serial Port Names](using.md#fixed-serial-port-names)
* [Reticulum as a System Service](using.md#reticulum-as-a-system-service)
* [Protecting Open Networks](stamps.md)
* [Cryptographic Stamps](stamps.md#cryptographic-stamps)
* [Base Primitives](stamps.md#base-primitives)
* [On-Network Types](stamps.md#on-network-types)
* [Configuring Stamps](stamps.md#configuring-stamps)
* [Filtering & QoS](stamps.md#filtering-qos)
* [Blackhole Management](stamps.md#blackhole-management)
* [Ingress & Burst Control](stamps.md#ingress-burst-control)
* [Understanding Reticulum](understanding.md)
* [Motivation](understanding.md#motivation)
* [Goals](understanding.md#goals)

View file

@ -910,13 +910,6 @@ Reticulum includes a powerful system for publishing your local interfaces to the
When an interface is made **discoverable**, your Reticulum instance will periodically broadcast an announce packet containing the connection details and parameters required for other peers to establish a connection. These announces are propagated over the network using the standard Reticulum announce mechanism using the `rnstransport.discovery.interface` destination type.
#### NOTE
To use the interface discovery functionality, the `LXMF` module must be installed in your Python environment. You can install it using pip:
```sh
pip install lxmf
```
### Enabling Discovery
Interface discovery is enabled on a per-interface basis. To make a specific interface discoverable, you must add the `discoverable` option to that interface’s configuration block and set it to `yes`.

View file

@ -3,7 +3,7 @@
Communication over Reticulum networks is achieved by using a simple set of classes exposed by the RNS API.
This chapter lists and explains all classes exposed by the Reticulum Network Stack API, along with their method signatures and usage. It can be used as a reference while writing applications that utilise Reticulum, or it can be read in entirity to gain an understanding of the complete functionality of RNS from a developers perspective.
### `class RNS.Reticulum(configdir=None, loglevel=None, logdest=None, verbosity=None, require_shared_instance=False, shared_instance_type=None)`
### `class RNS.Reticulum(configdir=None, loglevel=None, logdest=None, verbosity=None, require_shared_instance=False, shared_instance_type=None, enable_stamping=False, enforce_stamps=False)`
This class is used to initialise access to Reticulum within a
program. You must create exactly one instance of this class before
@ -156,7 +156,7 @@ Returns the required stamp value for a discovered interface
to be considered valid and remembered.
* **Returns:**
The required stamp value as an integer.
The required stamp value as a float.
#### `static publish_blackhole_enabled()`
@ -189,7 +189,7 @@ interfaces are discovered.
* **Returns:**
A list of identity hashes.
### `class RNS.Identity(create_keys=True)`
### `class RNS.Identity(create_keys=True, value=None)`
This class is used to manage identities in Reticulum. It provides methods
for encryption, decryption, signatures and verification, and is the basis
@ -247,6 +247,26 @@ Recall last heard app_data for a destination hash.
* **Returns:**
*Bytes* containing app_data, or *None* if the destination is unknown.
#### `static recall_stamp_value(destination_hash)`
Recall last heard announce stamp value for a destination hash.
* **Parameters:**
**destination_hash** – Destination hash as *bytes*.
* **Returns:**
*Float*, or *None* if the destination is unknown.
#### `static recall_link_cost(destination_hash)`
Recall the link request stamp cost announced by a destination.
* **Parameters:**
**destination_hash** – Destination hash as *bytes*.
* **Returns:**
*Float*, or *None* if the destination is unknown or has not announced a cost.
#### `static full_hash(data)`
Get a SHA-256 hash of passed data.
@ -331,6 +351,11 @@ Saves the public identity to a file.
* **Returns:**
True if the file was saved, otherwise False.
#### `get_value()`
* **Returns:**
The stamp value of this identity as a *float*
#### `get_private_key()`
* **Returns:**
@ -467,6 +492,29 @@ relevant interfaces. Application specific data can be added to the announce.
* **app_data** – *bytes* containing the app_data.
* **path_response** – Internal flag used by [RNS.Transport](#api-transport). Ignore.
#### `set_value(value)`
Sets the target stamp value for this destination.
* **Parameters:**
**value** – The target value as a *float*.
#### `set_link_cost(cost)`
Sets the required link establishment stamp cost for this destination. Set to 0 to disable.
* **Parameters:**
**cost** – The required cost as a *float*.
#### `get_link_cost()`
Returns the link request stamp cost to be announced for this
destination, as a float. If no destination-specific cost has
been set, the default link request cost is returned.
* **Returns:**
The announced link request cost as a *float*.
#### `accepts_links(accepts=None)`
Set or query whether the destination accepts incoming link requests.
@ -1373,7 +1421,7 @@ blocks until the path is available, or the timeout is reached.
* **Returns:**
*True* if a path to the destination is found, otherwise *False*.
#### `static request_path(destination_hash, on_interface=None, tag=None, recursive=False)`
#### `static request_path(destination_hash, on_interface=None, tag=None, recursive=False, ext_payload=None)`
Requests a path to the destination from the network. If
another reachable peer on the network knows a path, it
@ -1382,6 +1430,7 @@ will announce it.
* **Parameters:**
* **destination_hash** – A destination hash as *bytes*.
* **on_interface** – If specified, the path request will only be sent on this interface. In normal use, Reticulum handles this automatically, and this parameter should not be used.
* **ext_payload** – Internal use by [RNS.Transport](#api-transport). Ignore.
#### `static blackhole_identity(identity_hash, until=None, reason=None)`

226
docs/markdown/stamps.md Normal file
View file

@ -0,0 +1,226 @@
# Protecting Open Networks
#### IMPORTANT
Reticulum is currently transitioning towards full, on-network stamp verification and enforcement via a phased transition:
- The `1.6.0` release completely implements the required mechanisms, and will start excercising the verification system in the transport backend. By default, `1.6.0` does not enable full stamp generation, emission and enforcement, but all of these options can be early-enabled in the configuration.
- The `1.6.1` release will enable full stamp generation and emission of all types by default, but will leave the *enforcement* a configurable option.
- The `1.6.2` release will complete the transition, activating full stamp enforcement across all the systems.
The stated version numbers are the *intended* release sequence. If any issues or implementation problems are found during the initial network deployments, the transition points may be pushed later than this plan by interim releases.
While you can create entirely closed-off and private networks with Reticulum, the protocol itself is open and permissionless. On widely interconnected networks, anyone can create identities and globally reachable destinations without external permission or approval, and establish links anonymously over the network.
Such capabilities are powerful, and a required characteristic of a truly functional communications fabric, but also raise very large challenges, that have been almost impossible to solve in legacy networking technologies.
Reticulum approaches this particular problem, like most others, by employing cryptographic principles. This provides a comprehensive, multi-layered repertoire of defense mechanisms, which can be composed and employed in very effective ways.
In contrast to other networking paradigms, these mechanisms do not have to be bolted on to the application layer in hindsight, but are a core part of the protocol itself, which means that they can be applied universally and effectively:
> All nodes help combat spam and network abuse, according to the rules *set by the actual owners of supplied resources* - not by any bureaucracy or external authority.
> Rules and requirements can be adjusted live, dynamically and directly, and by those that actually operate and run the infrastructure and services.
The system has been designed so that it becomes very cheap computationally for resource-providing nodes to verify or reject traffic, and very expensive for malicious nodes to abuse the shared resources provided by the network’s operators.
## Cryptographic Stamps
All networking primitives that consume shared network resources are gated by *stamps*. A stamp is compact, cryptographic token that proves that a certain amount of computation and energy has been expended in its creation.
The amount of such computation required for a stamp to be considered valid can be configured individually by the operator of the resource being made available, whether that is network transport, a node providing information for retrieval, a shared voice room, or something else entirely.
While the core functionality is completely automatic, and handled by Reticulum itself, the primitives are made available at the application layer API as well, so that developers can use them to implement further protections, if required by their usage scenarios. In most cases, however, simply setting the target *values* and required *costs* for the built-in mechanisms will be sufficient.
The *value* of a stamp is a decimal representation of how difficult a stamp was to create, on a scale from `0.0` to `100.0`. The scale is **exponential**. An increase of one point is equal to *doubling* the average compute time required. Fractional values are supported, such as `14.125`.
Internally, the fractional part is quantized to `256` different values, giving an approximately `0.4%` difficulty increase per step. You can use any decimal number when configuring stamps, such as `9.3691` and you do not have to worry about “landing on” the correct step values. Reticulum will automatically handle the quantization, wire-transport representation and value comparisons.
The term *cost* is used everywhere a stamp value *requirement* is configured or specified. In general, *value* refers to the actual, determined value of a given stamp, *cost* refers to a value requirement.
### Base Primitives
Reticulum provides two types of base stamp primitives:
> * **Detached stamps** can be tied to any external information, and are useful for stamping both static information and for one-time verification purposes. The stamp itself is a detached, short binary sequence, typically 14 to 32 bytes, that can be verified directly against the stamped material.
> They can be configured from relatively easy to compute, even for embbedded systems and microcontrollers, all the way to something that is practically impossible, even with all the compute and memory on the planet.
> * **Embedded stamps** are tied directly to a Reticulum Identity keyset, and embedded within it. The keyset itself *contains* the stamp, and there is no external, detached byte sequence for them.
> Anyone can verify the value of an identity-embedded stamp simply from the public key material of the identity.
### On-Network Types
The base primitives are used to implement scenario-specific network-level primitives that, if configured correctly, make spam and network abuse expensive, but validation and enforcement cheap and efficient.
> * **Destination Stamps** are detached stamps associated with reticulum destinations. They are included in all announces sent by a destination, and by verifying that their value matches a transport node’s cost requirement, they can be either accepted for rebroadcast onto the network, or rejected and dropped.
> Destination stamps are *one-time* generations, and are reusable across announces. They limit the number of *new* destinations that can be created, and makes it expensive to spam a network with destinations that do not provide anything meaningful. As such, these stamps will typically target relatively high values, and their cost requirements should be set accordingly.
> A generation time for such stamps in *minutes* rather than seconds can very well be reasonable on large, open-access networks. Due to their detached nature, they can also be pre-generated off-device (and do not require the private key material for generation), so that even low-powered nodes, such as microcontrollers, can use high-value destination stamps, by having them generated and loaded externally as a one-time procedure.
> * **Path Request Stamps** are also detached stamps, but generated *individually* for every path request emitted on the network. These will typically have a much lower cost requirement than destination stamps, but if a node is overwhelmed by path requests, it can be tuned higher.
> The stamp is generated against the individually unique *emission*, so that unstamped or low-value path requests for a destination cannot disrupt the resolution of legitimate ones toward that same destination.
> * **Link Request Stamps** embedded stamps, carried in the ephemeral link request keyset. They are therefore completely transparent to the network, but can still be verified extremely quickly by any node along the link request path, who can then make a decision on whether or not to transport it.
> Link request cost targets are set by the *endpoint destinations individually*. Every destination that includes a stamp in its announces will also include link request cost signalling. This means that any node that hears an announce from the destination will also know what link request stamp value to target, when establishing links to that destination.
> Furthermore, spam and link request abuse can be filtered before even reaching the destination, if at least one node along the path validates the link request stamp value and cost requirement.
All of the stamp primitives, functionality and on-wire signalling is *transparent and backwards-compatible* with older versions of Reticulum transport nodes. This means, that even if a node doesn’t itself understand stamp functionality, it will still transport all the required information. Stamped announces, path and link requests can cross older, non stamp-aware network segments transparently and unaffected.
### Configuring Stamps
Reticulum, and its included utilities, provide sane default cost requirements and value targets for the different types of network stamps, but it is entirely up to the operator whether to follow the defaults. All of them are configurable on a per-node, per-application and per-destination basis.
#### Instance Configuration
In reality, different kinds of networks will want to configure different kinds of costs and value targets for their use. For instance-wide defaults and settings, you can configure these in the `[stamps]` section of the Reticulum configuration file:
> * The `stamp_destinations` option enables generation and emission
> of destination stamps in announces. This is a transitory option.
> It will become mandatory and enabled by default in RNS `1.6.1`.
>
> * The `stamp_prs` option enables stamping of path requests emitted
> by this instance. This is a transitory option. It will become
> mandatory and enabled by default in RNS `1.6.1`.
>
> * The `always_stamp_lrs` option will stamp *all* outgoing link
> requests, even to destinations that have not announced a link
> request cost (and will, in that case, use the configured or
> default link request cost). This option is mostly useful for
> testing and diagnostics. In general use, Reticulum will handle
> link request stamping and cost targets automatically.
>
> * The `enforce_stamps` option allows early activation of stamp
> enforcement. When enabled, announces and path requests that do
> not meet the configured cost requirements are dropped, and link
> requests with insufficient stamps are ignored. This is a transitory
> option. It will become mandatory and enabled by default in RNS
> `1.6.2`.
>
> * The `destination_cost` option sets the default required stamp
> cost for announced destinations to be accepted, and have their
> announces propagated by this node. Defaults to `23.5`.
>
> * The `destination_value` option sets the default stamp value that
> this instance will target when generating new destination stamps.
> An application can request higher targets for destinations that it
> creates, but a requested lower value will always be clamped to the
> configured default as a minimum. Defaults to `25.0`.
>
> > *Destination stamps are one-time generations per destination, so it
> > is generally a good idea to target a slightly higher value than the
> > minimum required cost of the networks you want the destination to
> > be reachable on.*
> * The `pr_cost` option sets the required stamp cost for incoming
> path requests. Defaults to `15.8`.
>
> * The `pr_value` option sets the target stamp value for path
> request stamps generated by this instance. Defaults to `15.8`.
>
> * The `lr_cost` option sets the default link request stamp cost,
> that destinations created on this instance will require. This
> value can be freely overridden by applications that specify their
> own link request cost requirements, and is solely used as the
> default if no such specification is provided. Defaults to `12.5`.
>
> * The `lr_stamp_timeout` and `pr_stamp_timeout` options set the
> maximum amount of time, in seconds, to spend while attempting to
> generate link and path request stamps respectively. If a stamp is
> not generated within this timespan, the generation is cancelled,
> and the link request or path request fails. Defaults to `15`
> seconds for both options.
>
An example of customised stamp cost and value configuration follows below:
```ini
[stamps]
stamp_destinations = yes
stamp_prs = yes
destination_cost = 24.8
destination_value = 26.25
pr_cost = 15.8
pr_value = 16.45
```
Stamp cost requirements can also be configured on a per-interface basis:
```ini
[[Public Gateway]]
type = BackboneInterface
mode = gateway
listen_on = 0.0.0.0
port = 4242
destination_cost = 25.0
pr_cost = 17.2
[[Local RNode]]
type = RNodeInterface
port = /dev/ttyUSB0
# Much lower requirements
# for the local network.
destination_cost = 11.2
pr_cost = 5.0
```
#### For Developers
Applications can dynamically set their own stamp values and required link requests costs at runtime. Whenever the values are adjusted, the destination will have to send an announce for the updated information to become known by the rest of the network.
If you are setting these values at destination creation time, ensure that they are set *immediately* after the destination is instantiated, as Reticulum may queue internal, instance-local announces for the destination shortly after creation, so that the local shared instance and its clients are aware of the newly created destination.
```python
# Create a new destination
my_destination = RNS.Destination(
my_identity,
RNS.Destination.IN,
RNS.Destination.SINGLE,
"myapp", "service"
)
# Configure stamps
my_destination.set_value(30.0)
my_destination.set_link_cost(15.0)
```
Dynamically adjusting link request costs is a viable and intended mechanism for mitigating resource abuse, scraping, DoS attempts and other malicious behaviour. An application may implement mechanisms to statically or dynamically raise link request costs under certain conditions.
It is also possible for application code to directly get the destination value and link request cost for any known destination:
```python
# Get the value of a known destination
RNS.Identity.recall_stamp_value(destination_hash)
# Get the current link cost requirement
# of a known destination
RNS.Identity.recall_link_cost(destination_hash)
```
An `Identity` can be created with an embedded stamp value, by passing the target value at instantiation time:
```python
# Create a new, stamped identity
my_identity = RNS.Identity(value=24.0)
# Get the value of any known identity
another_identity.get_value()
```
As with destination stamps, this is a one-time generation procedure, that happens at Identity creation. Once an identity is created with an embedded stamp, its value *cannot* be upgraded at a later point as with detached stamps.
## Filtering & QoS
TODO: Section explaining the `[filter]` configuration options, for creating allow and blocklists for specific destination types.
## Blackhole Management
TODO: Section explaining the blackhole system conceptually (including distributed updates from other nodes), with a few terse examples for either locally - or across an entire managed network - blocking specific identities (and therefore any destination types created by such), as well as blocking incoming (identified) link requests from that identity at terminus.
## Ingress & Burst Control
TODO: Section explaining the rate-limiting, ingress control and burst limiters conceptually, with a few, terse examples on how to configure them (linked references to other more extensive documentation sections of the options).

View file

@ -178,12 +178,14 @@ change anything, and you may already be connected to a wider network. If not,
you will probably need to add relevant *interfaces* to the configuration, in
order to communicate with other systems.
You can generate a much more verbose configuration example by running the command:
The example above does not document all the available options, only the basics.
To explore all the various configuration options available, you can generate a
much more verbose and complete configuration example by running the command:
`rnsd --exampleconfig`
The output includes examples for most interface types supported
by Reticulum, along with additional options and configuration parameters.
The output includes examples for most interface types supported by Reticulum,
along with additional options and configuration parameters.
It is a good idea to read the comments and explanations in the above default config.
It will teach you the basic concepts you need to understand to configure your network.
@ -617,7 +619,7 @@ Or fetch a file from the remote system:
$ rncp --fetch ~/path/to/file.tgz 73cbd378bb0286ed11a707c13447bb1e
```
The default identity file is stored in `~/.reticulum/identities/rncp`, but you can use
The default identity file is stored in `~/.reticulum/storage/identities/rncp`, but you can use
another one, which will be created if it does not already exist
```text
@ -700,7 +702,7 @@ Or enter the interactive mode pseudo-shell:
$ rnx 7a55144adf826958a9529a3bcf08b149 -x
```
The default identity file is stored in `~/.reticulum/identities/rnx`, but you can use
The default identity file is stored in `~/.reticulum/storage/identities/rnx`, but you can use
another one, which will be created if it does not already exist
```text
@ -912,9 +914,10 @@ When connecting to a remote listener, several options are available:
**Identity & Destination**
The default identity file for `rnsh` is stored at
`~/.reticulum/identities/rnsh`, but you can specify a different one with the
`-i` option, which will be created if it does not already exist:
The default initiator identity file for `rnsh` is stored at
`~/.rns/identity` (default listener identity is in `~/.rns/identity.default`),
but you can specify a different one with the `-i` option, which will be created if
it does not already exist:
```text
$ rnsh -l -i /path/to/identity
@ -1402,6 +1405,7 @@ Type=simple
Restart=always
RestartSec=3
User=USERNAMEHERE
Environment=MALLOC_ARENA_MAX=2
ExecStart=rnsd --service
[Install]
@ -1442,6 +1446,7 @@ After=default.target
Type=simple
Restart=always
RestartSec=3
Environment=MALLOC_ARENA_MAX=2
ExecStart=RNS_BIN_DIR/rnsd --service
[Install]