spooky

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func End

func End(data []uint64, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11 uint64) (uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64)

func EndPartial

func EndPartial(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11 uint64) (uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64)

func Hash128

func Hash128(in []byte, seed uint64) (uint64, uint64)

Hash128: hash a single message in one call, return 64-bit output

func Hash32

func Hash32(in []byte, seed uint32) uint32

Hash32: hash a single message in one call, produce 32-bit output

func Hash64

func Hash64(in []byte, seed uint64) uint64

Hash64: hash a single message in one call, return 64-bit output

func Mix

func Mix(data []uint64, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 uint64) (uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64)

This is used if the input is 96 bytes long or longer.

The internal state is fully overwritten every 96 bytes. Every input bit appears to cause at least 128 bits of entropy before 96 other bytes are combined, when run forward or backward

For every input bit,
Two inputs differing in just that input bit
Where "differ" means xor or subtraction
And the base value is random
When run forward or backwards one Mix

I tried 3 pairs of each; they all differed by at least 212 bits.

func Rot64

func Rot64(x, k uint64) uint64

func ShortEnd

func ShortEnd(h0, h1, h2, h3 uint64) (uint64, uint64, uint64, uint64)

Mix all 4 inputs together so that h0, h1 are a hash of them all.

For two inputs differing in just the input bits Where "differ" means xor or subtraction And the base value is random, or a counting value starting at that bit The final result will have each bit of h0, h1 flip For every input bit, with probability 50 +- .3% (it is probably better than that) For every pair of input bits, with probability 50 +- .75% (the worst case is approximately that)

func ShortMix

func ShortMix(h0, h1, h2, h3 uint64) (uint64, uint64, uint64, uint64)

The goal is for each bit of the input to expand into 128 bits of

apparent entropy before it is fully overwritten.

n trials both set and cleared at least m bits of h0 h1 h2 h3

n: 2   m: 29
n: 3   m: 46
n: 4   m: 57
n: 5   m: 107
n: 6   m: 146
n: 7   m: 152

when run forwards or backwards for all 1-bit and 2-bit diffs with diffs defined by either xor or subtraction with a base of all zeros plus a counter, or plus another bit, or random

func SpookyHash128

func SpookyHash128(in []byte, hash1, hash2 uint64) (uint64, uint64)

do the whole hash in one call

func SpookyHashShort

func SpookyHashShort(in []byte, hash1, hash2 uint64) (uint64, uint64)

short hash ... it could be used on any message, but it's used by Spooky just for short messages.

func U8tou32le

func U8tou32le(p []byte) uint64

func U8tou64le

func U8tou64le(p []byte) uint64

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL