28 Commits
Author SHA1 Message Date
DeFiDude 83b88146f4 transport: discover paths for roaming interfaces 2026-06-26 16:10:52 -06:00
DeFiDude 3ddf3c362b test: Ed25519 validate() rejects tampered signatures 2026-06-12 14:01:51 -06:00
DeFiDude 858010cee0 AutoInterface: carrier-change handling, configurable hops, port-collision guard 2026-05-01 16:06:36 -06:00
DeFiDude 670820a41e Add AutoInterface (IPv6 multicast LAN auto-discovery, Python-wire-compatible) 2026-04-25 20:36:59 -06:00
DeFiDude 352de23ed0 Add E2E loopback tests: 8 tests covering full protocol flow
Validates the complete C++ protocol stack without hardware:
1. testE2eSmallMessage — LXMF <263B pack/unpack/sign/verify
2. testE2eLargeMessage — LXMF >263B (resource-needed size)
3. testE2eImageField — LXMF with FIELD_IMAGE nested array
4. testE2eResourceRoundtrip — chunking + map hash + assembly
5. testE2eBz2Roundtrip — bz2 compress/decompress (1000B)
6. testE2eBz2DeterministicFixture — BZh magic + roundtrip (400x'A')
7. testE2eAnnounceWithRatchet — 180-byte announce with ratchet key
8. testE2eBidirectionalLxmf — two identities, A→B + B→A

All 8 tests pass on native17. Total: 145 C++ tests (144 pass).
2026-03-24 17:34:26 -06:00
DeFiDude 166083aba7 Add bz2 compression for Resource transfer + 3 compression tests
Vendor libbzip2 (1.0.8, BSD license) for ESP32-compatible bz2
compression/decompression. This matches Python's bz2.compress()
and Rust's bzip2 crate for cross-platform Resource transfers.

C++ wrapper (Compression/BZ2.h):
- bz2_compress() — compress with blockSize100k=9
- bz2_decompress() — decompress with progressive buffer sizing
- try_compress() — compress only if smaller than original

Resource integration:
- OutboundResource::init() now compresses with bz2 if beneficial
- InboundResource::assemble() decompresses if compressed flag set
- ResourceFlags.compressed bit tracks compression state

3 new tests (test_resource_transfer):
- testBz2CompressDecompress — roundtrip verification
- testTryCompress — beneficial vs non-beneficial compression
- testBz2CrossPlatformFormat — BZh magic bytes match Python/Rust

Total: 137 tests, 136 pass (1 pre-existing allocator).
2026-03-24 17:15:42 -06:00
DeFiDude 798512e8f7 Implement Resource transfer: advertisement, map hash, chunking, assembly
Complete rewrite of Resource.h/cpp with full protocol implementation:

ResourceAdvertisement: msgpack map pack/unpack with 11 string keys
  (t,d,n,h,r,o,i,l,q,f,m) matching Python/Rust wire format.

OutboundResource (sender): compress → encrypt → chunk → hashmap → advertise.
  Splits encrypted blob into SDU-sized parts (263 bytes), computes
  SHA256(chunk||random_hash)[:4] map hashes, handles receiver requests.

InboundResource (receiver): accept advertisement → receive parts by map hash
  → assemble → decrypt → decompress. Sends initial request, generates proof.

Helper functions: get_map_hash(), compute_resource_hash(),
  compute_expected_proof() — all match Python/Rust implementations.

8 new tests (test_resource_transfer): advertisement roundtrip, map hash,
  resource hash, proof, flag encoding, nil/non-nil request_id.

Legacy Resource class preserved for Link.cpp compatibility.
2026-03-24 16:48:55 -06:00
DeFiDude 65ecaef894 Add test_announce_interop (6 tests) + test_protocol_edge_cases (6 tests)
Announce interop tests:
1. testAnnouncePack — 148-byte announce wire format
2. testAnnounceUnpack — verify field offsets + signature validation
3. testAnnounceWithRatchet — 180-byte announce with 32-byte ratchet key
4. testAppDataExtraction — msgpack and UTF-8 app_data formats
5. testDestHashFromIdentity — delivery + propagation dest hash computation
6. testNameHashes — lxmf.delivery, lxmf.propagation, nomadnetwork.node

