Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

KangarooVariant

Generic KangarooTwelve variant builder. Creates a variant type with specific cryptographic parameters.

kangarootwelve.KangarooVariant
fn KangarooVariant(
    comptime security_level_bits: comptime_int,
    comptime rate_bytes: usize,
    comptime cv_size_bytes: usize,
    comptime StateTypeParam: type,
    comptime sep_x: usize,
    comptime sep_y: usize,
    comptime pad_x: usize,
    comptime pad_y: usize,
    comptime toBufferFn: fn (*const MultiSliceView, u8, []u8) void,
    comptime allocFn: fn (Allocator, *const MultiSliceView, u8, usize) anyerror![]u8,
) type

File

lib/std/crypto/kangarootwelve.zig:43

Code

fn KangarooVariant(
    comptime security_level_bits: comptime_int,
    comptime rate_bytes: usize,
    comptime cv_size_bytes: usize,
    comptime StateTypeParam: type,
    comptime sep_x: usize,
    comptime sep_y: usize,
    comptime pad_x: usize,
    comptime pad_y: usize,
    comptime toBufferFn: fn (*const MultiSliceView, u8, []u8) void,
    comptime allocFn: fn (Allocator, *const MultiSliceView, u8, usize) anyerror![]u8,
) type {
    return struct {
        const security_level = security_level_bits;
        const rate = rate_bytes;
        const rate_in_lanes = rate_bytes / 8;
        const cv_size = cv_size_bytes;
        const StateType = StateTypeParam;
        const separation_byte_pos = .{ .x = sep_x, .y = sep_y };
        const padding_pos = .{ .x = pad_x, .y = pad_y };

        inline fn turboShakeToBuffer(view: *const MultiSliceView, separation_byte: u8, output: []u8) void {
            toBufferFn(view, separation_byte, output);
        }

        inline fn turboShakeMultiSliceAlloc(
            allocator: Allocator,
            view: *const MultiSliceView,
            separation_byte: u8,
            output_len: usize,
        ) ![]u8 {
            return allocFn(allocator, view, separation_byte, output_len);
        }
    };
}