Compare commits

...
18 Commits
Author SHA1 Message Date
DeFiDude 5c18a5f8e6 ci: pin rsReticulum f6d0d69 2026-11-20 12:57:54 -07:00
DeFiDude 483bf7f970 propagation: the delivery limit bounds only a message download, not the ID list 2026-11-20 11:47:18 -07:00
DeFiDude 094c49bd83 ci: pin rsReticulum 54c8525 2026-11-19 20:51:38 -07:00
DeFiDude 3d606ca703 message: a signed message lends out its attachment bytes 2026-11-19 20:47:47 -07:00
DeFiDude 419711b0ee propagation: the Offline Inbox client refuses a response larger than its delivery limit allows 2026-11-19 20:28:05 -07:00
DeFiDude 9436d052c5 message: media fields encode once at their size, and signing builds the wire in place 2026-11-19 20:28:05 -07:00
DeFiDude 70fa224211 ci: pin rsReticulum 5e35c9f 2026-11-19 09:33:10 -07:00
DeFiDude 2d04201bff ci: pin rsReticulum 0ce5a12 2026-11-19 08:55:25 -07:00
DeFiDude 7cbb87cd47 test: lxmd's ratchet test re-announces a second later, past Reticulum's same-second prefilter 2026-11-19 08:52:27 -07:00
DeFiDude b92923e2ec ci: pin rsReticulum 3d53958 2026-11-19 07:54:34 -07:00
DeFiDude bc04e75c4b lxmd: deregister destination types once at exit, through runtime shutdown 2026-11-18 20:11:17 -07:00
DeFiDude 2e057f6172 readme: 1.5.1 follows LXMF 1.3.1 and Reticulum 1.6.1 2026-11-18 17:14:39 -07:00
DeFiDude e2719fbe07 release: version 1.5.1 2026-11-18 17:08:58 -07:00
DeFiDude f65ffa6295 stamps: fractional PN stamp test uses a stamp only the expanded form accepts 2026-11-18 16:54:38 -07:00
DeFiDude 932d59ab74 lxmf: report LXMF 1.3.1 2026-11-18 16:54:38 -07:00
DeFiDude eae4fd50a4 stamps: accept both LXMF workblock forms 2026-11-18 12:59:15 -07:00
DeFiDude bc07d04396 discovery: delegate both-form stamp validation 2026-11-18 12:54:32 -07:00
DeFiDude eee86a37c2 build: lock rsReticulum 1.5.1 2026-11-18 11:36:52 -07:00
23 changed files with 516 additions and 157 deletions

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@ permissions:
contents: read
env:
RSLXMF_RSRETICULUM_COMMIT: 184bbfe59f1e089af802df2de706688b82dd49d2
RSLXMF_RSRETICULUM_COMMIT: f6d0d698dd7e6edc180f9c3697ab1c873571f372
jobs:
api-compat:
+2 -2
View File
@@ -24,8 +24,8 @@ env:
RELEASE_TAG: ${{ github.event.inputs.tag_name || github.ref_name }}
PACKAGE_ROOT: rsLXMF
LXMF_BINS: lxmd-rs
RSLXMF_RSRETICULUM_VERSION: 1.5.0
RSLXMF_RSRETICULUM_COMMIT: 184bbfe59f1e089af802df2de706688b82dd49d2
RSLXMF_RSRETICULUM_VERSION: 1.5.1
RSLXMF_RSRETICULUM_COMMIT: f6d0d698dd7e6edc180f9c3697ab1c873571f372
jobs:
verify:
+6
View File
@@ -2,6 +2,12 @@
## Unreleased
## 1.5.1 - 2026-11-18
- **Follows Python LXMF 1.3.1** with Reticulum 1.6.1 (rsReticulum 1.5.1), and reports LXMF 1.3.1, propagation-node announces included.
- Message, propagation-node, and peering stamps are accepted in both workblock forms: the non-expanded one LXMF senders are moving to, tried first, then the expanded one. A stamp's value comes from the form that passed. Generation stays expanded until senders switch.
- Discovery stamps are validated in both forms through rsReticulum's discovery stamper.
## 1.5.0 - 2026-11-13
### Added
Generated
+19 -47
View File
@@ -145,15 +145,6 @@ dependencies = [
"generic-array",
]
[[package]]
name = "block2"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f"
dependencies = [
"objc2 0.5.2",
]
[[package]]
name = "bytes"
version = "1.11.1"
@@ -725,13 +716,13 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]]
name = "lxmf-core"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"base64",
"bytes",
"hex",
"jni",
"objc2 0.6.5",
"objc2",
"proptest",
"rand 0.8.5",
"rmp",
@@ -756,7 +747,7 @@ dependencies = [
[[package]]
name = "lxmf-tools"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"base64",
"bytes",
@@ -891,22 +882,6 @@ dependencies = [
"libm",
]
[[package]]
name = "objc-sys"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310"
[[package]]
name = "objc2"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804"
dependencies = [
"objc-sys",
"objc2-encode",
]
[[package]]
name = "objc2"
version = "0.6.5"
@@ -918,12 +893,11 @@ dependencies = [
[[package]]
name = "objc2-core-bluetooth"
version = "0.2.2"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a644b62ffb826a5277f536cf0f701493de420b13d40e700c452c36567771111"
checksum = "79b30b9eacc37434a61377866f68b27acef9fa5496f25cc9ca8b2549032e0394"
dependencies = [
"bitflags 2.11.0",
"objc2 0.5.2",
"objc2",
"objc2-foundation",
]
@@ -935,14 +909,12 @@ checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
[[package]]
name = "objc2-foundation"
version = "0.2.2"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8"
checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
dependencies = [
"bitflags 2.11.0",
"block2",
"libc",
"objc2 0.5.2",
"objc2",
]
[[package]]
@@ -1211,7 +1183,7 @@ dependencies = [
[[package]]
name = "rns-crypto"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"aes",
"cbc",
@@ -1229,7 +1201,7 @@ dependencies = [
[[package]]
name = "rns-identity"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"hex",
"libc",
@@ -1249,7 +1221,7 @@ dependencies = [
[[package]]
name = "rns-interface"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"bytes",
"hex",
@@ -1258,7 +1230,7 @@ dependencies = [
"libc",
"md-5",
"mio",
"objc2 0.5.2",
"objc2",
"objc2-core-bluetooth",
"objc2-foundation",
"rand 0.8.5",
@@ -1278,7 +1250,7 @@ dependencies = [
[[package]]
name = "rns-link"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"hex",
"libc",
@@ -1295,7 +1267,7 @@ dependencies = [
[[package]]
name = "rns-protocol"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"bzip2",
"hex",
@@ -1312,7 +1284,7 @@ dependencies = [
[[package]]
name = "rns-runtime"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"bytes",
"hex",
@@ -1340,7 +1312,7 @@ dependencies = [
[[package]]
name = "rns-tools"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"base64",
"bytes",
@@ -1367,7 +1339,7 @@ dependencies = [
[[package]]
name = "rns-transport"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"bytes",
"hex",
@@ -1387,7 +1359,7 @@ dependencies = [
[[package]]
name = "rns-wire"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"rns-crypto",
"sha2",
+12 -12
View File
@@ -6,26 +6,26 @@ members = [
]
[workspace.package]
version = "1.5.0"
version = "1.5.1"
edition = "2024"
license-file = "LICENSE"
rust-version = "1.89"
[workspace.dependencies]
# Reticulum crates from a sibling rsReticulum checkout during development.
rns-crypto = { path = "../rsReticulum/crates/rns-crypto", version = "~1.5.0" }
rns-wire = { path = "../rsReticulum/crates/rns-wire", version = "~1.5.0" }
rns-identity = { path = "../rsReticulum/crates/rns-identity", version = "~1.5.0" }
rns-link = { path = "../rsReticulum/crates/rns-link", version = "~1.5.0" }
rns-protocol = { path = "../rsReticulum/crates/rns-protocol", version = "~1.5.0" }
rns-transport = { path = "../rsReticulum/crates/rns-transport", version = "~1.5.0", default-features = false }
rns-runtime = { path = "../rsReticulum/crates/rns-runtime", version = "~1.5.0" }
rns-interface = { path = "../rsReticulum/crates/rns-interface", version = "~1.5.0" }
rns-tools = { path = "../rsReticulum/crates/rns-tools", version = "~1.5.0", default-features = false }
rns-crypto = { path = "../rsReticulum/crates/rns-crypto", version = "~1.5.1" }
rns-wire = { path = "../rsReticulum/crates/rns-wire", version = "~1.5.1" }
rns-identity = { path = "../rsReticulum/crates/rns-identity", version = "~1.5.1" }
rns-link = { path = "../rsReticulum/crates/rns-link", version = "~1.5.1" }
rns-protocol = { path = "../rsReticulum/crates/rns-protocol", version = "~1.5.1" }
rns-transport = { path = "../rsReticulum/crates/rns-transport", version = "~1.5.1", default-features = false }
rns-runtime = { path = "../rsReticulum/crates/rns-runtime", version = "~1.5.1" }
rns-interface = { path = "../rsReticulum/crates/rns-interface", version = "~1.5.1" }
rns-tools = { path = "../rsReticulum/crates/rns-tools", version = "~1.5.1", default-features = false }
# Workspace LXMF crates
lxmf-core = { path = "crates/lxmf-core", version = "~1.5.0" }
lxmf-tools = { path = "crates/lxmf-tools", version = "~1.5.0" }
lxmf-core = { path = "crates/lxmf-core", version = "~1.5.1" }
lxmf-tools = { path = "crates/lxmf-tools", version = "~1.5.1" }
# Encoding
base64 = "0.22"
+7 -7
View File
@@ -6,8 +6,8 @@
[![License: Reticulum License](https://img.shields.io/badge/license-Reticulum%20License-blue.svg)](LICENSE)
[![Rust 1.89+](https://img.shields.io/badge/rust-1.89%2B-orange.svg)](https://www.rust-lang.org)
[![Baseline: LXMF 1.3.0](https://img.shields.io/badge/baseline-LXMF%201.3.0-success.svg)](https://github.com/markqvist/LXMF)
[![Reticulum 1.6.0](https://img.shields.io/badge/reticulum-1.6.0-blue.svg)](https://reticulum.network/)
[![Baseline: LXMF 1.3.1](https://img.shields.io/badge/baseline-LXMF%201.3.1-success.svg)](https://github.com/markqvist/LXMF)
[![Reticulum 1.6.1](https://img.shields.io/badge/reticulum-1.6.1-blue.svg)](https://reticulum.network/)
[![Status](https://img.shields.io/badge/status-experimental-yellow.svg)](#feature-status)
[LXMF Reference](https://github.com/markqvist/LXMF) |
@@ -37,7 +37,7 @@ reference's wire behavior release by release.
## Build It
This guide describes the 1.5.0 release, [v1.5.0](https://github.com/ratspeak/rsLXMF/releases/tag/v1.5.0), built with rsReticulum [v1.5.0](https://github.com/ratspeak/rsReticulum/releases/tag/v1.5.0), the source line Ratspeak builds from.
This guide describes the 1.5.1 release, [v1.5.1](https://github.com/ratspeak/rsLXMF/releases/tag/v1.5.1), built with rsReticulum [v1.5.1](https://github.com/ratspeak/rsReticulum/releases/tag/v1.5.1), the source line Ratspeak builds from.
The current development layout for rsLXMF requires
rsReticulum as a sibling directory/repo next to it, such as:
@@ -53,8 +53,8 @@ mkdir ratspeak-src
cd ratspeak-src
git clone https://github.com/ratspeak/rsReticulum
git clone https://github.com/ratspeak/rsLXMF
git -C rsReticulum checkout --detach v1.5.0
git -C rsLXMF checkout --detach v1.5.0
git -C rsReticulum checkout --detach v1.5.1
git -C rsLXMF checkout --detach v1.5.1
cd rsLXMF
```
@@ -291,7 +291,7 @@ Optional hash-list files live next to `<config-dir>/config`:
Each file accepts one raw 32-character hex hash per line. The two files use different hash types. Propagation administration is separate: `control_allowed` contains authorized control identity hashes; the daemon’s own identity is also authorized. Client retrieval authorization does not make the node’s stored messages readable to other clients.
Router state (delivered and processed transient IDs, stamp costs, and tickets)
is kept in `<config-dir>/storage/lxmf/state.db`, the SQLite file LXMF 1.3.0 uses.
is kept in `<config-dir>/storage/lxmf/state.db`, the SQLite file LXMF 1.3.1 uses.
Received ratchets are kept
by Reticulum in its own storage. These stores come from the default
`sqlite-store` feature of `lxmf-core`; without it, router state lasts only for
@@ -358,7 +358,7 @@ All upstream `lxmd` flags are implemented: `--config`, `--rnsconfig`,
Additional rsLXMF-only flags: `--send`, `--send-file`, `--send-method`,
`--send-timeout-secs`, and `--send-fields-json`.
rsLXMF 1.5.0 follows Python LXMF 1.3.0 with Reticulum 1.6.0, and
rsLXMF 1.5.1 follows Python LXMF 1.3.1 with Reticulum 1.6.1, and
`lxmd-rs --version` names both.
## License
+7 -7
View File
@@ -422,7 +422,7 @@ checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
[[package]]
name = "lxmf-core"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"base64",
"bytes",
@@ -646,7 +646,7 @@ dependencies = [
[[package]]
name = "rns-crypto"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"aes",
"cbc",
@@ -664,7 +664,7 @@ dependencies = [
[[package]]
name = "rns-identity"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"hex",
"libc",
@@ -684,7 +684,7 @@ dependencies = [
[[package]]
name = "rns-link"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"hex",
"libc",
@@ -701,7 +701,7 @@ dependencies = [
[[package]]
name = "rns-protocol"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"bzip2",
"hex",
@@ -718,7 +718,7 @@ dependencies = [
[[package]]
name = "rns-transport"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"bytes",
"hex",
@@ -738,7 +738,7 @@ dependencies = [
[[package]]
name = "rns-wire"
version = "1.5.0"
version = "1.5.1"
dependencies = [
"rns-crypto",
"sha2",
+6
View File
@@ -336,6 +336,7 @@ pub fn lxmf_core::discovery_stamper::LxmfDiscoveryStamper::with_max_iterations(u
impl rns_transport::discovery::stamper::DiscoveryStamper for lxmf_core::discovery_stamper::LxmfDiscoveryStamper
pub fn lxmf_core::discovery_stamper::LxmfDiscoveryStamper::generate(&self, &[u8; 32], f64, &rns_identity::stamps::StampControl) -> core::option::Option<alloc::vec::Vec<u8>>
pub fn lxmf_core::discovery_stamper::LxmfDiscoveryStamper::valid(&self, &[u8; 32], &[u8], f64) -> bool
pub fn lxmf_core::discovery_stamper::LxmfDiscoveryStamper::validate(&self, &[u8; 32], &[u8], f64) -> core::option::Option<f64>
pub fn lxmf_core::discovery_stamper::LxmfDiscoveryStamper::value(&self, &[u8; 32], &[u8]) -> f64
pub const lxmf_core::discovery_stamper::DISCOVERY_MAX_ITERATIONS: u64
pub const lxmf_core::discovery_stamper::DISCOVERY_WORKBLOCK_EXPAND_ROUNDS: usize
@@ -1011,8 +1012,10 @@ pub fn lxmf_core::message::SignedLxMessage::content_text(&self) -> alloc::borrow
pub fn lxmf_core::message::SignedLxMessage::destination_hash(&self) -> [u8; 16]
pub fn lxmf_core::message::SignedLxMessage::fields(&self) -> lxmf_core::message::Fields<'_>
pub fn lxmf_core::message::SignedLxMessage::finalize(self, core::option::Option<lxmf_core::message::RecipientStamp>) -> core::result::Result<lxmf_core::message::LxMessage, lxmf_core::message::MessageError>
pub fn lxmf_core::message::SignedLxMessage::first_file_attachment(&self) -> core::result::Result<core::option::Option<(alloc::string::String, &[u8])>, lxmf_core::message::MessageError>
pub fn lxmf_core::message::SignedLxMessage::generate_recipient_stamp(&self) -> core::result::Result<core::option::Option<lxmf_core::message::RecipientStamp>, lxmf_core::message::MessageError>
pub fn lxmf_core::message::SignedLxMessage::generate_recipient_stamp_with(&self, &rns_identity::stamps::StampControl) -> core::result::Result<core::option::Option<lxmf_core::message::RecipientStamp>, lxmf_core::message::MessageError>
pub fn lxmf_core::message::SignedLxMessage::image_attachment(&self) -> core::result::Result<core::option::Option<(alloc::string::String, &[u8])>, lxmf_core::message::MessageError>
pub fn lxmf_core::message::SignedLxMessage::into_unstamped(self) -> lxmf_core::message::LxMessage
pub fn lxmf_core::message::SignedLxMessage::message_id(&self) -> [u8; 32]
pub fn lxmf_core::message::SignedLxMessage::outbound_ticket(&self) -> core::option::Option<[u8; 16]>
@@ -1307,8 +1310,10 @@ pub fn lxmf_core::message::SignedLxMessage::content_text(&self) -> alloc::borrow
pub fn lxmf_core::message::SignedLxMessage::destination_hash(&self) -> [u8; 16]
pub fn lxmf_core::message::SignedLxMessage::fields(&self) -> lxmf_core::message::Fields<'_>
pub fn lxmf_core::message::SignedLxMessage::finalize(self, core::option::Option<lxmf_core::message::RecipientStamp>) -> core::result::Result<lxmf_core::message::LxMessage, lxmf_core::message::MessageError>
pub fn lxmf_core::message::SignedLxMessage::first_file_attachment(&self) -> core::result::Result<core::option::Option<(alloc::string::String, &[u8])>, lxmf_core::message::MessageError>
pub fn lxmf_core::message::SignedLxMessage::generate_recipient_stamp(&self) -> core::result::Result<core::option::Option<lxmf_core::message::RecipientStamp>, lxmf_core::message::MessageError>
pub fn lxmf_core::message::SignedLxMessage::generate_recipient_stamp_with(&self, &rns_identity::stamps::StampControl) -> core::result::Result<core::option::Option<lxmf_core::message::RecipientStamp>, lxmf_core::message::MessageError>
pub fn lxmf_core::message::SignedLxMessage::image_attachment(&self) -> core::result::Result<core::option::Option<(alloc::string::String, &[u8])>, lxmf_core::message::MessageError>
pub fn lxmf_core::message::SignedLxMessage::into_unstamped(self) -> lxmf_core::message::LxMessage
pub fn lxmf_core::message::SignedLxMessage::message_id(&self) -> [u8; 32]
pub fn lxmf_core::message::SignedLxMessage::outbound_ticket(&self) -> core::option::Option<[u8; 16]>
@@ -2261,6 +2266,7 @@ pub fn lxmf_core::stamper::stamp_valid(&[u8], f64, &[u8]) -> bool
pub fn lxmf_core::stamper::validate_peering_key(&[u8], &[u8], f64) -> bool
pub fn lxmf_core::stamper::validate_pn_stamp(&[u8], f64) -> core::option::Option<lxmf_core::stamper::PropagationStampParts>
pub fn lxmf_core::stamper::validate_stamp(&[u8; 32], &[u8], f64, usize) -> bool
pub fn lxmf_core::stamper::validated_stamp_value(&[u8], &[u8], f64, usize) -> core::option::Option<f64>
pub fn lxmf_core::stamper::value_meets(f64, f64) -> bool
pub type lxmf_core::stamper::PropagationStampParts = ([u8; 32], alloc::vec::Vec<u8>, f64, [u8; 32])
pub mod lxmf_core::state_store
+15 -15
View File
@@ -4,7 +4,7 @@
"packages": [
{
"name": "lxmf-core",
"version": "1.5.0",
"version": "1.5.1",
"rustVersion": "1.89",
"edition": "2024",
"features": {
@@ -113,7 +113,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -124,7 +124,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -135,7 +135,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -146,7 +146,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -157,7 +157,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": false,
"features": [],
@@ -168,7 +168,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -294,7 +294,7 @@
},
{
"name": "lxmf-tools",
"version": "1.5.0",
"version": "1.5.1",
"rustVersion": "1.89",
"edition": "2024",
"features": {},
@@ -362,7 +362,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -384,7 +384,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -395,7 +395,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -406,7 +406,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [
@@ -419,7 +419,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": false,
"features": [],
@@ -430,7 +430,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": false,
"features": [],
@@ -441,7 +441,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.5.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
+2 -2
View File
@@ -24,8 +24,8 @@
"tier": "candidate-stable",
"compatibility": "reviewed-snapshot",
"snapshot": "api/snapshots/lxmf-core.txt",
"itemCount": 2452,
"sha256": "36fa8acae92bcb9902def95ffb965fb901655d81414060ed7fce16539ec0f180"
"itemCount": 2458,
"sha256": "93bd001beb46ae13e2ece84d355e9fd4ffc8198029233de3a397b1a645b77651"
},
{
"name": "lxmf-tools",
+1 -1
View File
@@ -91,7 +91,7 @@ pub const PN_META_VERSION: u8 = 0x00;
/// The LXMF release this port follows. A propagation node announces it as
/// its [`PN_META_VERSION`], where upstream announces `LXMF.__version__`
/// (LXMRouter.py, `get_propagation_node_announce_metadata`).
pub const LXMF_COMPAT_VERSION: &str = "1.3.0";
pub const LXMF_COMPAT_VERSION: &str = "1.3.1";
pub const PN_META_NAME: u8 = 0x01;
pub const PN_META_SYNC_STRATUM: u8 = 0x02;
pub const PN_META_SYNC_THROTTLE: u8 = 0x03;
+16
View File
@@ -58,6 +58,10 @@ impl DiscoveryStamper for LxmfDiscoveryStamper {
fn valid(&self, infohash: &[u8; 32], stamp: &[u8], required_value: f64) -> bool {
rns_transport::discovery::RnsDiscoveryStamper.valid(infohash, stamp, required_value)
}
fn validate(&self, infohash: &[u8; 32], stamp: &[u8], required_value: f64) -> Option<f64> {
rns_transport::discovery::RnsDiscoveryStamper.validate(infohash, stamp, required_value)
}
}
/// Synchronous discovery stamp search with 20 HKDF workblock rounds and an
@@ -140,6 +144,18 @@ mod tests {
);
}
#[test]
fn non_expanded_stamps_validate_with_their_own_value() {
let infohash = mk_infohash(b"non-expanded");
let (stamp, value) =
rns_identity::stamps::generate_stamp(&infohash, 6.0, 0, 32, &StampControl::default())
.unwrap()
.unwrap();
let stamper = LxmfDiscoveryStamper::default();
assert_eq!(stamper.validate(&infohash, &stamp, 6.0), Some(value));
assert!(stamper.valid(&infohash, &stamp, 6.0));
}
#[test]
fn workblock_constant_matches_python() {
assert_eq!(DISCOVERY_WORKBLOCK_EXPAND_ROUNDS, 20);
+6 -3
View File
@@ -485,9 +485,12 @@ impl LxMessage {
}
}
let stamp = <&[u8; 32]>::try_from(stamp).ok()?;
let work = crate::stamper::stamp_workblock(&self.message_id, STAMP_WORKBLOCK_EXPAND_ROUNDS);
crate::stamper::stamp_valid(stamp, target_cost, &work)
.then(|| crate::stamper::stamp_value(&work, stamp))
crate::stamper::validated_stamp_value(
&self.message_id,
stamp,
target_cost,
STAMP_WORKBLOCK_EXPAND_ROUNDS,
)
}
/// Update [`auto_compress`](MessageMetadata::auto_compress) based on a peer's cached announce app_data.
///
+53 -26
View File
@@ -169,23 +169,38 @@ impl LxMessageDraft {
id: impl Into<FieldId>,
bytes: impl Into<Bytes>,
) -> Result<(), MessageError> {
self.set_field_value(
id,
FieldValue::MessagePack(EncodedFieldValue::canonical(bytes.into())?),
)
let value = EncodedFieldValue::canonical(bytes.into())?;
self.insert_field(id.into(), FieldValue::MessagePack(value))
}
pub fn set_field_value(
&mut self,
id: impl Into<FieldId>,
value: FieldValue,
) -> Result<(), MessageError> {
let id = id.into();
let value = match value {
FieldValue::MessagePack(v) => FieldValue::MessagePack(EncodedFieldValue::canonical(
Bytes::copy_from_slice(v.encoded()),
)?),
FieldValue::MessagePack(v) => {
FieldValue::MessagePack(EncodedFieldValue::canonical(v.into_bytes())?)
}
binary => binary,
};
self.insert_field(id.into(), value)
}
/// Encode one of this crate's media fields at its exact size, once.
fn set_media_field<T: serde::Serialize>(
&mut self,
id: FieldId,
value: &T,
bytes: usize,
name: usize,
) -> Result<(), MessageError> {
self.limits.check_wire(bytes)?;
// Two array headers, a str header and a bin header: at most 12 bytes.
let mut encoded = Vec::with_capacity(bytes + name + 12);
rmp_serde::encode::write(&mut encoded, value).map_err(packed)?;
let value = EncodedFieldValue::trusted(encoded.into());
self.insert_field(id, FieldValue::MessagePack(value))
}
fn insert_field(&mut self, id: FieldId, value: FieldValue) -> Result<(), MessageError> {
if !self.fields.contains_key(&id) && self.fields.len() >= self.limits.max_top_level_fields {
return Err(MessageError::TooManyFields);
}
@@ -207,24 +222,25 @@ impl LxMessageDraft {
self.fields.remove(&id.into())
}
pub fn set_image_field(&mut self, format: &str, bytes: &[u8]) -> Result<(), MessageError> {
self.limits.check_wire(bytes.len())?;
let encoded = rmp_serde::to_vec(&ImageFieldRef { format, bytes }).map_err(packed)?;
self.set_msgpack_field(FIELD_IMAGE, encoded)
let value = ImageFieldRef { format, bytes };
self.set_media_field(FIELD_IMAGE.into(), &value, bytes.len(), format.len())
}
pub fn set_audio_field(&mut self, mode: u8, bytes: &[u8]) -> Result<(), MessageError> {
self.limits.check_wire(bytes.len())?;
let encoded = rmp_serde::to_vec(&AudioFieldRef { mode, bytes }).map_err(packed)?;
self.set_msgpack_field(FIELD_AUDIO, encoded)
let value = AudioFieldRef { mode, bytes };
self.set_media_field(FIELD_AUDIO.into(), &value, bytes.len(), 0)
}
pub fn set_file_attachment_field(
&mut self,
file_name: &str,
bytes: &[u8],
) -> Result<(), MessageError> {
self.limits.check_wire(bytes.len())?;
let encoded =
rmp_serde::to_vec(&FileAttachmentsFieldRef { file_name, bytes }).map_err(packed)?;
self.set_msgpack_field(FIELD_FILE_ATTACHMENTS, encoded)
let value = FileAttachmentsFieldRef { file_name, bytes };
self.set_media_field(
FIELD_FILE_ATTACHMENTS.into(),
&value,
bytes.len(),
file_name.len(),
)
}
/// Exact unsigned payload, for diagnostics; it is not a transmittable message.
pub fn pack_payload(&self) -> Result<Vec<u8>, MessageError> {
@@ -270,7 +286,7 @@ impl LxMessageDraft {
pub fn sign(self, key: &Ed25519PrivateKey) -> Result<SignedLxMessage, MessageError> {
self.sign_with(|bytes| Ok::<_, std::convert::Infallible>(key.sign(bytes)))
}
pub fn sign_with<F, E>(self, sign: F) -> Result<SignedLxMessage, MessageError>
pub fn sign_with<F, E>(mut self, sign: F) -> Result<SignedLxMessage, MessageError>
where
F: FnOnce(&[u8]) -> Result<[u8; 64], E>,
E: std::fmt::Display,
@@ -280,16 +296,19 @@ impl LxMessageDraft {
signed.extend_from_slice(&self.destination);
signed.extend_from_slice(&self.source);
self.write_payload(&mut signed)?;
// The payload now lives in `signed` alone.
self.fields.clear();
let id = sha256(&signed);
signed.extend_from_slice(&id);
let signature = sign(&signed).map_err(packed)?;
let mut wire = Vec::with_capacity(size);
wire.extend_from_slice(&self.destination);
wire.extend_from_slice(&self.source);
wire.extend_from_slice(&signature);
wire.extend_from_slice(&signed[32..signed.len() - 32]);
drop(signed);
let mut message = LxMessage::unpack_owned(wire.into(), self.limits)?;
// The wire in place: drop the id and open the signature after the
// two hashes. `size` is exactly the wire length, so nothing moves.
let payload_end = signed.len() - 32;
signed.truncate(payload_end);
signed.resize(size, 0);
signed.copy_within(32..payload_end, 96);
signed[32..96].copy_from_slice(&signature);
let mut message = LxMessage::unpack_owned(signed.into(), self.limits)?;
message.metadata = self.metadata;
message.incoming = false;
message.state = MessageState::Outbound;
@@ -353,6 +372,14 @@ impl SignedLxMessage {
pub fn fields(&self) -> Fields<'_> {
self.message.fields()
}
/// The first file attachment's name and bytes, borrowed from the wire.
pub fn first_file_attachment(&self) -> Result<Option<(String, &[u8])>, MessageError> {
self.message.first_file_attachment()
}
/// The image field's format and bytes, borrowed from the wire.
pub fn image_attachment(&self) -> Result<Option<(String, &[u8])>, MessageError> {
self.message.image_attachment()
}
/// The signed, unstamped message, for failing it without a stamp.
pub fn into_unstamped(self) -> LxMessage {
self.message
+7
View File
@@ -84,6 +84,13 @@ impl EncodedFieldValue {
pub fn encoded(&self) -> &[u8] {
&self.0
}
/// For this crate's encoders, whose output is canonical by construction.
pub(crate) fn trusted(bytes: Bytes) -> Self {
Self(bytes)
}
pub(crate) fn into_bytes(self) -> Bytes {
self.0
}
}
/// A binary byte string or a native structured MessagePack value.
#[derive(Debug, Clone, PartialEq, Eq)]
+77
View File
@@ -375,6 +375,21 @@ fn recipient_stamp_array_range_and_malformed_dispositions() {
}
}
#[test]
fn non_expanded_recipient_stamp_validates_with_its_own_value() {
let signed = draft().sign(&key()).unwrap();
let (stamp, value) = crate::stamper::generate_stamp(
&signed.message_id(),
6.0,
0,
&crate::stamper::StampControl::default(),
)
.unwrap()
.unwrap();
let mut m = signed.finalize(RecipientStamp::from_bytes(&stamp)).unwrap();
assert_eq!(m.validated_stamp_value(6.0, None), Some(value));
assert!(m.check_stamp(6.0, None));
}
#[test]
fn recipient_ticket_stamp_and_missing_stamp_policy() {
let mut d = draft();
d.outbound_ticket = Some([3; 16]);
@@ -947,3 +962,65 @@ fn container_is_a_named_map() {
]
);
}
/// Media fields are written once at their size, and the bytes are the
/// canonical encoding the generic msgpack path produces.
#[test]
fn media_fields_encode_canonically_in_one_pass() {
for (name, len) in [
("a.bin", 3usize),
(&"n".repeat(40) as &str, 300),
("é.jpg", 70_000),
] {
let bytes: Vec<u8> = (0..len).map(|i| i as u8).collect();
let mut d = draft();
d.set_file_attachment_field(name, &bytes).unwrap();
d.set_image_field(name, &bytes).unwrap();
d.set_audio_field(7, &bytes).unwrap();
let reference = [
(
FIELD_FILE_ATTACHMENTS,
rmp_serde::to_vec(&FileAttachmentsFieldRef {
file_name: name,
bytes: &bytes,
}),
),
(
FIELD_IMAGE,
rmp_serde::to_vec(&ImageFieldRef {
format: name,
bytes: &bytes,
}),
),
(
FIELD_AUDIO,
rmp_serde::to_vec(&AudioFieldRef {
mode: 7,
bytes: &bytes,
}),
),
];
for (id, encoded) in reference {
let encoded = canonical::canonicalize(&encoded.unwrap()).unwrap();
let Some(FieldValue::MessagePack(value)) = d.get_field(id) else {
panic!("field {id} missing");
};
assert_eq!(
value.encoded(),
encoded.as_slice(),
"field {id}, {len} bytes"
);
}
}
}
/// The wire built in place is `destination, source, signature, payload`,
/// signed over `destination, source, payload, id`.
#[test]
fn signing_builds_the_wire_in_place() {
let mut d = draft();
d.set_file_attachment_field("f", &[9; 5000]).unwrap();
let payload = d.pack_payload().unwrap();
let message = freeze(d);
assert_eq!(message.wire_bytes(), wire(&payload).as_slice());
}
+83 -2
View File
@@ -433,6 +433,27 @@ impl PropagationClient {
self.delivery_limit = Some(limit_kb);
}
/// The largest response a node keeping to upstream's accounting can send.
/// Only a message `/get` spends the delivery limit (LXMRouter.py
/// `message_get_request`); the ID list is unbounded there. The Link response
/// adds its request id.
fn response_size_limit(&self) -> usize {
const RESPONSE_FRAMING: usize = 64;
if !matches!(
self.request.as_ref().map(|request| request.kind),
Some(RequestKind::Get(..))
) {
return MAX_RESOURCE_SIZE;
}
self.delivery_limit
.filter(|limit| limit.is_finite() && *limit > 0.0)
.map_or(MAX_RESOURCE_SIZE, |limit| {
((limit * 1000.0) as usize)
.saturating_add(RESPONSE_FRAMING)
.min(MAX_RESOURCE_SIZE)
})
}
/// Trust this ID as a durable local have, with no expiry. It may authorize
/// remote purge on the next download cycle unless retention is enabled.
/// The caller must establish the durable local effect; this method does not verify it.
@@ -1469,10 +1490,19 @@ impl PropagationClient {
return;
}
let response_limit = self.response_size_limit();
if adv.data_size > response_limit {
tracing::warn!(
size = adv.data_size,
limit = response_limit,
"propagation node offered a response above the delivery limit"
);
self.fail();
return;
}
if adv.flags.is_request
|| !adv.flags.encrypted
|| adv.flags.has_metadata
|| adv.data_size > MAX_RESOURCE_SIZE
|| adv.total_segments == 0
|| adv.segment_index == 0
|| adv.segment_index > adv.total_segments
@@ -1814,6 +1844,7 @@ impl PropagationClient {
route: Option<SegmentRoute>,
metadata: Option<Vec<u8>>,
) {
let response_limit = self.response_size_limit();
let Some(response) = self
.request
.as_mut()
@@ -1824,7 +1855,7 @@ impl PropagationClient {
let Some(total) = response
.assembled_bytes
.checked_add(assembled.len())
.filter(|total| *total <= MAX_RESOURCE_SIZE && *total <= response.data_size)
.filter(|total| *total <= response_limit && *total <= response.data_size)
else {
self.fail();
return;
@@ -3768,6 +3799,56 @@ mod tests {
assert!(client.status.progress >= first_progress);
}
/// A node keeping to the delivery limit never sends more than the limit
/// plus framing, so a larger offer fails the sync before any part arrives.
/// The ID list is not bounded by it.
#[test]
fn get_response_above_the_delivery_limit_is_refused_when_offered() {
for (kind, payload_len, accepted) in [
(RequestKind::Get(0, 0), 2_064, true),
(RequestKind::Get(0, 0), 2_065, false),
(RequestKind::List, 2_065, true),
] {
let (tx, _rx) = mpsc::channel(64);
let mut client = PropagationClient::new(tx, None, None);
client.set_delivery_limit(2.0);
let (initiator, responder) = active_link_pair([0xE4; 16]);
client.link_id = Some(initiator.link_id);
client.link = Some(initiator);
client.status.state = kind.state();
client.request = Some(PendingRequest {
link_id: client.link_id.unwrap(),
generation: 1,
id: [0x45; 16],
kind,
sender_active: false,
outbound: None,
response: None,
waiting_since: Some(Instant::now()),
timeout: Duration::from_secs(60),
});
let mut sender = OutboundTransfer::new_encrypted(
vec![0xAB; payload_len],
false,
Duration::from_millis(50),
responder.session_keys().unwrap(),
)
.unwrap();
sender.resource.flags.is_response = true;
sender.resource.request_id = Some(vec![0x45; 16]);
let TransferAction::SendAdvertisement(advertisement) = sender.tick() else {
panic!("expected a Resource advertisement");
};
client.handle_resource_advertisement(&responder.encrypt(&advertisement).unwrap());
let state = client.status.state;
assert_eq!(
state == PropagationClientState::Receiving,
accepted,
"{kind:?} {payload_len}: {state:?}"
);
}
}
#[test]
fn resource_response_is_not_published_when_its_proof_cannot_be_retained() {
let (tx, mut rx) = mpsc::channel(64);
+61 -7
View File
@@ -402,10 +402,13 @@ impl ValidatedOpaquePropagationBlob {
let body = &bytes[..bytes.len() - 32];
let stamp: &[u8; 32] = bytes[bytes.len() - 32..].try_into().ok()?;
let transient_id = rns_crypto::sha::full_hash(body);
let workblock =
crate::stamper::stamp_workblock(&transient_id, STAMP_WORKBLOCK_EXPAND_ROUNDS_PN);
let stamp_value = crate::stamper::stamp_value(&workblock, stamp);
crate::stamper::stamp_valid(stamp, minimum_stamp_cost, &workblock).then_some(Self {
let stamp_value = crate::stamper::validated_stamp_value(
&transient_id,
stamp,
minimum_stamp_cost,
STAMP_WORKBLOCK_EXPAND_ROUNDS_PN,
)?;
Some(Self {
bytes,
transient_id,
stamp_value,
@@ -896,8 +899,10 @@ impl PropagationNode {
}
/// Validate and reserve a new opaque propagation image plus its 32-byte stamp.
/// Checks the measured stamp value against `stamp_value` and node policy;
/// this method does not persist the returned plan.
/// `stamp_value` must be one the stamp measures in either workblock form,
/// since a check at another cost can report the other form; the plan
/// records the value measured at the node's cost. This method does not
/// persist the returned plan.
///
/// Stored images retain `lxmf_data || stamp` for peer sync. Client `/get`
/// strips that stamp. Duplicates return `None`; use [`Self::plan_opaque_admission`]
@@ -917,7 +922,13 @@ impl PropagationNode {
let blob =
ValidatedOpaquePropagationBlob::validate(bytes.into(), self.config.min_stamp_cost)?;
if blob.stamp_value() != stamp_value {
return None;
let tid = blob.transient_id();
let expanded = crate::stamper::stamp_workblock(&tid, STAMP_WORKBLOCK_EXPAND_ROUNDS_PN);
if stamp_value != crate::stamper::stamp_value(&tid, stamp_data)
&& stamp_value != crate::stamper::stamp_value(&expanded, stamp_data)
{
return None;
}
}
match self.plan_opaque_admission(blob) {
PropagationAdmission::Reserved(plan) => Some(*plan),
@@ -3313,6 +3324,49 @@ pub(crate) mod tests {
let _ = std::fs::remove_dir_all(&dir);
}
// Upstream LXMF 1.3.1 `validate_pn_stamp` over `range(150)`: a
// non-expanded stamp (8.0703125 at cost 8) and an expanded one (8.1953125
// at cost 8, 2.19921875 at cost 0, from the non-expanded check).
const PN_NE_STAMP: &str = "228341ee29d47d4d9defe50c2704b1feb4bc2ef066a740637916cc690aaa4fd1";
const PN_EXPANDED_STAMP: &str =
"7e340b0726c99d8f60ae845912ecccc8aa7363db7a971a09132acd83c88ad771";
fn pn_vector(stamp: &str) -> (Vec<u8>, [u8; 32]) {
let stamp = hex::decode(stamp).unwrap().try_into().unwrap();
((0..150).collect(), stamp)
}
#[test]
fn non_expanded_deposits_validate_with_their_own_value() {
let (data, stamp) = pn_vector(PN_NE_STAMP);
let blob = ValidatedOpaquePropagationBlob::validate(
[data.as_slice(), &stamp].concat().into(),
8.0,
)
.unwrap();
assert_eq!(blob.stamp_value(), 8.0703125);
let config = PropagationNodeConfig {
min_stamp_cost: 8.0,
..Default::default()
};
let mut node = durable_test_node(config, [0xAA; 16]);
assert!(node.accept_stamped_propagated_blob(&data, &stamp, 8.0703125));
}
#[test]
fn a_value_measured_at_another_cost_is_accepted_at_the_node_value() {
let (data, stamp) = pn_vector(PN_EXPANDED_STAMP);
let config = PropagationNodeConfig {
min_stamp_cost: 8.0,
..Default::default()
};
let mut node = durable_test_node(config, [0xAA; 16]);
assert!(!node.accept_stamped_propagated_blob(&data, &stamp, 9.0));
assert!(node.accept_stamped_propagated_blob(&data, &stamp, 2.19921875));
let tid = rns_crypto::sha::full_hash(&data);
assert_eq!(node.store.get_stamp_value(&tid), Some(8.1953125));
}
#[test]
fn test_accept_propagated_blob_enforces_min_stamp_cost() {
let config = PropagationNodeConfig {
+16
View File
@@ -276,6 +276,22 @@ mod tests {
);
}
#[test]
fn a_non_expanded_peering_key_is_accepted() {
// Upstream LXMF 1.3.1 `validate_peering_key` accepts this key at cost 8
// for the peering id `[0x11; 16] || [0x22; 16]`.
let key = hex::decode("d63d05f5dbe354b33213745d275a343924b38da05098d2b7cbc521ca4ff103d1")
.unwrap();
let request = encode_offer(
Value::Binary(key),
Value::Array(vec![Value::Binary(id(3).to_vec())]),
);
assert_eq!(
evaluate(&request, &[0x11; 16], &[0x22; 16], 8.0, 1024, |_| false),
Ok(PnOfferEvaluation::WantAll)
);
}
#[test]
fn empty_key_is_valid_only_when_peering_work_is_disabled() {
let request = encode_offer(
@@ -58,14 +58,13 @@ fn validate(
}
let stamp_value = if record.stamped {
let stamp: &[u8; 32] = bytes[bytes.len() - 32..].try_into().map_err(err)?;
let workblock = crate::stamper::stamp_workblock(
crate::stamper::validated_stamp_value(
&record.transient_id,
stamp,
minimum_stamp_cost,
crate::constants::STAMP_WORKBLOCK_EXPAND_ROUNDS_PN,
);
if !crate::stamper::stamp_valid(stamp, minimum_stamp_cost, &workblock) {
return Err(invalid("recovered stamp does not meet node policy"));
}
crate::stamper::stamp_value(&workblock, stamp)
)
.ok_or_else(|| invalid("recovered stamp does not meet node policy"))?
} else {
if minimum_stamp_cost > 0.0 {
return Err(invalid("unstamped recovery does not meet node policy"));
+97 -10
View File
@@ -4,6 +4,10 @@
//! validity and generation from `RNS.Stamps`. Only the expand-round counts per
//! stamp kind are LXMF's own (`STAMP_WORKBLOCK_EXPAND_ROUNDS{,_PN,_PEERING}`
//! in constants.rs). Costs and values are fractional on the 1/256 grid.
//!
//! Validation accepts the non-expanded workblock (the material itself) as well
//! as the expanded one, as LXMF 1.3.1 does while senders move to it.
//! Generation stays expanded: LXMF 1.3.0 receivers accept only that form.
use std::sync::atomic::Ordering;
@@ -50,20 +54,43 @@ pub fn generate_stamp(
}))
}
/// The stamp's value when it meets `cost` over the non-expanded workblock,
/// else over `expand_rounds`, from the workblock that passed (LXMF 1.3.1
/// `LXMessage.validate_stamp`, `LXStamper.validate_pn_stamp`). The value can
/// depend on `cost`: below about cost 4 an expanded stamp often passes the
/// non-expanded check too, and at cost 0 it always does.
pub fn validated_stamp_value(
material: &[u8],
stamp: &[u8],
cost: f64,
expand_rounds: usize,
) -> Option<f64> {
if stamp_valid(stamp, cost, material) {
return Some(stamp_value(material, stamp));
}
let workblock = stamp_workblock(material, expand_rounds);
stamp_valid(stamp, cost, &workblock).then(|| stamp_value(&workblock, stamp))
}
/// Whether `stamp` meets `cost` in either workblock form; see [`validated_stamp_value`].
pub fn validate_stamp(
message_id: &[u8; 32],
stamp: &[u8],
cost: f64,
expand_rounds: usize,
) -> bool {
let workblock = stamp_workblock(message_id, expand_rounds);
stamp_valid(stamp, cost, &workblock)
validated_stamp_value(message_id, stamp, cost, expand_rounds).is_some()
}
/// Python reference: `LXStamper.validate_peering_key`.
pub fn validate_peering_key(peering_id: &[u8], peering_key: &[u8], target_cost: f64) -> bool {
let workblock = stamp_workblock(peering_id, STAMP_WORKBLOCK_EXPAND_ROUNDS_PEERING);
stamp_valid(peering_key, target_cost, &workblock)
validated_stamp_value(
peering_id,
peering_key,
target_cost,
STAMP_WORKBLOCK_EXPAND_ROUNDS_PEERING,
)
.is_some()
}
/// Python reference: `LXStamper.validate_pn_stamp`.
@@ -77,11 +104,12 @@ pub fn validate_pn_stamp(transient_data: &[u8], target_cost: f64) -> Option<Prop
let lxm_data = &transient_data[..split];
let stamp: [u8; 32] = transient_data[split..].try_into().ok()?;
let transient_id = rns_crypto::sha::full_hash(lxm_data);
let workblock = stamp_workblock(&transient_id, STAMP_WORKBLOCK_EXPAND_ROUNDS_PN);
if !stamp_valid(&stamp, target_cost, &workblock) {
return None;
}
let value = stamp_value(&workblock, &stamp);
let value = validated_stamp_value(
&transient_id,
&stamp,
target_cost,
STAMP_WORKBLOCK_EXPAND_ROUNDS_PN,
)?;
Some((transient_id, lxm_data.to_vec(), value, stamp))
}
@@ -171,6 +199,59 @@ mod tests {
use crate::constants::{STAMP_WORKBLOCK_EXPAND_ROUNDS, STAMP_WORKBLOCK_EXPAND_ROUNDS_PN};
use rns_crypto::sha::sha256;
// Upstream LXMF 1.3.1 / RNS 1.6.1 results: `LXMessage.validate_stamp`,
// `LXStamper.validate_pn_stamp` and `validate_peering_key` over the same
// inputs (gen_lxmf_ne.py in the K1 hand-back).
fn bytes32(hex: &str) -> [u8; 32] {
hex::decode(hex).unwrap().try_into().unwrap()
}
#[test]
fn message_stamps_validate_in_both_forms_as_upstream() {
let id = bytes32("179201d9189af65b2fee7b97dc90a4e9232121e084050aff94d27f171dc71f55");
let ne = bytes32("84276a6ab90c48763474eef01f7ce3e48b8ffad7f4b0eb1de8dd5761f9614ccd");
let ex = bytes32("a824ef0289c7542b417588d5e93fd3e8e2a0f624c6dc27c1a02e3f864c45fba4");
let rounds = STAMP_WORKBLOCK_EXPAND_ROUNDS;
assert_eq!(
validated_stamp_value(&id, &ne, 8.0, rounds),
Some(11.84765625)
);
assert_eq!(validated_stamp_value(&id, &ex, 8.0, rounds), Some(8.09375));
assert_eq!(
validated_stamp_value(&id, &ex, 0.0, rounds),
Some(0.37109375)
);
assert_eq!(validated_stamp_value(&id, &ne, 11.8515625, rounds), None);
assert!(validate_stamp(&id, &ne, 8.0, rounds));
}
#[test]
fn propagation_stamps_validate_in_both_forms_as_upstream() {
let lxm_data: Vec<u8> = (0..150).collect();
let entry = |stamp: &str| [lxm_data.clone(), bytes32(stamp).to_vec()].concat();
let ne = entry("228341ee29d47d4d9defe50c2704b1feb4bc2ef066a740637916cc690aaa4fd1");
let ex = entry("7e340b0726c99d8f60ae845912ecccc8aa7363db7a971a09132acd83c88ad771");
let value = |entry: &[u8], cost| validate_pn_stamp(entry, cost).map(|parts| parts.2);
assert_eq!(
validate_pn_stamp(&ne, 8.0).unwrap().0,
bytes32("f22b2e614e92d6453612b707385038300293d2cc292b148bc5335754b5ea30fd")
);
assert_eq!(value(&ne, 8.0), Some(8.0703125));
assert_eq!(value(&ex, 8.0), Some(8.1953125));
assert_eq!(value(&ex, 0.0), Some(2.19921875));
assert_eq!(value(&ne, 8.07421875), None);
}
#[test]
fn peering_keys_validate_in_both_forms_as_upstream() {
let id: Vec<u8> = [[0x11; 16], [0x22; 16]].concat();
let ne = bytes32("d63d05f5dbe354b33213745d275a343924b38da05098d2b7cbc521ca4ff103d1");
let ex = bytes32("4269201b6742c33c84098644f37c3f159c66235bda2c26f108cc7c824936ac7f");
assert!(validate_peering_key(&id, &ne, 8.0));
assert!(validate_peering_key(&id, &ex, 8.0));
assert!(!validate_peering_key(&id, &ne, 8.2578125));
}
fn found(material: &[u8], cost: f64, rounds: usize) -> ([u8; 32], f64) {
generate_stamp(material, cost, rounds, &StampControl::default())
.unwrap()
@@ -242,7 +323,13 @@ mod tests {
fn pn_stamp_parts_carry_the_fractional_value() {
let lxm_data = vec![0xAB; LXMF_OVERHEAD + 64];
let tid = rns_crypto::sha::full_hash(&lxm_data);
let (stamp, value) = found(&tid, 2.5, STAMP_WORKBLOCK_EXPAND_ROUNDS_PN);
// At cost 2.5 an expanded stamp often meets the non-expanded check too; keep one that doesn't.
let (stamp, value) = loop {
let (stamp, value) = found(&tid, 2.5, STAMP_WORKBLOCK_EXPAND_ROUNDS_PN);
if !stamp_valid(&stamp, 2.5, &tid) {
break (stamp, value);
}
};
let mut transient_data = lxm_data.clone();
transient_data.extend_from_slice(&stamp);
let (transient_id, extracted, got, extracted_stamp) =
+15 -8
View File
@@ -7132,8 +7132,9 @@ pub(crate) async fn main() {
}
}
// Reticulum's exit handler deregisters this process's destination types.
rns_handle.unwants_all_destination_types().await;
// Reticulum's exit handler: runtime shutdown deregisters this process's
// destination types once, then persists transport state.
rns_handle.shutdown_and_wait().await;
tracing::info!("LXMF Daemon stopped");
if let Some(status) = one_shot_status {
std::process::exit(status);
@@ -7327,8 +7328,12 @@ mod tests {
remove_earlier_ratchet_files(&paths).unwrap();
}
/// A recipient's delivery announce, with `ratchet` as its ratchet key.
fn recipient_announce(recipient: &Identity, ratchet: Option<&[u8; 32]>) -> (Vec<u8>, [u8; 16]) {
/// A recipient's delivery announce, with `ratchet` as its ratchet key, emitted at `emitted`.
fn recipient_announce(
recipient: &Identity,
ratchet: Option<&[u8; 32]>,
emitted: f64,
) -> (Vec<u8>, [u8; 16]) {
let mut destination = Destination::new(
Some(recipient),
rns_identity::destination::Direction::In,
@@ -7337,7 +7342,7 @@ mod tests {
)
.unwrap();
let raw = destination
.announce_packet(recipient, None, ratchet, false, None, now_f64())
.announce_packet(recipient, None, ratchet, false, None, emitted)
.unwrap();
(raw, destination.hash)
}
@@ -7404,7 +7409,7 @@ mod tests {
let recipient = Identity::new();
let ratchet_key = rns_crypto::x25519::X25519PrivateKey::generate().to_bytes();
let ratchet = rns_identity::ratchet::ratchet_public_bytes(&ratchet_key);
let (announce, recipient_hash) = recipient_announce(&recipient, Some(&ratchet));
let (announce, recipient_hash) = recipient_announce(&recipient, Some(&ratchet), now_f64());
let (reticulum, _shutdown) = standalone_reticulum(&rns).await;
let _driver = hear_and_recall(&reticulum, &announce, recipient_hash, Some(ratchet)).await;
@@ -7450,7 +7455,8 @@ mod tests {
let lxmf_dir = temp.path().join("lxmf");
initialize_storage_namespace(&lxmf_dir).unwrap();
let recipient = Identity::new();
let (announce, recipient_hash) = recipient_announce(&recipient, None);
let emitted = now_f64();
let (announce, recipient_hash) = recipient_announce(&recipient, None, emitted);
let (reticulum, _shutdown) = standalone_reticulum(&rns).await;
let _driver = hear_and_recall(&reticulum, &announce, recipient_hash, None).await;
@@ -7496,7 +7502,8 @@ mod tests {
let ratchet_key = rns_crypto::x25519::X25519PrivateKey::generate().to_bytes();
let ratchet = rns_identity::ratchet::ratchet_public_bytes(&ratchet_key);
let (announce, _) = recipient_announce(&recipient, Some(&ratchet));
// A later second: Reticulum's prefilter drops a same-second re-announce on the same path.
let (announce, _) = recipient_announce(&recipient, Some(&ratchet), emitted + 1.0);
let _driver = hear_and_recall(&reticulum, &announce, recipient_hash, Some(ratchet)).await;
let ciphertext =
encrypt_next_message(&mut runner, recipient_hash, "after it announces").await;
+2 -1
View File
@@ -482,10 +482,11 @@ mod tests {
data.set_name("Node");
// Upstream metadata order: 0xFE impl name, 0x00 version, then binary 0x01 name.
// `LXMRouter.get_propagation_node_app_data` at LXMF 1.3.1, `time.time` fixed to the timebase.
assert_eq!(
hex::encode(propagation_announce_app_data(&data)),
concat!(
"98c2ce6553f100c3cd0100cd28009311031383ccfea46c786d6400a5312e332e3001c4044e6f6465",
"98c2ce6553f100c3cd0100cd28009311031383ccfea46c786d6400a5312e332e3101c4044e6f6465",
"93cb4030400000000000cb4008000000000000cb4032800000000000"
)
);