Skip to documentation
SLOP

tiny.reticulum.hash

Reference tiny.reticulum hash

Defined in tiny.reticulum.

API (12)

Actions

Public operations.

Types and contracts

Public types and contracts.

Values and defaults

Public values and defaults.

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

Source

Called byCallsNo direct callshash.HasherfinalNamehash.HasherfinalTruncatedhashfullhash.HasherfinalFull
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallshashnamehash.HasherfinalFullhash.HasherfinalName
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallshashtruncatedhash.HasherfinalFullhash.HasherfinalTruncated
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callshashfullhashnamehashtruncatedhash.Hasherinit
Static calls · unresolved targets: 1 · external targets: 0.
Called byCallsNo direct callshashfullhashnamehashtruncatedhash.Hasherupdate
Static calls · unresolved targets: 1 · external targets: 0.
Called byCallsNo direct callershash.HasherfinalFullhash.Hasherinithash.Hasherupdatehashfull
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callershash.HasherfinalNamehash.Hasherinithash.Hasherupdatehashname
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callershash.HasherfinalTruncatedhash.Hasherinithash.Hasherupdatehashtruncated
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/reticulum/src/hash.zig

zig
const std = @import("std");const Sha256 = std.crypto.hash.sha2.Sha256;/// 32 bytes, the width of a complete SHA-256 digest, following Reticulum@1.5.0/// RNS/Identity.py:352.pub const full_bytes: usize = 32;/// 16 bytes, the width a destination hash and an identity hash take on the/// wire, following Reticulum@1.5.0 RNS/Identity.py:362 and Reticulum@1.5.0/// RNS/Reticulum.py:148.pub const truncated_bytes: usize = 16;/// 10 bytes, the width a destination's announced name hash and a rotating key's/// identifier take, following Reticulum@1.5.0 RNS/Identity.py:83.pub const name_bytes: usize = 10;/// Returns the complete 32-byte SHA-256 digest of some bytes, following/// Reticulum@1.5.0 RNS/Identity.py:352.pub fn full(bytes: []const u8) [full_bytes]u8 {    var hasher = Hasher.init();    hasher.update(bytes);    return hasher.finalFull();}/// Returns the first 16 bytes of the SHA-256 digest of some bytes, following/// Reticulum@1.5.0 RNS/Identity.py:362 and Reticulum@1.5.0/// RNS/Reticulum.py:148.pub fn truncated(bytes: []const u8) [truncated_bytes]u8 {    var hasher = Hasher.init();    hasher.update(bytes);    return hasher.finalTruncated();}/// Returns the first 10 bytes of the SHA-256 digest of some bytes, following/// Reticulum@1.5.0 RNS/Identity.py:83 and Reticulum@1.5.0/// RNS/Destination.py:120.pub fn name(bytes: []const u8) [name_bytes]u8 {    var hasher = Hasher.init();    hasher.update(bytes);    return hasher.finalName();}/// A SHA-256 state that takes its input in pieces and then gives any of the/// three widths. Reticulum hashes joined transcripts, so a caller feeds the/// pieces in turn and needs no buffer holding them all at once. Taking a digest/// works on a copy of the state, so one hasher gives more than one width.pub const Hasher = struct {    state: Sha256,    pub fn init() Hasher {        return .{ .state = Sha256.init(.{}) };    }    pub fn update(self: *Hasher, bytes: []const u8) void {        self.state.update(bytes);    }    pub fn finalFull(self: Hasher) [full_bytes]u8 {        var state = self.state;        var result: [full_bytes]u8 = undefined;        state.final(&result);        return result;    }    pub fn finalTruncated(self: Hasher) [truncated_bytes]u8 {        const result = self.finalFull();        return result[0..truncated_bytes].*;    }    pub fn finalName(self: Hasher) [name_bytes]u8 {        const result = self.finalFull();        return result[0..name_bytes].*;    }};

Source: lib/reticulum/src/root.zig:62

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

Audit

Definitions13
Public names13
Members1
Version26.7.0
Revisiondaab053ee433