1#![no_std]
2#![doc = include_str!("../README.md")]
3
4extern crate alloc;
5
6mod hgd;
7mod ope;
8mod prng;
9mod utils;
10
11use num_bigint::BigInt as ZZ;
12
13use crate::ope::Ope;
14use crate::prng::BLOCK_SIZE;
15
16#[derive(Debug)]
17pub enum OpeError
18{
19 HdgInvalidInputs,
20 OpeRange,
21}
22
23const DOMAIN: u64 = u16::max_value() as u64 - 1;
27const RANGE: u64 = u32::max_value() as u64 - 1;
28
29pub type OpeKey = [u8; BLOCK_SIZE];
30
31pub fn get_ope(key: &OpeKey) -> Ope
32{
33 Ope::new(key, DOMAIN, RANGE)
34}
35
36#[cfg(test)]
37mod tests
38{
39 use alloc::borrow::ToOwned;
40 use alloc::vec::Vec;
41
42 use super::*;
43
44 const MAX_SIZE: u64 = 65531;
45
46 #[test]
47 #[ignore]
48 fn test_all_numbers()
49 {
50 let k = b"this is a key 10".to_owned();
51
52 let ope = get_ope(&k);
53
54 let mut v = Vec::with_capacity(MAX_SIZE as usize);
55
56 for i in 23..MAX_SIZE {
58 let en = ope.encrypt(i).unwrap();
59 v.push(en);
60 }
61
62 let mut past_item = 0;
64
65 for item in v {
66 assert!(past_item < item);
67
68 past_item = item;
69 }
70 }
71}