gear-fingerprinter 0.0.0

GEAR and MinHash based data fingerprinting
Documentation
/// A generic, 64-byte aligned type.
///
/// 64 bytes is used here, instead of 32 or 16, to allow the use of up to AVX-512 aligned
/// store/loads
#[repr(align(64))]
pub(crate) struct Aligned<T>(pub T);

/// Simple, scalar implementation of our core GEAR hash
///
/// This is a 32-bit variant
pub(crate) fn gear(x: u32, b: u8) -> u32 {
    x.overflowing_shl(1)
        .0
        .overflowing_add(GEAR_TABLE[b as usize])
        .0
}

/// Table used by the GEAR hash.
///
/// This was generated randomly
pub(crate) const GEAR_TABLE: [u32; 256] = [
    830867032, 3490364684, 3930921546, 2035375216, 2145507395, 3008307803, 465857157, 4027909869,
    895532077, 1830851551, 183030330, 2584163774, 3202680342, 3133497258, 1248941386, 2819119492,
    651159877, 1502924867, 3938422676, 2507806456, 3869356501, 3426338327, 2017811460, 11663043,
    2648243367, 141507355, 2553461686, 2511451945, 345731837, 2363056349, 203082974, 2633581320,
    2862539008, 734449058, 1904248796, 2459141272, 815706274, 1960789314, 196162470, 632022522,
    581101153, 344108910, 1440477249, 1975114953, 1088200266, 2938679342, 3117338954, 3909455026,
    1970657515, 1238258801, 1540316490, 2466347937, 2637643372, 3520803614, 2195700786, 2514381577,
    3778327671, 2093899653, 3280857082, 2684604148, 3884781618, 1984640046, 1921540402, 2895983367,
    2056378863, 2151702456, 2241704825, 1188557015, 3962133158, 2062786295, 1484127097, 2082470864,
    2492458734, 2932814683, 3689769319, 193561018, 3234795097, 4048070482, 1585002941, 2953431669,
    2149983319, 808178276, 3086967455, 204652114, 2323203975, 853340210, 4154209092, 3478875247,
    520814394, 1704619657, 865168061, 2927963365, 3598854192, 305591610, 989388413, 1682249636,
    3810016975, 3179526304, 636505071, 2436475110, 1099669984, 3802930143, 3760716720, 2672406389,
    3492015330, 3991833496, 3476592157, 809510884, 927806124, 1400780077, 383309227, 1998103756,
    1617584078, 340453122, 2294675954, 2069236016, 186411335, 80074624, 709051803, 1379113190,
    2578009436, 2281083045, 645161295, 3761787880, 2333618818, 1527255658, 3352876832, 1216025092,
    3990618922, 3617797506, 1674782464, 3705123241, 1130497148, 849636905, 1278557776, 2070975999,
    85584512, 1607746039, 1691341035, 1008727075, 3586104023, 1421855384, 3016031983, 828856826,
    3239098701, 2116451147, 1862569899, 1626745290, 1249834795, 2822178152, 895971568, 1596313258,
    3823348272, 1920653252, 4227017754, 3970942129, 4099592146, 4058494280, 2558210880, 2085429808,
    2288311637, 2309717825, 4096423190, 3897455388, 2586830217, 3693997979, 3945805563, 1848132247,
    2660700333, 3294806175, 1468976432, 2626901680, 552627970, 1429370980, 2735315558, 4029304787,
    2430345887, 350969753, 1064649494, 2658831880, 3657043285, 3188266233, 2655443302, 527417128,
    3030585449, 1059018570, 735010574, 1164394364, 2051087744, 2491819829, 247156371, 992066526,
    1966268922, 3798619326, 3066489937, 1008643104, 2083366982, 591040740, 903424515, 237007378,
    2399923713, 1806400939, 2020925765, 2449493601, 989908624, 1805144826, 3109050670, 3055942459,
    3693945546, 3719645019, 349798288, 1332712541, 3245203543, 115031465, 932253340, 2934160925,
    1275291942, 1245160915, 1000191050, 4224814841, 3313678390, 1978407612, 2461289534, 2538550071,
    3066068609, 2974539159, 339265748, 1632258416, 2642860371, 3330481689, 1704401452, 3616199796,
    3990471536, 2523733233, 3120654655, 2124447005, 410157808, 3647254426, 1159271689, 1389559229,
    4118690348, 3868149109, 2540012309, 3074188513, 846226176, 2238900312, 738406227, 2630598756,
    3346106831, 2742512829, 1543607148, 2635732063, 2872169800, 4114619134, 962585424, 2997170188,
];

/// Table used for the M value in the (hash * N) + M equation for deriving multiple hashes from our
/// core GEAR hash
///
/// This was generated randomly
pub(crate) const M_TABLE: Aligned<[u32; 24]> = Aligned([
    3263695788, 4284976248, 1074641099, 1680067053, 715650790, 2810839376, 1211641968, 594100721,
    360572195, 2358187858, 2846127177, 3941664028, 527827354, 2324179424, 803633734, 1265198905,
    2954418304, 3276225452, 2211648214, 3945001076, 3812369139, 2541122146, 3296605361, 306197888,
]);

/// Table used for the N value in the (hash * N) + M equation for deriving multiple hashes from our
/// core GEAR hash
///
/// This was generated randomly
pub(crate) const N_TABLE: Aligned<[u32; 32]> = Aligned([
    1421816930, 3813494594, 2553632728, 2749350028, 2802861788, 2888076237, 3429566536, 2061663240,
    46339790, 2964738579, 2513029960, 2127363525, 3585068206, 2720079865, 3101658675, 4220094497,
    4056716319, 2998722176, 1253403421, 3383351200, 1745562594, 3089716894, 1799253698, 3838586637,
    646841162, 3106901399, 2128962702, 1501297569, 243897038, 2336718416, 921245287, 448402000,
]);