cryptocol/random/
trait_random_engine.rs

1// Copyright 2024, 2025 PARK Youngho.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
6// This file may not be copied, modified, or distributed
7// except according to those terms.
8
9
10/// The supporting trait for `Random_Generic`
11/// `Random_Generic` uses whatever object that has this trait for pseudo-random
12/// number generator engine. So, if you plug in any hash algorithm that has
13/// this trait to `Random_Generic`, `Random_Generic` will use the object
14/// as its pseudo-random number generator engine.
15/// You will hardly use the object that has this trait except the case
16/// that you use it in order to plug it in the `Random_Generic`. 
17#[allow(non_camel_case_types)]
18pub trait Random_Engine
19{
20    // // fn new() -> Self;
21    // /// Constructs the object.
22    // /// 
23    // /// # Example
24    // /// Refer to the souce codes of `Random` to see how to use this method.
25    // fn new() -> Box<dyn Random_Engine>;
26
27    // // fn new_with<T, const N: usize>(message: &[T; N]) -> Self
28    // /// Constructs the object with the given `message`.
29    // /// 
30    // /// # Features
31    // /// How to use the argument `message` depends on the object.
32    // /// 
33    // /// # Example
34    // /// Refer to the souce codes of `Random` to see how to use this method.
35    // // fn new_with<T, const N: usize>(message: &[T; N]) -> Self
36    // // where T: SmallUInt + Copy + Clone + Display + Debug + ToString
37    // //     + Add<Output=T> + AddAssign + Sub<Output=T> + SubAssign
38    // //     + Mul<Output=T> + MulAssign + Div<Output=T> + DivAssign
39    // //     + Rem<Output=T> + RemAssign
40    // //     + Shl<Output=T> + ShlAssign + Shr<Output=T> + ShrAssign
41    // //     + BitAnd<Output=T> + BitAndAssign + BitOr<Output=T> + BitOrAssign
42    // //     + BitXor<Output=T> + BitXorAssign + Not<Output=T>
43    // //     + PartialEq + PartialOrd;
44    // fn new_with(message: &[u64; 8]) -> Box<dyn Random_Engine>;
45
46    // fn sow_array<T, const N: usize>(&mut self, message: &[T; N])
47    /// Provides new seeds for `self`.
48    /// 
49    /// # Argument
50    /// `message` is the new seeds for `self`.
51    /// 
52    /// # Example
53    /// Refer to the souce codes of `Random` to see how to use this method.
54    // fn sow_array<T, const N: usize>(&mut self, message: &[T; N])
55    // where T: SmallUInt + Copy + Clone + Display + Debug + ToString
56    //     + Add<Output=T> + AddAssign + Sub<Output=T> + SubAssign
57    //     + Mul<Output=T> + MulAssign + Div<Output=T> + DivAssign
58    //     + Rem<Output=T> + RemAssign
59    //     + Shl<Output=T> + ShlAssign + Shr<Output=T> + ShrAssign
60    //     + BitAnd<Output=T> + BitAndAssign + BitOr<Output=T> + BitOrAssign
61    //     + BitXor<Output=T> + BitXorAssign + Not<Output=T>
62    //     + PartialEq + PartialOrd;
63    #[allow(unused_variables)]
64    fn sow_array(&mut self, message: &[u64; 8]) {}
65
66    // fn harvest(&mut self, sugar: u64) -> [u64; 8]
67    /// Outputs the pseudo-random number array.
68    /// 
69    /// # Argument
70    /// `sugar` is `u64`-typed unsigned integer that changes the direction of
71    /// its pseudo-random number sequence so that the period of the
72    /// pseudo-random number sequence may not repeated.
73    /// 
74    /// # Example
75    /// Refer to the souce codes of `Random` to see how to use this method.
76    fn harvest(&mut self, sugar: u64, message: &[u64; 8]) -> [u64; 8];
77}