Introduce efficient Hash-based RNG streamer (#4169)

* Introduce efficient Hash-based RNG streamer

* Loop in the case of being in bias space.

* Fix tests

* Minor cleanup
This commit is contained in:
Gavin Wood
2019-11-26 13:27:15 +01:00
committed by Robert Habermeier
parent 9ead395bff
commit 70bc6eaed6
3 changed files with 114 additions and 1 deletions
@@ -1026,7 +1026,14 @@ pub trait OpaqueKeys: Clone {
}
/// Input that adds infinite number of zero after wrapped input.
struct TrailingZeroInput<'a>(&'a [u8]);
pub struct TrailingZeroInput<'a>(&'a [u8]);
impl<'a> TrailingZeroInput<'a> {
/// Create a new instance from the given byte array.
pub fn new(data: &'a [u8]) -> Self {
Self(data)
}
}
impl<'a> codec::Input for TrailingZeroInput<'a> {
fn remaining_len(&mut self) -> Result<Option<usize>, codec::Error> {