data.random.toeplitz ≡
template < auto PipelineCycles, auto HashWidth, auto DataWidth, auto KeyWidth, uint<KeyWidth> Key > class toeplitz §source
Implementation of the Toeplitz hash algorithm as described here.
Input data is passed into calc_hash as one parallel data
structure.
If you need a key, a secure rng is a reasonable method of producing one. Here is a 256 byte key produced with the default Windows RNGCryptoServiceProvider. You can truncate it to whatever length you need.
6D 5A 1B A6 54 0E 36 AE 73 84 C9 47 79 71 0E 89 BA B5 77 83 62 E9 B3 02 C3 A2 CF 20 2B 56 15 A9
DD 5E 8E F2 E2 EF 40 44 4F 7C 23 BB B7 6A 50 8B F4 8B E9 00 D8 A3 3D AE 88 29 FB 3C 64 37 71 A6
C6 CD 1B F7 80 24 89 A2 35 5A B4 C2 43 56 04 2E 5F 67 99 BC BA 61 1C 0B C6 70 9B FA 9D AC 4B 74
2A 8C 31 FA 41 56 81 8F 7D 77 B5 8C F7 B8 29 F6 06 8F 09 A3 20 B1 02 74 A0 95 3B 87 35 C7 2E 3A
9D 47 2C 2D C7 C9 0B 9C 07 8E 76 7B 2C D6 47 79 28 F5 ED 41 A7 CD 3A 00 1D 1D A6 CC 6E 3D 0D 0C
CD DB 40 FC 39 68 BA 50 41 F1 18 25 C7 03 4B 0C F4 3E DD 60 32 6F 41 B3 35 5B 8E E4 D7 93 5B 46
C7 6A F8 E3 D5 37 17 65 9B 19 8A C8 07 CD 79 D8 C2 E3 EF C0 0E 81 70 81 2D E3 77 B9 96 B6 16 D2
ED BD 4C 99 4E D8 0E 39 A2 49 1E 73 4A C1 51 05 09 52 85 6B 52 47 58 07 74 10 6D 78 E8 16 94 6E
Parameters
-
auto PipelineCyclesThe hash computation will be pipelined such that it can calculate a new result every
DataWidthcycles. Increasing this lowers the area consumed to implement the hash at the expense of throughput. -
auto HashWidthThe width of the output hash value.
-
auto DataWidthThe width of the input data.
-
auto KeyWidth -
uint<KeyWidth> KeyKey value used for hash computation. This value must be at least
HashWidthbits wide.
Aliases
Methods
Invariants
-
(KeyWidth >= HashWidth)
-
(PipelineCycles > 0)
template <auto Width, auto KeyWidth, uint<KeyWidth> Key, auto PipelineCycles> class toeplitz_random §source
Implement a pseudo-random number generator by hashing a counter with
a Toeplitz hash implementation. This implementation is more expensive
than LFSR, but gives a result that is more analogous to the
std::random algorithms in C++.
A reasonable key for 256-bit or smaller widths is:
0x6D5A1BA6540E36AE7384C94779710E89BAB5778362E9B302C3A2CF202B5615A9
Parameters
-
auto WidthThe width of the output in bits, as well as the width of the internal counter.
-
auto KeyWidthThe width of the Toeplitz hash key in bits.
-
uint<KeyWidth> KeyToeplitz hash key. The width of the key must be greater than or equal to the output
Width. -
auto PipelineCyclesPipeline cycles to use for the hash calculation. A value of 1 gives maximum throughput but consumes maximum area. Values larger than one reduce throughput and consume less area.
Methods
-
uint<Width> next(bool set_seed, uint<Width> seed) §source
Get the next random number in the sequence, optionally seeding the random number generator first.
Arguments
-
bool set_seed
If true, the random number will be seeded with the specified seed.
-
uint<Width> seed
The number to seed the random number generator. Ignored if
set_seedis false.
-