Protocol edge case tests:
1. testPacketFlagCombinations — all critical flag byte values
2. testHashMasking — Header1 and Header2 produce same packet hash
3. testHopsDoNotAffectHash — hops excluded from hash computation
4. testMTUBoundary — 500 byte MTU, header sizes (19/35)
5. testIdentityHashLength — 16 bytes truncated, 64 bytes pubkey
6. testEncryptDecryptRoundtrip — ECIES token encrypt/decrypt

All 12 tests pass on native17.
2026-03-24 15:50:37 -06:00
DeFiDude ed362a52ee Add test_lxmf_interop: 10 cross-platform fixture + wire format tests
New test suite generating deterministic LXMF and protocol fixtures for
Rust validation:
1. testLxmfWithImageField — LXMF with FIELD_IMAGE (nested array)
2. testLxmfWithFileAttachment — LXMF with FIELD_FILE_ATTACHMENTS
3. testLxmfWithMultipleFields — LXMF with CUSTOM_TYPE + CUSTOM_DATA
4. testAnnounceUtf8AppData — announce with raw UTF-8 (Rust format)
5. testAnnounceMsgpackAppData — announce with msgpack array (Ratdeck format)
6. testOpportunisticWireNoDestHash — [src:16][sig:64][packed] format
7. testSignallingBytesPacking — mode+MTU bitfield encoding
8. testPacketFlagEncoding — all flag byte combinations
9. testTruncatedHashLengths — 16/32/10 byte hash outputs
10. testHeaderFormats — Header1 (19 bytes) vs Header2 (35 bytes)

All fixture values printed as hex for Rust cpp_interop_fields.rs to validate.
10/10 tests pass on native17.
2026-03-24 15:46:04 -06:00
DeFiDude fb76b6707b Add test_lxmf_codec: 10 LXMF packing/unpacking/signing tests
New test suite validating the LXMF message codec on native platform:
1. testPackContentRoundtrip — fixarray(4) structure
2. testPackContentBinEncoding — title/content as bin (0xC4), not str
3. testPackFullOpportunistic — wire: [src:16][sig:64][packed]
4. testPackFullDirect — wire: [dest:16][src:16][sig:64][packed]
5. testUnpackFull — pack → unpack → verify fields
6. testSignatureVerification — Ed25519 sign/verify roundtrip
7. testMessageIdComputation — deterministic SHA256 hash
8. testEmptyTitleAndContent — edge case: empty strings
9. testUnicodeContent — UTF-8 content round-trip
10. testMaxSizeContent — 280 bytes (near opportunistic limit)

All 10 tests pass on native17. Uses same deterministic seeds as
test_cross_compat for consistency.
2026-03-24 15:38:19 -06:00
DeFiDude 813d9095d7 Fix PKCS7 padding, identity persistence, and packet routing 2026-03-13 04:20:04 -06:00
Chad Attermann 4d6f0b9de2 Added dual-class PSRAM/TLSF allocator system and refactored memory management
Introduces a flexible two-class allocator architecture (RNS_DEFAULT_ALLOCATOR and RNS_CONTAINER_ALLOCATOR) supporting heap, PSRAM, and TLSF pool variants for fine-grained control over embedded memory layout.

