1use super::BigInt;
5use super::HexError;
6use std::marker::Sized;
7
8pub trait ZeroizeBN {
10 fn zeroize_bn(&mut self);
11}
12
13pub trait Converter {
15 fn to_vec(n: &Self) -> Vec<u8>;
17 fn to_hex(&self) -> String;
19 fn from_hex(n: &str) -> Result<BigInt, HexError>;
21 fn from_bytes(bytes: &[u8]) -> Self;
23 fn to_bytes(&self) -> Vec<u8>;
25}
26
27pub trait Modulo {
29 fn mod_pow(base: &Self, exponent: &Self, modulus: &Self) -> Self;
30 fn mod_mul(a: &Self, b: &Self, modulus: &Self) -> Self;
31 fn mod_sub(a: &Self, b: &Self, modulus: &Self) -> Self;
32 fn mod_add(a: &Self, b: &Self, modulus: &Self) -> Self;
33 fn mod_inv(a: &Self, modulus: &Self) -> Self;
34}
35
36pub trait Samplable {
38 fn sample_below(upper: &Self) -> Self;
39 fn sample_range(lower: &Self, upper: &Self) -> Self;
40 fn strict_sample_range(lower: &Self, upper: &Self) -> Self;
41 fn sample(bitsize: usize) -> Self;
42 fn strict_sample(bit_size: usize) -> Self;
43}
44
45pub trait NumberTests {
47 fn is_zero(_: &Self) -> bool;
49 fn is_even(_: &Self) -> bool;
51 fn is_negative(_: &Self) -> bool;
53 fn bits(_: &Self) -> usize;
55}
56
57pub trait EGCD
59where
60 Self: Sized,
61{
62 fn egcd(a: &Self, b: &Self) -> (Self, Self, Self);
64}
65
66pub trait BitManipulation {
68 fn set_bit(self: &mut Self, bit: usize, bit_val: bool);
70 fn test_bit(self: &Self, bit: usize) -> bool;
72}
73
74pub trait ConvertFrom<T> {
76 fn _from(_: &T) -> Self;
77}