Skip to documentation
SLOP

tiny.reticulum.packet.proof

Reference tiny.reticulum packet proof

Defined in packet.

API (5)

Actions

Public operations.

Types and contracts

Public types and contracts.

Values and defaults

Public values and defaults.

No direct callersNo direct callspacketproof
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsprivate sourcelib.reticulum.src.node.inboundproofFrametest sourcelib.reticulum.src.packet.proof.test_Reticulum...py:943-953 builds both proof lengthstest sourcelib.reticulum.src.packet.proof.test_Reticulum...py:485-520 validates built proof payl...wire.proofencodepacket.proofbuild
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallspacket.proofmakePackettest sourcelib.reticulum.src.packet.proof.test_Reticulum...py:381-384 proof destination is the h...wire.proofdestinationHashpacket.proofdestinationHash
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.reticulum.src.node.inboundproofFrametest sourcelib.reticulum.src.packet.proof.test_Reticulum...py:381-384 proof destination is the h...packet.proofdestinationHashpacket.proofmakePacket
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/reticulum/src/packet/proof.zig

zig
const std = @import("std");const reticulum = @import("../root.zig");const identity = reticulum.identity;const wire = reticulum.wire;pub const BuildError = wire.proof.EncodeError;/// True, so a proof carries the signature alone unless the caller asks for the/// longer form, following Reticulum@1.5.0 RNS/Reticulum.py:262.pub const default_implicit = true;/// Signs the proved packet's hash with the answering identity's private key and/// writes the proof payload into `out`, following Reticulum@1.5.0/// RNS/Identity.py:943-953. An explicit proof carries that hash ahead of the/// signature, and an implicit one carries the signature alone. The call returns/// `error.OutputTooSmall` when `out` is shorter than the payload.pub fn build(    packet_hash: [32]u8,    private: *const identity.Private,    implicit: bool,    out: []u8,) BuildError![]u8 {    const signature = private.sign(&packet_hash);    const value: wire.proof.Proof = if (implicit)        .{ .implicit = .{ .signature = signature } }    else        .{ .explicit = .{ .packet_hash = packet_hash, .signature = signature } };    return wire.proof.encode(value, out);}/// Returns the first 16 bytes of a proved packet's hash, the address a proof/// packet carries, following Reticulum@1.5.0 RNS/Packet.py:381-384.pub fn destinationHash(packet_hash: [32]u8) [16]u8 {    return wire.proof.destinationHash(packet_hash);}/// Builds the unencrypted HEADER_1 packet that carries a proof, addressed to/// the first 16 bytes of the proved packet's hash and starting at zero hops,/// following Reticulum@1.5.0 RNS/Packet.py:178-242.pub fn makePacket(packet_hash: [32]u8, payload: []const u8) wire.Packet {    return .{        .ifac = 0,        .header = .one,        .context_flag = 0,        .transport = .broadcast,        .destination_type = .single,        .packet_type = .proof,        .hops = 0,        .transport_id = null,        .destination = destinationHash(packet_hash),        .context = .none,        .payload = payload,    };}test "Reticulum@1.5.0 RNS/Identity.py:943-953 builds both proof lengths" {    var key_bytes: identity.KeyBytes = undefined;    for (&key_bytes, 0..) |*byte, index| byte.* = @intCast(index + 1);    var private = identity.Private.fromBytes(key_bytes);    defer private.zero();    const packet_hash: [32]u8 = @splat(0xa5);    var out: [wire.proof.explicit_bytes]u8 = undefined;    const implicit = try build(packet_hash, &private, true, &out);    try std.testing.expectEqual(@as(usize, wire.proof.implicit_bytes), implicit.len);    try std.testing.expect((try wire.proof.decode(implicit)) == .implicit);    const explicit = try build(packet_hash, &private, false, &out);    try std.testing.expectEqual(@as(usize, wire.proof.explicit_bytes), explicit.len);    try std.testing.expect((try wire.proof.decode(explicit)) == .explicit);}test "Reticulum@1.5.0 RNS/Packet.py:485-520 validates built proof payloads" {    var key_bytes: identity.KeyBytes = undefined;    for (&key_bytes, 0..) |*byte, index| byte.* = @intCast(index + 1);    var private = identity.Private.fromBytes(key_bytes);    defer private.zero();    var public = private.public();    defer public.zero();    const packet_hash: [32]u8 = @splat(0x5a);    var out: [wire.proof.explicit_bytes]u8 = undefined;    var implicit_receipt = reticulum.packet.receipt.Receipt{        .hash = packet_hash,        .truncated = packet_hash[0..16].*,        .destination = @splat(1),        .sent_at = 1,        .timeout = 12,    };    const implicit = try build(packet_hash, &private, default_implicit, &out);    try std.testing.expect(implicit_receipt.validateProof(        try wire.proof.decode(implicit),        &public,        2,    ));    var explicit_receipt = implicit_receipt;    explicit_receipt.status = .sent;    const explicit = try build(packet_hash, &private, false, &out);    try std.testing.expect(explicit_receipt.validateProof(        try wire.proof.decode(explicit),        &public,        3,    ));}test "Reticulum@1.5.0 RNS/Packet.py:381-384 proof destination is the hash prefix" {    var packet_hash: [32]u8 = undefined;    for (&packet_hash, 0..) |*byte, index| byte.* = @intCast(index);    try std.testing.expectEqualSlices(u8, packet_hash[0..16], &destinationHash(packet_hash));    const value = makePacket(packet_hash, "proof");    try std.testing.expectEqual(wire.HeaderType.one, value.header);    try std.testing.expectEqual(wire.PacketType.proof, value.packet_type);    try std.testing.expectEqual(wire.Context.none, value.context);    try std.testing.expectEqual(@as(u8, 0), value.hops);}

Source: lib/reticulum/src/packet/root.zig:49

zig
pub const proof = @import("proof.zig");

Audit

Definitions6
Public names6
Members0
Version26.7.0
Revisiondaab053ee433