diff --git a/CHANGELOG.md b/CHANGELOG.md
index cbadef715..8239b8e74 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,33 @@ Questions about a release, or about upgrading to one? Ask in the
### Added
+- **A reference gateway daemon, and with it LoRa**
+ ([ADR 0040](docs/adr/0040-a-reference-gateway-ships-with-the-sdk.md)).
+ The `reticulum` transport's device half has spoken the
+ [gateway contract](docs/spec/gateway-contract.md) since 0.25, but nothing in
+ the SDK answered it, so the transport never became available.
+ [`gateway/`](gateway/README.md) is the other half, in Python: devices attach
+ over local IP with a proof it checks through
+ `verify_gateway_address_proof`, and every submission gets exactly one
+ verdict. With a `[reticulum]` section it also carries frames and presence to
+ provisioned peer gateways over Reticulum, which is how an RNode's LoRa radio
+ reaches the SDK. No device-side change is needed: enable `reticulum` and
+ point its daemon address at the gateway. Two real engines pair over MLS and
+ exchange a message across two daemon processes joined by a Reticulum
+ backbone in its tests; it has not yet been run over radios. Expect a first
+ contact between two devices to cost about 20 backbone frames each: by
+ arithmetic, a few minutes on the example radio (SF8, 10 % airtime) and
+ hours at 1 %. A new gateway is unreachable while Reticulum mints its
+ one-time announce stamp.
+- **A gateway daemon can verify a device's attach proof without building
+ it: `verify_gateway_address_proof(address, public_key, signature,
+ challenge)`**, instance-less, in every binding and over the C API's
+ instance-less call. It is the gateway half of
+ `gateway_address_declaration`: it checks the signature over the one
+ canonical payload ([the gateway contract](docs/spec/gateway-contract.md#attach))
+ and that the key derives to the claimed address, and returns that address
+ or throws. A daemon still owns the third check, that the challenge is the
+ one it minted for this connection and has not been accepted before.
- **A browser page can dial a native app on the same Wi-Fi network, or on
the phone's own hotspot, from one code the app shows: WebRTC Direct**
([ADR 0039](docs/adr/0039-a-browser-dials-a-native-device-from-a-code.md)).
@@ -55,6 +82,14 @@ Questions about a release, or about upgrading to one? Ask in the
### Changed
+- **Media on the `reticulum` (gateway) transport is chunked at 64 KiB, the
+ peer-stream size, instead of 4 KiB.** The slot is a stream to a gateway
+ daemon over local IP, and the device never sizes frames to the backbone
+ behind it (ADR 0026). At 4 KiB every chunk slipped under a scarce
+ gateway's frame bound, so media crossed a LoRa backbone, which the gateway
+ contract says it MUST NOT; now every full chunk is refused
+ `frame_too_large` there, and a broad gateway carries transfers in fewer,
+ larger frames.
- **The mesh `appId` is now `appLabel`** (`app_label` in Rust, Python, Ruby
and the C API), so it is no longer mistaken for the App ID (`app_…`) the
developer portal issues for telemetry. Only the name changed: the value
diff --git a/CLAUDE.md b/CLAUDE.md
index 4eb6c7a4e..54eafcc8b 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -25,6 +25,7 @@ that are versioned, reviewable, and readable by people who are not an agent.
| `offline-protocol-sealed`: the envelope codec, `derive_address`, canonical signing payloads, ratchet constants, the 1:1 control-frame prefixes, `KeyPackagePayload`, the identity assertion codec | ADR [0022](docs/adr/0022-one-sealed-layer-shared-with-the-leaf.md) (also dual std/no_std, and the one home for each) |
| `offline-protocol-leaf`: anything a device does at pairing, on a frame, or with its store | ADR [0021](docs/adr/0021-a-leaf-node-speaks-mls.md) and [docs/spec/leaf-provisioning.md](docs/spec/leaf-provisioning.md) (a time source, real entropy, durable-before-emit and authorization are obligations, not suggestions) |
| The fast link: bringing up Wi-Fi between two devices that meet over Bluetooth, the `__FAST_LINK__` frame, the bridges' host and join code | ADR [0038](docs/adr/0038-a-fast-link-is-offered-inside-the-session.md) and [the fast link state machine](docs/state-machines/fast-link.md) (credentials only ever travel sealed and ephemeral; the host admits only the invitee) |
+| The gateway daemon: `gateway/`, the Reticulum (LoRa) backbone, `verify_gateway_address_proof` | ADR [0040](docs/adr/0040-a-reference-gateway-ships-with-the-sdk.md), [the gateway contract](docs/spec/gateway-contract.md) and [gateway/README.md](gateway/README.md) (the daemon never builds the proof payload itself; a backbone verdict waits for the peer gateway; the scarce burst must cover a first contact) |
| Replicated documents: the store, sync frames, attachments | [docs/spec/data-sync.md](docs/spec/data-sync.md), [the replication state machine](docs/state-machines/data-replication.md), ADR [0018](docs/adr/0018-data-layer-engine-and-storage-seams.md) and [0019](docs/adr/0019-remote-document-imports-are-contained-not-trusted.md) |
| Any binding: Swift, Kotlin, Python, TypeScript, C, Java, Ruby, the browser | [docs/bridges/](docs/bridges/README.md) |
| The C API: `offline-protocol-uniffi/src/capi`, `bindings/c` | [docs/bridges/c.md](docs/bridges/c.md) (the dispatcher is generated from the UDL; the header is generated by cbindgen and committed) |
diff --git a/bindings/c/include/offline_protocol.h b/bindings/c/include/offline_protocol.h
index 47f9949b2..4d5d866b0 100644
--- a/bindings/c/include/offline_protocol.h
+++ b/bindings/c/include/offline_protocol.h
@@ -244,8 +244,9 @@ const char *offline_protocol_version(void);
/**
* Calls one of the definition's instance-less functions
- * (`derive_address`, `parse_invite`, `verify_identity_assertion`), which
- * need no engine and may run before `offline_protocol_create`.
+ * (`derive_address`, `parse_invite`, `verify_identity_assertion`,
+ * `verify_gateway_address_proof`), which need no engine and may run before
+ * `offline_protocol_create`.
*
* `params_json` is a JSON object keyed by the definition's parameter names,
* or null for none. On success `*out_result` is the result as JSON, freed
diff --git a/bindings/csharp/local_api_methods.txt b/bindings/csharp/local_api_methods.txt
index 8ed403d4f..d272bbf99 100644
--- a/bindings/csharp/local_api_methods.txt
+++ b/bindings/csharp/local_api_methods.txt
@@ -208,6 +208,7 @@ update_dors_config
update_relay_config
update_retry_config
update_transport_metrics
+verify_gateway_address_proof
verify_identity_assertion
verify_signature
verify_signature_bytes
diff --git a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/Enums.g.cs b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/Enums.g.cs
index 9b3c68a50..856b8d3e8 100644
--- a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/Enums.g.cs
+++ b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/Enums.g.cs
@@ -1,6 +1,6 @@
//
// Generated by tools/gen_csharp_local_api.py from offline_protocol.udl
-// UDL_SHA256 = 5d2c20ac6054a3ac6d1890f1d539f686f2fff6119beae596b682ba0569e1a9ae
+// UDL_SHA256 = 702b40d0a44e0b060e63b9673cd10715a3a357d547724d42c7e9074af2d3c06b
// Do not edit.
#nullable enable
diff --git a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/LocalApiClients.g.cs b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/LocalApiClients.g.cs
index da83e9d6e..66461699a 100644
--- a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/LocalApiClients.g.cs
+++ b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/LocalApiClients.g.cs
@@ -1,6 +1,6 @@
//
// Generated by tools/gen_csharp_local_api.py from offline_protocol.udl
-// UDL_SHA256 = 5d2c20ac6054a3ac6d1890f1d539f686f2fff6119beae596b682ba0569e1a9ae
+// UDL_SHA256 = 702b40d0a44e0b060e63b9673cd10715a3a357d547724d42c7e9074af2d3c06b
// Do not edit.
#nullable enable
diff --git a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolConfig.g.cs b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolConfig.g.cs
index bf4ef7340..7c471024b 100644
--- a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolConfig.g.cs
+++ b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolConfig.g.cs
@@ -1,6 +1,6 @@
//
// Generated by tools/gen_csharp_local_api.py from offline_protocol.udl
-// UDL_SHA256 = 5d2c20ac6054a3ac6d1890f1d539f686f2fff6119beae596b682ba0569e1a9ae
+// UDL_SHA256 = 702b40d0a44e0b060e63b9673cd10715a3a357d547724d42c7e9074af2d3c06b
// Do not edit.
#nullable enable
diff --git a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part01.g.cs b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part01.g.cs
index e7328f5a5..87bc9fdb9 100644
--- a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part01.g.cs
+++ b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part01.g.cs
@@ -1,6 +1,6 @@
//
// Generated by tools/gen_csharp_local_api.py from offline_protocol.udl
-// UDL_SHA256 = 5d2c20ac6054a3ac6d1890f1d539f686f2fff6119beae596b682ba0569e1a9ae
+// UDL_SHA256 = 702b40d0a44e0b060e63b9673cd10715a3a357d547724d42c7e9074af2d3c06b
// Do not edit.
#nullable enable
diff --git a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part02.g.cs b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part02.g.cs
index 4bcc7cb3c..ef3743bfd 100644
--- a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part02.g.cs
+++ b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part02.g.cs
@@ -1,6 +1,6 @@
//
// Generated by tools/gen_csharp_local_api.py from offline_protocol.udl
-// UDL_SHA256 = 5d2c20ac6054a3ac6d1890f1d539f686f2fff6119beae596b682ba0569e1a9ae
+// UDL_SHA256 = 702b40d0a44e0b060e63b9673cd10715a3a357d547724d42c7e9074af2d3c06b
// Do not edit.
#nullable enable
diff --git a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part03.g.cs b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part03.g.cs
index 0ff21bc95..fb904986f 100644
--- a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part03.g.cs
+++ b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.LocalApi.part03.g.cs
@@ -1,6 +1,6 @@
//
// Generated by tools/gen_csharp_local_api.py from offline_protocol.udl
-// UDL_SHA256 = 5d2c20ac6054a3ac6d1890f1d539f686f2fff6119beae596b682ba0569e1a9ae
+// UDL_SHA256 = 702b40d0a44e0b060e63b9673cd10715a3a357d547724d42c7e9074af2d3c06b
// Do not edit.
#nullable enable
diff --git a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.Static.g.cs b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.Static.g.cs
index e3eaf13d7..74b59b0b8 100644
--- a/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.Static.g.cs
+++ b/bindings/csharp/src/OfflineProtocol.Sdk/Generated/ProtocolEngine.Static.g.cs
@@ -1,6 +1,6 @@
//
// Generated by tools/gen_csharp_local_api.py from offline_protocol.udl
-// UDL_SHA256 = 5d2c20ac6054a3ac6d1890f1d539f686f2fff6119beae596b682ba0569e1a9ae
+// UDL_SHA256 = 702b40d0a44e0b060e63b9673cd10715a3a357d547724d42c7e9074af2d3c06b
// Do not edit.
#nullable enable
@@ -19,6 +19,9 @@ public static Task DeriveAddressAsync(string? parametersJson = null, Can
public static Task ParseInviteAsync(string? parametersJson = null, CancellationToken cancellationToken = default) =>
CallStaticAsync("parse_invite", parametersJson, cancellationToken);
+ public static Task VerifyGatewayAddressProofAsync(string? parametersJson = null, CancellationToken cancellationToken = default) =>
+ CallStaticAsync("verify_gateway_address_proof", parametersJson, cancellationToken);
+
public static Task VerifyIdentityAssertionAsync(string? parametersJson = null, CancellationToken cancellationToken = default) =>
CallStaticAsync("verify_identity_assertion", parametersJson, cancellationToken);
}
diff --git a/bindings/java/src/main/java/com/offlineprotocol/sdk/NamespaceLibrary.java b/bindings/java/src/main/java/com/offlineprotocol/sdk/NamespaceLibrary.java
index 810b153cc..80047af6a 100644
--- a/bindings/java/src/main/java/com/offlineprotocol/sdk/NamespaceLibrary.java
+++ b/bindings/java/src/main/java/com/offlineprotocol/sdk/NamespaceLibrary.java
@@ -40,6 +40,9 @@ static void uniffiCheckApiChecksums() {
if (UniffiLib.uniffi_offline_protocol_uniffi_checksum_func_run_storage_conformance() != ((short) 20699)) {
throw new RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project");
}
+ if (UniffiLib.uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof() != ((short) 21016)) {
+ throw new RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project");
+ }
if (UniffiLib.uniffi_offline_protocol_uniffi_checksum_func_verify_identity_assertion() != ((short) 61480)) {
throw new RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project");
}
diff --git a/bindings/java/src/main/java/com/offlineprotocol/sdk/OfflineProtocolLib.java b/bindings/java/src/main/java/com/offlineprotocol/sdk/OfflineProtocolLib.java
index 27ea86df6..50f664c62 100644
--- a/bindings/java/src/main/java/com/offlineprotocol/sdk/OfflineProtocolLib.java
+++ b/bindings/java/src/main/java/com/offlineprotocol/sdk/OfflineProtocolLib.java
@@ -68,6 +68,28 @@ public static java.lang.String runStorageConformance(ProtocolStateStorageProvide
}
+ public static java.lang.String verifyGatewayAddressProof(java.lang.String address, java.util.List publicKey, java.util.List signature, java.util.List challenge) throws ProtocolException {
+ try {
+ return FfiConverterString.INSTANCE.lift(
+ UniffiHelpers.uniffiRustCallWithError(new ProtocolExceptionErrorHandler(), (_allocator, _status) -> {
+ return UniffiLib.uniffi_offline_protocol_uniffi_fn_func_verify_gateway_address_proof(_allocator,
+ FfiConverterString.INSTANCE.lower(address), FfiConverterSequenceByte.INSTANCE.lower(publicKey), FfiConverterSequenceByte.INSTANCE.lower(signature), FfiConverterSequenceByte.INSTANCE.lower(challenge), _status);
+ })
+ );
+ } catch (java.lang.RuntimeException _uniffi_ex) {
+
+ if (ProtocolException.class.isInstance(_uniffi_ex.getCause())) {
+ throw (ProtocolException)_uniffi_ex.getCause();
+ }
+
+ if (InternalException.class.isInstance(_uniffi_ex.getCause())) {
+ throw (InternalException)_uniffi_ex.getCause();
+ }
+ throw _uniffi_ex;
+ }
+ }
+
+
public static java.lang.String verifyIdentityAssertion(java.util.List assertion) throws ProtocolException {
try {
return FfiConverterString.INSTANCE.lift(
diff --git a/bindings/java/src/main/java/com/offlineprotocol/sdk/UniffiLib.java b/bindings/java/src/main/java/com/offlineprotocol/sdk/UniffiLib.java
index 884f9b774..3869e9f41 100644
--- a/bindings/java/src/main/java/com/offlineprotocol/sdk/UniffiLib.java
+++ b/bindings/java/src/main/java/com/offlineprotocol/sdk/UniffiLib.java
@@ -2396,6 +2396,15 @@ static java.lang.foreign.MemorySegment uniffi_offline_protocol_uniffi_fn_func_ru
} catch (Throwable _ex) { throw new AssertionError("invokeExact failed", _ex); }
}
+ // uniffi_offline_protocol_uniffi_fn_func_verify_gateway_address_proof
+ private static final java.lang.invoke.MethodHandle MH_uniffi_offline_protocol_uniffi_fn_func_verify_gateway_address_proof = findDowncallHandle("uniffi_offline_protocol_uniffi_fn_func_verify_gateway_address_proof", java.lang.foreign.FunctionDescriptor.of(RustBuffer.LAYOUT, RustBuffer.LAYOUT, RustBuffer.LAYOUT, RustBuffer.LAYOUT, RustBuffer.LAYOUT, java.lang.foreign.ValueLayout.ADDRESS));
+
+ static java.lang.foreign.MemorySegment uniffi_offline_protocol_uniffi_fn_func_verify_gateway_address_proof(java.lang.foreign.SegmentAllocator _allocator, java.lang.foreign.MemorySegment address, java.lang.foreign.MemorySegment publicKey, java.lang.foreign.MemorySegment signature, java.lang.foreign.MemorySegment challenge, java.lang.foreign.MemorySegment _uniffiOutErr) {
+ try {
+ return (java.lang.foreign.MemorySegment) MH_uniffi_offline_protocol_uniffi_fn_func_verify_gateway_address_proof.invokeExact(_allocator, address, publicKey, signature, challenge, _uniffiOutErr);
+ } catch (Throwable _ex) { throw new AssertionError("invokeExact failed", _ex); }
+ }
+
// uniffi_offline_protocol_uniffi_fn_func_verify_identity_assertion
private static final java.lang.invoke.MethodHandle MH_uniffi_offline_protocol_uniffi_fn_func_verify_identity_assertion = findDowncallHandle("uniffi_offline_protocol_uniffi_fn_func_verify_identity_assertion", java.lang.foreign.FunctionDescriptor.of(RustBuffer.LAYOUT, RustBuffer.LAYOUT, java.lang.foreign.ValueLayout.ADDRESS));
@@ -2900,6 +2909,15 @@ static short uniffi_offline_protocol_uniffi_checksum_func_run_storage_conformanc
} catch (Throwable _ex) { throw new AssertionError("invokeExact failed", _ex); }
}
+ // uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof
+ private static final java.lang.invoke.MethodHandle MH_uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof = findDowncallHandle("uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof", java.lang.foreign.FunctionDescriptor.of(java.lang.foreign.ValueLayout.JAVA_SHORT));
+
+ static short uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof() {
+ try {
+ return (short) MH_uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof.invokeExact();
+ } catch (Throwable _ex) { throw new AssertionError("invokeExact failed", _ex); }
+ }
+
// uniffi_offline_protocol_uniffi_checksum_func_verify_identity_assertion
private static final java.lang.invoke.MethodHandle MH_uniffi_offline_protocol_uniffi_checksum_func_verify_identity_assertion = findDowncallHandle("uniffi_offline_protocol_uniffi_checksum_func_verify_identity_assertion", java.lang.foreign.FunctionDescriptor.of(java.lang.foreign.ValueLayout.JAVA_SHORT));
diff --git a/bindings/python/offline_protocol_sdk/local_api/dispatch.py b/bindings/python/offline_protocol_sdk/local_api/dispatch.py
index 92b3df90a..25bfdf6e7 100644
--- a/bindings/python/offline_protocol_sdk/local_api/dispatch.py
+++ b/bindings/python/offline_protocol_sdk/local_api/dispatch.py
@@ -186,6 +186,7 @@
"derive_address",
"parse_invite",
"verify_identity_assertion",
+ "verify_gateway_address_proof",
}
)
@@ -338,7 +339,12 @@
#: The one group a client may call before ``hello``: nothing to stamp,
#: nothing to route.
BEFORE_HELLO: frozenset[str] = frozenset(
- {"derive_address", "parse_invite", "verify_identity_assertion"}
+ {
+ "derive_address",
+ "parse_invite",
+ "verify_identity_assertion",
+ "verify_gateway_address_proof",
+ }
)
#: Methods whose result is an identifier (or a list of them) that later
diff --git a/bindings/python/offline_protocol_sdk/local_api/table.py b/bindings/python/offline_protocol_sdk/local_api/table.py
index a15f4ac68..d5aad3d4d 100644
--- a/bindings/python/offline_protocol_sdk/local_api/table.py
+++ b/bindings/python/offline_protocol_sdk/local_api/table.py
@@ -9,7 +9,7 @@
from __future__ import annotations
-UDL_SHA256 = "5d2c20ac6054a3ac6d1890f1d539f686f2fff6119beae596b682ba0569e1a9ae"
+UDL_SHA256 = "702b40d0a44e0b060e63b9673cd10715a3a357d547724d42c7e9074af2d3c06b"
TABLE = {'callbacks': ('MlsStorageProvider',
'ProtocolStateStorageProvider',
@@ -604,6 +604,11 @@
'run_storage_conformance': ((('storage',
'ProtocolStateStorageProvider'),),
'string'),
+ 'verify_gateway_address_proof': ((('address', 'string'),
+ ('public_key', 'sequence'),
+ ('signature', 'sequence'),
+ ('challenge', 'sequence')),
+ 'string'),
'verify_identity_assertion': ((('assertion', 'sequence'),),
'string')}},
'records': {'AckConfig': (('default_timeout_ms', 'u64', False),
diff --git a/bindings/python/offline_protocol_sdk/offline_protocol.py b/bindings/python/offline_protocol_sdk/offline_protocol.py
index 51fc74f35..ceb84400b 100644
--- a/bindings/python/offline_protocol_sdk/offline_protocol.py
+++ b/bindings/python/offline_protocol_sdk/offline_protocol.py
@@ -561,6 +561,8 @@ def _uniffi_check_api_checksums(lib):
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_offline_protocol_uniffi_checksum_func_run_storage_conformance() != 20699:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof() != 21016:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_offline_protocol_uniffi_checksum_func_verify_identity_assertion() != 61480:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_offline_protocol_uniffi_checksum_method_datastore_attachment_hash() != 10852:
@@ -1097,6 +1099,9 @@ def _uniffi_check_api_checksums(lib):
_UniffiLib.uniffi_offline_protocol_uniffi_checksum_func_run_storage_conformance.argtypes = (
)
_UniffiLib.uniffi_offline_protocol_uniffi_checksum_func_run_storage_conformance.restype = ctypes.c_uint16
+_UniffiLib.uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof.argtypes = (
+)
+_UniffiLib.uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof.restype = ctypes.c_uint16
_UniffiLib.uniffi_offline_protocol_uniffi_checksum_func_verify_identity_assertion.argtypes = (
)
_UniffiLib.uniffi_offline_protocol_uniffi_checksum_func_verify_identity_assertion.restype = ctypes.c_uint16
@@ -1859,6 +1864,14 @@ def _uniffi_check_api_checksums(lib):
ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.uniffi_offline_protocol_uniffi_fn_func_run_storage_conformance.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_offline_protocol_uniffi_fn_func_verify_gateway_address_proof.argtypes = (
+ _UniffiRustBuffer,
+ _UniffiRustBuffer,
+ _UniffiRustBuffer,
+ _UniffiRustBuffer,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_offline_protocol_uniffi_fn_func_verify_gateway_address_proof.restype = _UniffiRustBuffer
_UniffiLib.uniffi_offline_protocol_uniffi_fn_func_verify_identity_assertion.argtypes = (
_UniffiRustBuffer,
ctypes.POINTER(_UniffiRustCallStatus),
@@ -15069,6 +15082,29 @@ def run_storage_conformance(storage: ProtocolStateStorageProvider) -> str:
*_uniffi_lowered_args,
)
return _uniffi_lift_return(_uniffi_ffi_result)
+def verify_gateway_address_proof(address: str,public_key: typing.List[int],signature: typing.List[int],challenge: typing.List[int]) -> str:
+
+ _UniffiFfiConverterString.check_lower(address)
+
+ _UniffiFfiConverterSequenceUInt8.check_lower(public_key)
+
+ _UniffiFfiConverterSequenceUInt8.check_lower(signature)
+
+ _UniffiFfiConverterSequenceUInt8.check_lower(challenge)
+ _uniffi_lowered_args = (
+ _UniffiFfiConverterString.lower(address),
+ _UniffiFfiConverterSequenceUInt8.lower(public_key),
+ _UniffiFfiConverterSequenceUInt8.lower(signature),
+ _UniffiFfiConverterSequenceUInt8.lower(challenge),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterString.lift
+ _uniffi_error_converter = _UniffiFfiConverterTypeProtocolError
+ _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ _uniffi_error_converter,
+ _UniffiLib.uniffi_offline_protocol_uniffi_fn_func_verify_gateway_address_proof,
+ *_uniffi_lowered_args,
+ )
+ return _uniffi_lift_return(_uniffi_ffi_result)
def verify_identity_assertion(assertion: typing.List[int]) -> str:
_UniffiFfiConverterSequenceUInt8.check_lower(assertion)
@@ -15161,6 +15197,7 @@ def verify_identity_assertion(assertion: typing.List[int]) -> str:
"derive_address",
"parse_invite",
"run_storage_conformance",
+ "verify_gateway_address_proof",
"verify_identity_assertion",
"DataStore",
"DataStoreProtocol",
diff --git a/bindings/python/tests/test_gateway_address_proof.py b/bindings/python/tests/test_gateway_address_proof.py
new file mode 100644
index 000000000..1bd9c7d5c
--- /dev/null
+++ b/bindings/python/tests/test_gateway_address_proof.py
@@ -0,0 +1,106 @@
+"""Both halves of the gateway attach proof, against the real library.
+
+A device signs with ``gateway_address_declaration(challenge)`` on its engine;
+a gateway daemon, which runs no engine, checks the result with the
+instance-less ``verify_gateway_address_proof``. Neither half builds the
+payload in Python: it has one home, in the sealed crate, and this test is
+what shows the two halves agree across the FFI.
+"""
+
+from __future__ import annotations
+
+import os
+
+import pytest
+
+from offline_protocol_sdk.offline_protocol import (
+ OfflineProtocol,
+ OverflowPolicy,
+ ProtocolConfig,
+ ProtocolError,
+ verify_gateway_address_proof,
+)
+
+from conftest import InMemoryStorage
+
+
+def _config(profile: str) -> ProtocolConfig:
+ return ProtocolConfig(
+ app_label="test-app",
+ profile=profile,
+ ble_enabled=False,
+ wifi_direct_enabled=False,
+ internet_enabled=False,
+ reticulum_enabled=True,
+ nostr_enabled=False,
+ prefer_online=True,
+ initial_ttl=3,
+ encryption_enabled=True,
+ auto_key_exchange=True,
+ store_pending=True,
+ require_encryption=False,
+ max_pending_per_peer=100,
+ max_pending_global=1000,
+ pending_ttl_ms=60000,
+ overflow_policy=OverflowPolicy.DROP_OLDEST,
+ )
+
+
+def _device(profile: str) -> OfflineProtocol:
+ protocol = OfflineProtocol(_config(profile))
+ protocol.initialize_mls(InMemoryStorage(), InMemoryStorage())
+ assert protocol.local_address() is not None
+ return protocol
+
+
+def test_a_device_declaration_verifies_to_its_own_address() -> None:
+ device = _device("gateway-proof-device")
+ challenge = os.urandom(32)
+ declaration = device.gateway_address_declaration(list(challenge))
+ bound = verify_gateway_address_proof(
+ declaration.address,
+ declaration.public_key,
+ declaration.signature,
+ list(challenge),
+ )
+ assert bound == device.local_address() == declaration.address
+
+
+def test_a_declaration_does_not_verify_on_another_connection() -> None:
+ device = _device("gateway-proof-replay")
+ declaration = device.gateway_address_declaration(list(os.urandom(32)))
+ with pytest.raises(ProtocolError):
+ verify_gateway_address_proof(
+ declaration.address,
+ declaration.public_key,
+ declaration.signature,
+ list(os.urandom(32)),
+ )
+
+
+def test_a_signature_cannot_claim_another_devices_address() -> None:
+ """The check that makes the binding mean anything: a valid signature
+ under the sender's own key, naming somebody else's address."""
+ attacker = _device("gateway-proof-attacker")
+ victim = _device("gateway-proof-victim")
+ challenge = list(os.urandom(32))
+ declaration = attacker.gateway_address_declaration(challenge)
+ with pytest.raises(ProtocolError):
+ verify_gateway_address_proof(
+ victim.local_address(),
+ declaration.public_key,
+ declaration.signature,
+ challenge,
+ )
+
+
+def test_a_tampered_signature_is_refused() -> None:
+ device = _device("gateway-proof-tamper")
+ challenge = list(os.urandom(32))
+ declaration = device.gateway_address_declaration(challenge)
+ signature = list(declaration.signature)
+ signature[10] ^= 0x01
+ with pytest.raises(ProtocolError):
+ verify_gateway_address_proof(
+ declaration.address, declaration.public_key, signature, challenge
+ )
diff --git a/bindings/react-native/android/src/main/java/uniffi/offline_protocol/offline_protocol.kt b/bindings/react-native/android/src/main/java/uniffi/offline_protocol/offline_protocol.kt
index 940a83a0a..f69e6822b 100644
--- a/bindings/react-native/android/src/main/java/uniffi/offline_protocol/offline_protocol.kt
+++ b/bindings/react-native/android/src/main/java/uniffi/offline_protocol/offline_protocol.kt
@@ -871,6 +871,8 @@ internal object IntegrityCheckingUniffiLib {
): Int
external fun uniffi_offline_protocol_uniffi_checksum_func_run_storage_conformance(
): Int
+ external fun uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof(
+ ): Int
external fun uniffi_offline_protocol_uniffi_checksum_func_verify_identity_assertion(
): Int
external fun uniffi_offline_protocol_uniffi_checksum_method_datastore_attachment_hash(
@@ -1950,6 +1952,8 @@ internal object UniffiLib {
): RustBuffer.ByValue
external fun uniffi_offline_protocol_uniffi_fn_func_run_storage_conformance(`storage`: Long,uniffi_out_err: UniffiRustCallStatus,
): RustBuffer.ByValue
+ external fun uniffi_offline_protocol_uniffi_fn_func_verify_gateway_address_proof(`address`: RustBuffer.ByValue,`publicKey`: RustBuffer.ByValue,`signature`: RustBuffer.ByValue,`challenge`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
+ ): RustBuffer.ByValue
external fun uniffi_offline_protocol_uniffi_fn_func_verify_identity_assertion(`assertion`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
): RustBuffer.ByValue
external fun ffi_offline_protocol_uniffi_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus,
@@ -2080,6 +2084,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
if ((lib.uniffi_offline_protocol_uniffi_checksum_func_run_storage_conformance() and 0xFFFF) != 20699) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
+ if ((lib.uniffi_offline_protocol_uniffi_checksum_func_verify_gateway_address_proof() and 0xFFFF) != 21016) {
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ }
if ((lib.uniffi_offline_protocol_uniffi_checksum_func_verify_identity_assertion() and 0xFFFF) != 61480) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
@@ -14319,6 +14326,21 @@ public object FfiConverterMapStringString: FfiConverterRustBuffer