r30sponge.h Documentation

API Reference

r30s_new

Signature: void *r30s_new(size_t bits, size_t steps)
Param (bits): The size of the internal state in bits.
Param (steps): The number of Rule 30 steps per bit.
Returns: Pointer to sponge.

This function allocates and initializes a sponge.

r30s_new_default

Signature: void *r30s_new_default()
Returns: Pointer to sponge

r30s_absorb_bit

Signature: void r30s_absorb_bit(void *sp, uint8_t bit)
Param (sp): Sponge pointer
Param (bit): The bit to absorb
Returns: Nothing

r30s_absorb_byte

Signature: void r30s_absorb_bit(void *sp, uint8_t byte)
Param (sp): Sponge pointer
Param (byte): The byte to absorb
Returns: Nothing

r30s_absorb

r30s_absorb_cstr

r30s_squeeze_bit

r30s_squeeze_byte

r30s_squeeze_buf

Examples

Below are some examples.

Simple hash

size_t hash_cstr(const char *str) {
    size_t hash;
    void *sp = r30s_new_default();
    r30s_absorb_cstr(sp, str);
    r30s_squeeze_buf(sp, &hash, sizeof(hash));
    return hash;
}

Using a custom allocator

If you do not want the library to perform dynamic memory allocations, you can define R30S_NOMALLOC. This will remove the r30s_new and r30s_new_default functions. Aside from these constructors, there is no memory allocation anywhere else in the library.


Gokberk Yaltirakli - https://www.gkbrk.com/