summary refs log tree commit diff
path: root/ripple/fossil/src/chunker/mod.rs
blob: 0045646eaa2155e37321c43a35ab035e290dee4b (plain)
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
// SPDX-FileCopyrightText: edef <edef@unfathomable.blue>
// SPDX-License-Identifier: OSL-3.0

use std::mem;

mod buz;

pub const MIN_CHUNK_SIZE: usize = AVG_CHUNK_SIZE / 4;
pub const AVG_CHUNK_SIZE: usize = 64 * 1024;
pub const MAX_CHUNK_SIZE: usize = AVG_CHUNK_SIZE * 4;

fn discriminator_from_average(avg: u64) -> u32 {
	let avg = avg as f64;
	(avg / (-1.42888852e-7 * avg + 1.33237515)) as u32
}

#[derive(Clone)]
pub struct Chunker<'a> {
	buffer: &'a [u8],
}

impl<'a> Chunker<'a> {
	pub fn from(buffer: &'a [u8]) -> Chunker<'a> {
		Chunker { buffer }
	}
}

impl<'a> Iterator for Chunker<'a> {
	type Item = &'a [u8];
	fn next(&mut self) -> Option<&'a [u8]> {
		if self.buffer.is_empty() {
			return None;
		}

		if self.buffer.len() <= MIN_CHUNK_SIZE {
			return Some(mem::take(&mut self.buffer));
		}

		let bytes = self
			.buffer
			.iter()
			.cloned()
			.enumerate()
			.take(MAX_CHUNK_SIZE)
			.skip(MIN_CHUNK_SIZE);

		let d = discriminator_from_average(AVG_CHUNK_SIZE as u64);
		let mut hasher = buz::Rolling::<48>::from_slice(&self.buffer[..MIN_CHUNK_SIZE]);
		let chunk;
		for (idx, byte) in bytes {
			hasher.push(byte);
			let buz::Hash(x) = hasher.sum();
			if x % d == d.wrapping_sub(1) {
				// split point
				(chunk, self.buffer) = self.buffer.split_at(idx + 1);
				return Some(chunk);
			}
		}

		(chunk, self.buffer) = self.buffer.split_at(MAX_CHUNK_SIZE.min(self.buffer.len()));
		Some(chunk)
	}

	fn size_hint(&self) -> (usize, Option<usize>) {
		if self.buffer.is_empty() {
			return (0, Some(0));
		}
		let min = (self.buffer.len() + MAX_CHUNK_SIZE - 1) / MAX_CHUNK_SIZE;
		let max = (self.buffer.len() + MIN_CHUNK_SIZE - 1) / MIN_CHUNK_SIZE;
		(min, Some(max))
	}
}

#[cfg(test)]
mod test {
	use std::io::Read;

	fn generate(length: usize) -> Vec<u8> {
		let mut h = blake3::Hasher::new();
		h.update(b"test vector");
		let mut buf = vec![0; length];
		h.finalize_xof().read_exact(&mut buf).unwrap();
		buf
	}

