1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
//! ## HighwayHash
//!
//! We have devised a new way of mixing inputs with SIMD multiply and permute
//! instructions. The multiplications are 32x32 -> 64 bits and therefore infeasible
//! to reverse. Permuting equalizes the distribution of the resulting bytes.
//!
//! The internal state is quite large (1024 bits) but fits within SIMD registers.
//! Due to limitations of the AVX2 instruction set, the registers are partitioned
//! into two 512-bit halves that remain independent until the reduce phase. The
//! algorithm outputs 64 bit digests or up to 256 bits at no extra cost.
//!
//! In addition to high throughput, the algorithm is designed for low finalization
//! cost. The result is more than twice as fast as SipTreeHash.
//!
//! We also provide an SSE4.1 version (80% as fast for large inputs and 95% as fast
//! for short inputs), an implementation for VSX on POWER and a portable version
//! (10% as fast). A third-party ARM implementation is referenced below.
//!
//! Statistical analyses and preliminary cryptanalysis are given in
//! https://arxiv.org/abs/1612.06257.
use crateFastHash;
/// 256-bit secret key that should remain unknown to attackers.
/// We recommend initializing it to a random value.
pub type Seed = HHKey;
/// `HighwayHash` 64-bit hash functions for a byte array.
///
/// # Example
///
/// ```
/// use std::hash::Hasher;
/// use std::io::Cursor;
///
/// use fasthash::{highway, FastHash};
///
/// assert_eq!(highway::hash64("hello world"), 10265319535608467649);
/// ```
/// `HighwayHash` 64-bit hash function for a byte array.
///
/// For convenience, a 256-bit seed is also hashed into the result.
///
/// # Example
///
/// ```
/// use std::hash::Hasher;
/// use std::io::Cursor;
///
/// use fasthash::{highway, FastHash};
///
/// assert_eq!(highway::hash64_with_seed("hello world", [1, 2, 3, 4]), 6273970844710122614);
/// ```
/// `HighwayHash` 128-bit hash functions for a byte array.
///
/// # Example
///
/// ```
/// use std::hash::Hasher;
/// use std::io::Cursor;
///
/// use fasthash::{highway, FastHash};
///
/// assert_eq!(highway::hash128("hello world"), 184704813598772831779357069533224393217);
/// ```
/// `HighwayHash` 128-bit hash function for a byte array.
///
/// For convenience, a 256-bit seed is also hashed into the result.
///
/// # Example
///
/// ```
/// use std::hash::Hasher;
/// use std::io::Cursor;
///
/// use fasthash::{highway, FastHash};
///
/// assert_eq!(highway::hash128_with_seed("hello world", [1, 2, 3, 4]), 70726204502586093039340094508598794871);
/// ```
/// An implementation of `std::hash::Hasher`.
///
/// # Example
///
/// ```
/// use std::hash::Hasher;
/// use std::io::Cursor;
///
/// use fasthash::{highway, FastHash};
///
/// assert_eq!(highway::Hash64::hash_with_seed("hello world", [1, 2, 3, 4]), 6273970844710122614);
/// ```
;
trivial_hasher!
/// An implementation of `std::hash::Hasher`.
///
/// # Example
///
/// ```
/// use std::hash::Hasher;
/// use std::io::Cursor;
///
/// use fasthash::{highway, FastHash};
///
/// assert_eq!(highway::Hash128::hash_with_seed("hello world", [1, 2, 3, 4]), 70726204502586093039340094508598794871);
/// ```
;
trivial_hasher!