- New Memory.h/cpp with ContainerAllocator<T>, heap/PSRAM/pool allocator types, and heap stats reporting
- IdentityTable and PathTable now use ContainerAllocator
- Replaced RNS_USE_TLSF/RNS_USE_ALLOCATOR/RNS_USE_PSRAM flags with per-class allocator flags (RNS_DEFAULT_ALLOCATOR, RNS_CONTAINER_ALLOCATOR)
- Added ESP32 PSRAM allocator support (RNS_PSRAM_ALLOCATOR, RNS_PSRAM_POOL_ALLOCATOR)
- Added Transport::get_path()/remove_path() helpers
- Added loop callback (set_loop_callback) to enable more responsive app during long operations (like clean_cache)
- Aded guard against re-entrancy to clean_cache()
- Added callback option to list_directory() to avoid heap allocation
- Added OOM auto-restart (ESP.restart/NVIC_SystemReset) in Interface send/receive and Reticulum loop.
- Renamed setLogCallback to set_log_callback
- Made Link/Identity static members private
- Added native14 env to CI and platformio.ini
- Bumped version to 0.2.10
2026-03-06 16:43:04 -07:00
Chad Attermann 49ccbc2827 Major bug fixes and performance enhancements
- Fixed bug in path table loading from flash storage wherein the raw
(packed) announce packet associated with each path entry was not being
unpacked prior to use.
- Fixed bug in path table entry announce packet loading where critical
changes to the announce packet (like hops increment) was being
overwriteen each time packet was re-loaded from cache.
- Optimized path table entries to lazy-load both announce packet and
receive interface so that memory is consumed by these structures until
if/when the path is actually used.
- Updated several global timers and sizes to match new RNS 1.x values.
- Bumped version to 0.2.9
2026-03-03 17:53:06 -07:00
Chad Attermann 9289da1a19 Bump to version 0.2.7. 2026-03-01 12:45:35 -07:00
Chad Attermann 79b75bbd4e Replace string-concatenation logging with printf-style F-variants
Converted log calls across src/, examples/, and test/ to use DEBUGF/TRACEF/ERRORF/etc. macros instead of std::string + operator+. This eliminates temporary heap allocations on every log call, which matters on memory-constrained MCUs.
2026-03-01 10:59:33 -07:00
Chad Attermann e86481e121 Add announce table culling, fix use-after-free, and refactor build/log
- Add cull_announce_table() with OOM-safe min_element fallback, matching pattern from cull_path_table() and cull_known_destinations()
- Call cull immediately after every announce/path/known-destination insert
- Fix use-after-free: guard announce_entry access with announce_erased flag
- remove_path() now also deletes cached packet files
- Path table insert now removes existing entry first to prevent duplicates
- Rename env:mcu -> env:embedded; add env:native_debug and heltec_wifi_lora_32_V4
- Make TLSF buffer size configurable via RNS_TLSF_BUFFER_SIZE macro
- Refactor log macros to unified RNS::log() path; add doHeadLog with callback support
- Prefix all bad_alloc error messages with "bad_alloc -" for easier grepping
2026-02-28 19:54:15 -07:00
Chad Attermann d76bfce7ce Update test_main.cpp
Disabled `test_receipt_timeout_callback` test which is currently failing.
2026-02-24 13:24:29 -07:00
Dan BeardandClaude Opus 4.6 6a705bc582 Add transport and Bytes unit tests
Tests for Bytes::assignHex, appendHex, mid() edge cases, and
Transport receipt culling logic. 18 test cases covering the bugs
fixed in the previous commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:46:39 -06:00
Chad Attermann 27433edb19 Updates for MCU builds broken by previous dev. 2026-02-09 13:52:13 -07:00
Chad Attermann 818782382a Enhance Bytes, fix for Lins, test/example updates
- Added convenience methods to Bytes class
- Fix for logic error in Link class compliments of @cobraPA
- Added unit tests
- Updated example apps
2026-01-21 12:38:13 -07:00
Chad Attermann b8be484624 WIP: Major refactor of unit and integration tests 2025-08-26 21:05:36 -06:00
Chad Attermann fe687d391b WIP: Migrated a few unit tests to Unity 2025-08-26 10:49:37 -06:00
Chad Attermann bac53b9e6d WIP: Integrated Unity test framework. 2025-08-25 14:42:15 -06:00
Chad Attermann 11155b5829 WIP: Completed but un-tested port of Link.
Link is now mostly ported from Python but as of yet un-tested.
Refactored Interface.
Orgnanized example apps.
2025-08-21 17:29:26 -06:00
Chad Attermann fcfda66365 WIP: General improvements in persistence efficiency 2024-08-14 21:59:23 -06:00
Chad Attermann f415b5e0b5 WIP: Enhancements to persistence 2024-06-03 08:13:45 -06:00
attermann 1b919a9489 WIP Update
Cleaned up and organized test functions.
Implemented Ed25519.
2023-10-07 01:03:15 -06:00
attermann eef5f1b326 Initial commit 2023-10-06 17:24:48 -06:00