ihash 0.1.2

World's fastest high-quality non-cryptographic hash, deterministic cross-platform XOF, and seekable stream cipher
Documentation
use crate::state::State;

// GF((2^4)^2) vperm AES S-box 16-byte tables (index 0 mapped to 0xC0 sentinel in log tables).
pub(super) const IPT_LO_LI: State = [
  0x00, 0x01, 0x20, 0x21, 0x46, 0x47, 0x66, 0x67, 0x4C, 0x4D, 0x6C, 0x6D, 0x0A, 0x0B, 0x2A, 0x2B,
];
pub(super) const IPT_HI_LI: State = [
  0x00, 0x3C, 0xD5, 0xE9, 0x34, 0x08, 0xE1, 0xDD, 0xE5, 0xD9, 0x30, 0x0C, 0xD1, 0xED, 0x04, 0x38,
];
pub(super) const LOG16_LI: State = [
  0xC0, 0x00, 0x01, 0x04, 0x02, 0x08, 0x05, 0x0A, 0x03, 0x0E, 0x09, 0x07, 0x06, 0x0D, 0x0B, 0x0C,
];
pub(super) const EXP16_LI: State = [
  0x01, 0x02, 0x04, 0x08, 0x03, 0x06, 0x0C, 0x0B, 0x05, 0x0A, 0x07, 0x0E, 0x0F, 0x0D, 0x09, 0x01,
];
pub(super) const LOG_INV16_LI: State = [
  0xC0, 0x00, 0x0E, 0x0B, 0x0D, 0x07, 0x0A, 0x05, 0x0C, 0x01, 0x06, 0x08, 0x09, 0x02, 0x04, 0x03,
];
pub(super) const SQ_NU16_LI: State = [
  0x00, 0x08, 0x06, 0x0E, 0x0B, 0x03, 0x0D, 0x05, 0x0A, 0x02, 0x0C, 0x04, 0x01, 0x09, 0x07, 0x0F,
];
pub(super) const SBO_LO_LI: State = [
  0x63, 0x7C, 0xD1, 0xCE, 0xC8, 0xD7, 0x7A, 0x65, 0x55, 0x4A, 0xE7, 0xF8, 0xFE, 0xE1, 0x4C, 0x53,
];
pub(super) const SBO_HI_LI: State = [
  0x00, 0x52, 0x3E, 0x6C, 0x65, 0x37, 0x5B, 0x09, 0x60, 0x32, 0x5E, 0x0C, 0x05, 0x57, 0x3B, 0x69,
];

pub(super) const SR_PERM_LI: State = [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11];
pub(super) const SR_ROT8_PERM_LI: State = [5, 10, 15, 0, 9, 14, 3, 4, 13, 2, 7, 8, 1, 6, 11, 12];

// Prove bit-7 zeroing holds for `(s & 0x8F) + (s >> 4)` without an extra zero-select step.
const _: () = {
  let mut a = 0usize;
  while a < 16 {
    let mut b = 0usize;
    while b < 16 {
      let s = LOG16_LI[a].wrapping_add(LOG16_LI[b]);
      let idx = (s & 0x8F).wrapping_add(s >> 4);
      if a == 0 || b == 0 {
        assert!(idx >= 0x80);
      } else {
        assert!(idx < 16);
      }
      b += 1;
    }
    a += 1;
  }
};