	const GOLDEN: &[[u8; 32]] = &[
		[
			0x66, 0x77, 0xd1, 0xf7, 0x78, 0xbf, 0x7b, 0x42, 0x91, 0x15, 0x16, 0xda, 0xde, 0xae,
			0x69, 0x17, 0x59, 0xe9, 0x73, 0xe8, 0x5b, 0xa2, 0xa0, 0x92, 0x6f, 0x98, 0x76, 0x8c,
			0xbb, 0xb4, 0x74, 0xc7,
		],
		[
			0xad, 0xd6, 0xc0, 0x6e, 0x0e, 0xef, 0xb5, 0x3b, 0x1f, 0x8b, 0xeb, 0xac, 0x21, 0xa8,
			0xf7, 0x0c, 0xc9, 0xeb, 0xc8, 0x20, 0x22, 0xf0, 0xfe, 0x0a, 0x72, 0x15, 0x15, 0x21,
			0x32, 0x7d, 0xe5, 0x0a,
		],
		[
			0xbc, 0xd0, 0x68, 0x57, 0x0a, 0x66, 0x70, 0xf3, 0x3e, 0x81, 0xc9, 0xa8, 0x7d, 0xac,
			0xd9, 0xde, 0x80, 0xb9, 0x8a, 0x19, 0x8d, 0x54, 0xcd, 0xd7, 0x5e, 0x76, 0xca, 0x0f,
			0xb0, 0x0d, 0x53, 0x11,
		],
		[
			0x91, 0x16, 0x6f, 0x72, 0x92, 0x3d, 0x00, 0xbb, 0x46, 0x82, 0x7a, 0xc5, 0x35, 0xda,
			0x0c, 0x6e, 0x20, 0xbc, 0x1a, 0xb0, 0xb8, 0x40, 0x58, 0x0b, 0xf4, 0xc4, 0xe3, 0xbe,
			0xb7, 0x81, 0xeb, 0xd8,
		],
		[
			0x51, 0x59, 0xea, 0xdf, 0xd1, 0x41, 0x38, 0x11, 0xa9, 0x91, 0xb3, 0xf4, 0x91, 0x8c,
			0x7b, 0x61, 0x38, 0x4a, 0x04, 0x59, 0x1f, 0xe9, 0xc1, 0xa6, 0x01, 0x19, 0x32, 0x5b,
			0xfa, 0x3b, 0x24, 0x92,
		],
		[
			0x7c, 0x64, 0x0c, 0xa5, 0xe8, 0x3a, 0x25, 0xeb, 0xaf, 0xe3, 0x1e, 0x5b, 0x58, 0xd4,
			0x8b, 0xb8, 0x0a, 0xa5, 0x50, 0x5d, 0x18, 0x8a, 0x79, 0x38, 0xe3, 0x71, 0x61, 0x6d,
			0x24, 0x4b, 0x0d, 0x07,
		],
		[
			0x6c, 0x4b, 0xc6, 0x17, 0xf2, 0xaf, 0x9b, 0xa6, 0x81, 0xd4, 0x1b, 0xf1, 0x77, 0xce,
			0xcf, 0x0b, 0xb7, 0xbf, 0x3a, 0x54, 0xc7, 0x26, 0x5f, 0x8c, 0x43, 0x5a, 0x40, 0x61,
			0xf5, 0x5c, 0x47, 0x75,
		],
		[
			0x98, 0x74, 0xd1, 0x45, 0x30, 0xe9, 0x47, 0x0c, 0xcf, 0x76, 0x52, 0x65, 0x85, 0x96,
			0xf6, 0x90, 0x6f, 0x1d, 0x84, 0x24, 0xe1, 0x4f, 0x08, 0x55, 0x03, 0xf8, 0xe8, 0x8f,
			0x10, 0xb4, 0xec, 0xc8,
		],
		[
			0xd2, 0x87, 0x27, 0x3d, 0xa5, 0x7d, 0x31, 0x75, 0x56, 0x82, 0xb7, 0x13, 0x4c, 0xea,
			0x68, 0xbf, 0xc4, 0x1c, 0x0b, 0xb9, 0xce, 0x64, 0xb1, 0x90, 0xfb, 0xde, 0x2a, 0xd8,
			0xce, 0xc0, 0x1b, 0x2c,
		],
		[
			0x68, 0xbd, 0xfb, 0x6c, 0x99, 0xf5, 0x3e, 0x82, 0xf6, 0x9e, 0x6a, 0xa6, 0x01, 0x56,
			0x00, 0x3f, 0xab, 0x8e, 0x9c, 0xf7, 0x98, 0x93, 0x1a, 0x70, 0xef, 0x2b, 0x19, 0x5b,
			0x1c, 0xf0, 0x1e, 0x38,
		],
		[
			0xae, 0x9f, 0xa2, 0x52, 0x89, 0x7b, 0xda, 0xcf, 0x65, 0x09, 0x93, 0xd1, 0xe0, 0x96,
			0x73, 0xb6, 0xfb, 0xa6, 0x0f, 0x58, 0x02, 0xec, 0x79, 0x22, 0xf8, 0xa7, 0xea, 0xe8,
			0x16, 0x60, 0x6d, 0x1b,
		],
		[
			0x8b, 0x9e, 0x83, 0xc2, 0x45, 0x75, 0x9c, 0x3a, 0xf4, 0x0f, 0x4b, 0xb4, 0xbd, 0x82,
			0xa1, 0x62, 0x66, 0xde, 0xd3, 0x2f, 0xda, 0xf6, 0xfc, 0x12, 0xc9, 0x57, 0x40, 0xe2,
			0x18, 0x90, 0x89, 0x67,
		],
		[
			0x6b, 0x0d, 0x3f, 0x9b, 0xec, 0x24, 0xb2, 0xf7, 0x90, 0x8c, 0x75, 0x28, 0x57, 0xc9,
			0x6f, 0x9e, 0xa7, 0x78, 0x94, 0x31, 0xaf, 0xa4, 0xa4, 0x61, 0x9c, 0x6e, 0xa7, 0xf9,
			0x64, 0x60, 0x48, 0xcd,
		],
		[
			0xbd, 0x04, 0x1a, 0x0c, 0x3e, 0xe2, 0x3e, 0x3a, 0xe6, 0x6c, 0x5b, 0xcd, 0x8d, 0x8a,
			0x1e, 0xfe, 0x4d, 0xd5, 0xac, 0x14, 0xd5, 0xe6, 0x59, 0x40, 0x0e, 0xa0, 0xcf, 0x75,
			0x32, 0xc6, 0xb6, 0x7a,
		],
		[
			0x66, 0x73, 0x94, 0x96, 0x23, 0x81, 0x69, 0x26, 0x34, 0x94, 0x4d, 0x20, 0xf3, 0x6d,
			0x67, 0x3d, 0xb6, 0xb9, 0x9b, 0xc7, 0xa7, 0x7c, 0x22, 0xc3, 0x56, 0xd1, 0x58, 0xe5,
			0x4e, 0x55, 0x0a, 0x33,
		],
		[
			0x26, 0xdd, 0xfc, 0x31, 0xac, 0xfc, 0xd2, 0x57, 0x9d, 0x52, 0x65, 0xdc, 0xf3, 0xe0,
			0x8a, 0xde, 0x13, 0x04, 0x5f, 0xee, 0xc4, 0xf4, 0x35, 0xce, 0xb6, 0xcf, 0xd1, 0x7f,
			0xc0, 0xc5, 0x4b, 0x7f,
		],
		[
			0xe2, 0xd5, 0x6a, 0xb7, 0xdb, 0x71, 0x1d, 0x4d, 0xb2, 0xb4, 0xdb, 0xee, 0x94, 0x4c,
			0xac, 0x92, 0x6e, 0xdc, 0xf3, 0xfd, 0x92, 0x44, 0xf1, 0x79, 0x66, 0x2a, 0x1e, 0x70,
			0xd6, 0x2e, 0xb4, 0x6b,
		],
		[
			0x86, 0x5d, 0x5f, 0x60, 0x75, 0x3d, 0xff, 0x7b, 0xac, 0x50, 0xa3, 0x11, 0x82, 0x7a,
			0xb8, 0xfe, 0xde, 0xbc, 0xb1, 0x0a, 0xfd, 0xea, 0xa8, 0x08, 0xaa, 0x28, 0xfc, 0x95,
			0x72, 0x04, 0x72, 0x13,
		],
		[
			0xa6, 0x2d, 0xcc, 0x3a, 0x2e, 0x8e, 0xe9, 0xf2, 0x87, 0xc7, 0xcc, 0xa8, 0xc8, 0xa3,
			0x18, 0x33, 0xc9, 0x43, 0x31, 0x4a, 0xab, 0xfe, 0xaf, 0xc1, 0x1d, 0xc6, 0x22, 0x3d,
			0xf3, 0x54, 0x45, 0xe2,
		],
		[
			0x75, 0x1d, 0x1f, 0x3d, 0x94, 0x8e, 0x7d, 0x27, 0x22, 0x7f, 0x1a, 0x0e, 0xcc, 0x61,
			0xef, 0xbd, 0x41, 0x16, 0x53, 0xb9, 0x5b, 0x78, 0x05, 0x06, 0x80, 0x60, 0xa3, 0x17,
			0x4f, 0x01, 0x10, 0x51,
		],
		[
			0x4e, 0x0f, 0x4d, 0x71, 0x65, 0x10, 0xa5, 0x81, 0xff, 0xfe, 0x62, 0x6b, 0x15, 0x94,
			0x17, 0x4c, 0x6d, 0x12, 0x85, 0xbe, 0x74, 0xcb, 0x56, 0x04, 0xc7, 0x38, 0x8f, 0xb7,
			0x6e, 0xaa, 0xfd, 0x12,
		],
		[
			0xe4, 0xb8, 0x64, 0x03, 0x92, 0xe5, 0x71, 0x89, 0x31, 0xfc, 0xc7, 0xe9, 0xee, 0xcd,
			0x92, 0xfb, 0x92, 0xb0, 0x1d, 0x32, 0x34, 0xa1, 0x91, 0xd4, 0x7f, 0x5b, 0x8b, 0x37,
			0xb8, 0x60, 0x2d, 0x6a,
		],
		[
			0xc6, 0x3c, 0x17, 0xc0, 0x94, 0x0d, 0x16, 0xec, 0xc6, 0x67, 0x1f, 0xd1, 0x7a, 0xec,
			0x12, 0x10, 0xf3, 0xf6, 0x1e, 0x59, 0x4b, 0x29, 0xab, 0x1c, 0xd4, 0xf6, 0xd1, 0x2e,
			0x8a, 0xd7, 0x42, 0xc1,
		],
		[
			0x8d, 0x59, 0x07, 0x06, 0x8c, 0x84, 0x68, 0x2a, 0x02, 0xb0, 0xe3, 0x2a, 0x88, 0x64,
			0x28, 0x1a, 0xbf, 0x58, 0x74, 0xb5, 0xf9, 0x75, 0x5f, 0xd8, 0xc8, 0x4d, 0xa6, 0x9b,
			0xd3, 0x40, 0x19, 0x05,
		],
		[
			0x45, 0xa7, 0xc6, 0x21, 0xb3, 0x14, 0x14, 0x95, 0x74, 0x2e, 0xa4, 0xdc, 0x1f, 0x11,
			0xe0, 0x77, 0xd5, 0xf3, 0x68, 0xe2, 0xc1, 0x9a, 0xb9, 0x83, 0xed, 0xd4, 0xf6, 0x77,
			0x83, 0x09, 0x8f, 0x54,
		],
		[
			0x94, 0x79, 0x72, 0xb1, 0x57, 0x2a, 0xb5, 0x2d, 0x81, 0x87, 0x9b, 0x32, 0xa8, 0xbf,
			0xa8, 0xb6, 0x69, 0xff, 0x82, 0x69, 0x37, 0x69, 0x56, 0x7f, 0x26, 0xa4, 0xf2, 0x6c,
			0x9a, 0xfd, 0x7e, 0x1a,
		],
		[
			0x6f, 0x7f, 0x6d, 0xf1, 0x1f, 0xbb, 0x57, 0x2b, 0x2f, 0x29, 0x9f, 0x3d, 0x4e, 0x00,
			0xd3, 0x75, 0x9b, 0xf2, 0x9f, 0x5d, 0xd4, 0xe5, 0x07, 0x9e, 0x46, 0xe0, 0x73, 0x3e,
			0x68, 0x52, 0xa4, 0x99,
		],
		[
			0xbb, 0x38, 0x7e, 0xc3, 0x7b, 0x3f, 0xe4, 0x9d, 0x05, 0xcc, 0x38, 0xa0, 0xe2, 0x3e,
			0xb0, 0x95, 0x23, 0x43, 0x92, 0x2b, 0x83, 0x77, 0x10, 0xe4, 0x33, 0x7d, 0xe9, 0x75,
			0xac, 0xdd, 0xe4, 0xcf,
		],
		[
			0x32, 0x36, 0x32, 0x5b, 0x9f, 0xa9, 0x47, 0xd3, 0xfb, 0xca, 0xc0, 0x4e, 0x3d, 0x4a,
			0xa6, 0xb8, 0x42, 0x16, 0x91, 0x43, 0xf2, 0x20, 0x04, 0x8d, 0x12, 0xb9, 0xb2, 0xa4,
			0xc8, 0x97, 0xff, 0x99,
		],
		[
			0x91, 0x11, 0xf3, 0xae, 0x36, 0x81, 0x03, 0xa5, 0x11, 0x74, 0xcd, 0x39, 0x06, 0x38,
			0x1b, 0xa6, 0x87, 0x06, 0x28, 0x8a, 0x8a, 0x12, 0xbd, 0x35, 0xf6, 0x3c, 0xfe, 0xa9,
			0x4a, 0x5b, 0x4e, 0x99,
		],
		[
			0x68, 0x58, 0x3d, 0x1b, 0x52, 0xcb, 0x10, 0x28, 0x13, 0x1c, 0x99, 0x3b, 0xba, 0x09,
			0x0b, 0x61, 0xc1, 0x51, 0x16, 0x03, 0xd9, 0x53, 0xba, 0x92, 0x6b, 0x45, 0x52, 0x8b,
			0x90, 0x3c, 0xe1, 0x64,
		],
		[
			0x5c, 0x26, 0xc4, 0xc9, 0x46, 0x08, 0x4d, 0x5d, 0xd2, 0xd7, 0x1e, 0xc7, 0xab, 0x95,
			0xe8, 0xa6, 0xc1, 0x03, 0xff, 0x1f, 0x48, 0x1f, 0x2a, 0x8f, 0xe6, 0xa7, 0x05, 0x3c,
			0xbb, 0xde, 0x9e, 0xbc,
		],
		[
			0xf2, 0x25, 0xf0, 0xee, 0xd0, 0xa8, 0x2c, 0x50, 0x1b, 0x02, 0xaf, 0xd4, 0x56, 0x7b,
			0x45, 0xea, 0x10, 0xf6, 0x8f, 0xb7, 0x2c, 0xe2, 0xe7, 0x88, 0xc6, 0x52, 0x91, 0x5d,
			0xfe, 0x18, 0x4a, 0x0e,
		],
		[
			0xb0, 0x38, 0xfe, 0x27, 0x98, 0xc4, 0x4d, 0xad, 0xfa, 0x07, 0x09, 0xa4, 0x40, 0xc8,
			0x5a, 0x85, 0x69, 0xb5, 0xbd, 0xf3, 0xac, 0xb2, 0x82, 0x2e, 0x55, 0x22, 0xb4, 0x19,
			0xf6, 0x30, 0xde, 0x82,
		],
		[
			0x5f, 0x98, 0x00, 0xfd, 0x1d, 0x88, 0xf0, 0x00, 0x39, 0x20, 0x70, 0x5c, 0x2b, 0x81,
			0xb3, 0x2d, 0x31, 0x7c, 0x1c, 0xa8, 0xcc, 0x21, 0x09, 0xb5, 0xfc, 0xd0, 0xae, 0x59,
			0xdb, 0x45, 0xbf, 0x03,
		],
		[
			0xf5, 0x92, 0xf4, 0x5f, 0xb9, 0x29, 0x1c, 0xc1, 0xee, 0xf1, 0x12, 0xf8, 0x0d, 0xc4,
			0x92, 0x3a, 0xc8, 0x45, 0x5b, 0x1e, 0x2b, 0xae, 0xfc, 0xb4, 0x35, 0x21, 0x15, 0xcf,
			0xc8, 0xc8, 0x3b, 0x19,
		],
		[
			0xc2, 0x2e, 0x11, 0x46, 0x01, 0x5f, 0x0c, 0xa2, 0x6a, 0xe1, 0x13, 0x6d, 0x30, 0xd4,
			0x86, 0xdf, 0xdd, 0xe0, 0x30, 0x8f, 0x3e, 0xaa, 0x1c, 0xd3, 0xf3, 0xda, 0x4c, 0x72,
			0xdb, 0xe3, 0xe3, 0x23,
		],
		[
			0xf9, 0x98, 0x5c, 0xcd, 0x6e, 0x19, 0xbf, 0xfa, 0xeb, 0x28, 0xf5, 0xf1, 0xab, 0xea,
			0x25, 0x8d, 0xd4, 0xa7, 0xb7, 0x11, 0x95, 0x4f, 0xed, 0x9b, 0x0d, 0xba, 0x08, 0x83,
			0xc4, 0x97, 0xad, 0x65,
		],
		[
			0x76, 0xb1, 0x15, 0x9a, 0x9a, 0x76, 0xac, 0x13, 0x7e, 0xfa, 0x0f, 0x3c, 0xaa, 0x70,
			0xb5, 0x9a, 0x60, 0x4d, 0xb9, 0x5b, 0x48, 0xd0, 0x38, 0x85, 0x1d, 0x4a, 0xcb, 0xa9,
			0xe0, 0x4d, 0x41, 0x10,
		],
		[
			0xbe, 0xf5, 0xbb, 0x3b, 0x80, 0x96, 0x52, 0x07, 0x8a, 0x39, 0xdc, 0xf4, 0xc4, 0x36,
			0x34, 0xd5, 0x2f, 0xb3, 0xf4, 0x81, 0xde, 0x92, 0x7f, 0x7b, 0xcc, 0x0c, 0xc6, 0x82,
			0x10, 0xd0, 0xdb, 0xa4,
		],
		[
			0x91, 0x8b, 0x9a, 0x12, 0x12, 0x04, 0x84, 0x7a, 0x08, 0x03, 0x88, 0x0d, 0x59, 0x0a,
			0xe1, 0x79, 0xd8, 0x21, 0x28, 0x96, 0xa4, 0x93, 0x3e, 0x66, 0xc3, 0xf0, 0x0d, 0x7f,
			0x63, 0xc7, 0xc0, 0x0b,
		],
		[
			0xa8, 0x0b, 0x46, 0xe0, 0x44, 0x86, 0xe1, 0xa4, 0xe8, 0x39, 0x61, 0x73, 0x69, 0x59,
			0xed, 0xf4, 0x63, 0xfd, 0x1a, 0x55, 0x9b, 0x12, 0xf3, 0xa1, 0xab, 0x4c, 0x89, 0x3b,
			0xb9, 0x31, 0x8b, 0xbf,
		],
		[
			0x9f, 0xc1, 0x32, 0x3f, 0xcf, 0x6b, 0x96, 0xd8, 0x26, 0xbe, 0x3e, 0x73, 0x30, 0xed,
			0x53, 0x10, 0xe7, 0x9d, 0x35, 0x72, 0x1e, 0x67, 0xe6, 0x77, 0x4f, 0x6b, 0xa8, 0xd3,
			0xdf, 0xd7, 0x13, 0x66,
		],
		[
			0x6a, 0x6b, 0x9c, 0xfa, 0xcd, 0x49, 0xb5, 0xd4, 0x17, 0x9f, 0xaa, 0xe0, 0x25, 0x9a,
			0xf4, 0xa4, 0x46, 0x39, 0x56, 0xff, 0x6f, 0xdf, 0x5f, 0x6f, 0xa5, 0xa2, 0x52, 0x98,
			0xe4, 0x1b, 0x64, 0x05,
		],
		[
			0x15, 0xd2, 0x00, 0x5b, 0x94, 0xa4, 0xa0, 0xa7, 0x93, 0xce, 0x66, 0x89, 0xc3, 0xa6,
			0xa6, 0x5e, 0x5c, 0xa1, 0x51, 0x4e, 0x3b, 0xf2, 0xbd, 0x9d, 0xc5, 0x27, 0x3c, 0x34,
			0xaa, 0xc6, 0x7b, 0xfc,
		],
		[
			0x85, 0xeb, 0xa0, 0x53, 0xce, 0xdd, 0xfc, 0x1e, 0x2d, 0x16, 0x09, 0xb0, 0x3d, 0xd1,
			0x1f, 0x3c, 0xf0, 0x71, 0x2d, 0xa2, 0xbd, 0x1e, 0xb6, 0x1a, 0x27, 0x0c, 0xe1, 0x34,
			0x42, 0x49, 0x8c, 0x41,
		],
		[
			0xd1, 0xaf, 0xae, 0x46, 0x0e, 0xb6, 0xc3, 0x7e, 0xb7, 0x83, 0x45, 0xab, 0xc5, 0x2e,
			0xc4, 0x3b, 0x16, 0x52, 0x84, 0x0f, 0xbf, 0x4f, 0x79, 0x0c, 0x2b, 0xa7, 0x98, 0xc5,
			0x4d, 0x0b, 0x17, 0xff,
		],
		[
			0x0e, 0xb6, 0x4e, 0xf4, 0x49, 0x54, 0xa9, 0x5d, 0x51, 0xf1, 0xf4, 0x5e, 0xf7, 0x56,
			0xe1, 0x84, 0x7b, 0xaa, 0x25, 0x3b, 0xa4, 0xa0, 0xe4, 0xf6, 0x5f, 0xc5, 0x55, 0x12,
			0x57, 0x1f, 0x30, 0x27,
		],
		[
			0xc6, 0x43, 0x9d, 0x8c, 0x49, 0x8c, 0x45, 0xb9, 0x05, 0x14, 0xe3, 0x07, 0xdf, 0x1f,
			0xa9, 0x9f, 0x41, 0xf2, 0xd0, 0xe1, 0xde, 0x90, 0xa8, 0x52, 0xa0, 0x55, 0x40, 0xa1,
			0x94, 0xf7, 0xad, 0xd3,
		],
		[
			0x8f, 0x8a, 0xc3, 0x9c, 0x0d, 0xbc, 0xf7, 0xd6, 0x65, 0xda, 0x26, 0x0a, 0x82, 0x6d,
			0x88, 0xe0, 0x88, 0xd8, 0xba, 0x73, 0x81, 0xce, 0x5d, 0x1e, 0xa6, 0xdd, 0x88, 0x94,
			0x56, 0x89, 0x17, 0xa6,
		],
		[
			0x97, 0xe1, 0xbf, 0xc8, 0x8f, 0x16, 0x99, 0xce, 0x00, 0x44, 0x9c, 0x5a, 0x5f, 0x69,
			0xb0, 0xfd, 0xf6, 0xc9, 0x94, 0x10, 0x73, 0x53, 0x10, 0xf2, 0xb6, 0x22, 0x2a, 0x6f,
			0x25, 0x67, 0xbe, 0xc2,
		],
		[
			0x80, 0x02, 0x68, 0x53, 0x7b, 0x24, 0xe0, 0x19, 0x7b, 0x10, 0x9c, 0x47, 0x77, 0xab,
			0x0f, 0x4c, 0x09, 0x28, 0x5d, 0xa5, 0x54, 0xd1, 0x25, 0x65, 0x97, 0x4d, 0x45, 0xd2,
			0xa0, 0x71, 0xec, 0x2d,
		],
		[
			0x55, 0xbf, 0x83, 0x5b, 0xa6, 0xba, 0xb1, 0x43, 0x1b, 0x18, 0x23, 0xd9, 0x64, 0x93,
			0x66, 0x0a, 0x92, 0x06, 0xfe, 0xa1, 0xec, 0xb5, 0xce, 0x95, 0x9f, 0x9f, 0x7d, 0xc4,
			0x92, 0x49, 0x84, 0xfd,
		],
		[
			0xdb, 0x6a, 0xcd, 0x67, 0x7a, 0x11, 0x65, 0x38, 0x56, 0x65, 0x89, 0xfd, 0x1b, 0x5f,
			0x86, 0x19, 0x1f, 0xb9, 0x38, 0x94, 0x98, 0x5d, 0x6b, 0x30, 0x82, 0xce, 0xae, 0x3e,
			0x53, 0x4c, 0xbb, 0x95,
		],
		[
			0xd1, 0x83, 0xc3, 0xd4, 0xb0, 0x65, 0xf0, 0x77, 0xad, 0x50, 0x65, 0x24, 0xec, 0x07,
			0x48, 0x1d, 0xe4, 0x9d, 0x2c, 0x6e, 0x94, 0xc9, 0x1d, 0x58, 0x43, 0x7a, 0x93, 0xaf,
			0xff, 0x6e, 0xd2, 0xbd,
		],
		[
			0x07, 0x17, 0x08, 0x3d, 0xcb, 0xb2, 0x4e, 0x38, 0x96, 0x1e, 0x68, 0x84, 0x39, 0xba,
			0x3a, 0x40, 0xc2, 0x6a, 0x72, 0xcf, 0xf8, 0x2d, 0x56, 0x18, 0x44, 0x42, 0x9d, 0xa8,
			0x08, 0x67, 0xfc, 0x10,
		],
		[
			0xed, 0x8d, 0xdb, 0xbf, 0x6e, 0x1a, 0xd0, 0x0a, 0x34, 0x61, 0xac, 0xab, 0x32, 0x3f,
			0x2a, 0x70, 0x51, 0xf7, 0x39, 0xb5, 0x63, 0xbb, 0xac, 0x83, 0xba, 0x56, 0x73, 0xc8,
			0x4a, 0x60, 0x09, 0x24,
		],
		[
			0x46, 0x63, 0x1d, 0x73, 0x51, 0xf6, 0xe2, 0x57, 0xa5, 0x6a, 0xbb, 0xb5, 0x88, 0x76,
			0x3c, 0xeb, 0x89, 0xbe, 0xc5, 0x1b, 0x95, 0x9c, 0xc5, 0x30, 0x02, 0x21, 0xad, 0x35,
			0x2f, 0xe5, 0xae, 0x51,
		],
		[
			0x69, 0xcb, 0x42, 0x2a, 0xd8, 0x9b, 0xcc, 0xcc, 0x51, 0x3b, 0x58, 0xe9, 0x21, 0x61,
			0xee, 0x81, 0xb1, 0x0d, 0x0a, 0xc4, 0xb1, 0xc7, 0xa0, 0x4f, 0x19, 0x76, 0x57, 0x5e,
			0xd8, 0x53, 0x0a, 0xee,
		],
		[
			0x9b, 0x39, 0x2e, 0x2e, 0xd5, 0x7f, 0x0f, 0x82, 0x04, 0xbb, 0x7c, 0xf6, 0x88, 0x39,
			0xd9, 0xd1, 0x91, 0xc8, 0x06, 0x71, 0x36, 0x1d, 0x96, 0xc2, 0x9d, 0xdf, 0xc2, 0x6c,
			0x18, 0xe1, 0x1b, 0x79,
		],
		[
			0xe7, 0xe0, 0x6b, 0xfa, 0x7c, 0xcd, 0x85, 0x9e, 0x10, 0xb8, 0xac, 0x33, 0xae, 0x61,
			0x5a, 0x29, 0x98, 0x2a, 0x65, 0xc1, 0x31, 0x33, 0xe2, 0x7e, 0xd2, 0x97, 0x5e, 0x9a,
			0x67, 0xe2, 0x16, 0x52,
		],
		[
			0x5b, 0x01, 0x92, 0x69, 0x45, 0xf7, 0xd6, 0x35, 0xf7, 0xca, 0x28, 0xa6, 0xd7, 0x1c,
			0xd8, 0x8d, 0xac, 0x15, 0x6e, 0x00, 0xeb, 0xaa, 0xe4, 0x9c, 0x2f, 0xe5, 0x03, 0x95,
			0x79, 0xf1, 0x55, 0xf1,
		],
		[
			0x9d, 0x8f, 0x23, 0x51, 0xb6, 0xae, 0x39, 0xe9, 0xae, 0x13, 0x5c, 0xcb, 0x86, 0xb5,
			0xdd, 0xc7, 0x77, 0xa8, 0x92, 0x23, 0x59, 0xb8, 0x1d, 0xea, 0x58, 0x64, 0x34, 0x0c,
			0x13, 0xbe, 0x95, 0xba,
		],
		[
			0xf2, 0x2f, 0x2d, 0x26, 0xa5, 0x78, 0xbe, 0x8d, 0xd2, 0xb1, 0xf9, 0xf4, 0x19, 0x01,
			0x29, 0xd6, 0x87, 0xc6, 0xcf, 0x57, 0x46, 0xb1, 0x3c, 0x63, 0x15, 0x1c, 0x65, 0xee,
			0x83, 0x7e, 0x16, 0x56,
		],
		[
			0xd5, 0x81, 0x12, 0x6b, 0x6b, 0xdc, 0xc4, 0xc6, 0x84, 0x25, 0x04, 0xdd, 0xc9, 0x8c,
			0xb1, 0x50, 0x56, 0x19, 0x6e, 0xbf, 0x69, 0x03, 0x12, 0x38, 0x93, 0x20, 0x98, 0xb7,
			0xf2, 0x5e, 0x4c, 0xd6,
		],
		[
			0x12, 0x4b, 0xbc, 0x2e, 0x30, 0x71, 0x18, 0xa5, 0x82, 0xd5, 0xae, 0x52, 0xfa, 0xfd,
			0xbf, 0xcb, 0x75, 0x2b, 0x94, 0x8e, 0x9e, 0xc3, 0xaf, 0x56, 0xa1, 0x41, 0xdc, 0x57,
			0xaf, 0x40, 0x50, 0xdb,
		],
		[
			0xaa, 0xaa, 0x52, 0xad, 0xa4, 0xf5, 0xde, 0xd6, 0x92, 0x9e, 0xbf, 0xb9, 0x12, 0xfa,
			0x70, 0x12, 0xa8, 0x19, 0x6e, 0x0c, 0xa4, 0xdf, 0x7c, 0x99, 0x88, 0x94, 0x2c, 0x3a,
			0x98, 0x3d, 0xa6, 0x4e,
		],
	];

	#[test]
	fn golden() {
		let data = generate(1024 * 64 * 64);
		let chunks = super::Chunker::from(&data).map(blake3::hash);
		for (actual, &expected) in chunks.zip(GOLDEN.iter()) {
			assert_eq!(actual, blake3::Hash::from(expected));
		}
	}
}