hacspec_lib/
vec_integers_secret.rs

1#![allow(unused_variables)]
2use crate::prelude::*;
3
4// TODO: this won't allow us to split between signed and unsigned.
5impl<T: Numeric + SecretInteger + Copy> ModNumeric for Seq<T> {
6    /// (self - rhs) % n.
7    fn sub_mod(self, rhs: Self, n: Self) -> Self {
8        unimplemented!();
9    }
10    /// `(self + rhs) % n`
11    fn add_mod(self, rhs: Self, n: Self) -> Self {
12        unimplemented!();
13    }
14    /// `(self * rhs) % n`
15    fn mul_mod(self, rhs: Self, n: Self) -> Self {
16        unimplemented!();
17    }
18    /// `(self ^ exp) % n`
19    fn pow_mod(self, exp: Self, n: Self) -> Self {
20        unimplemented!();
21    }
22    /// `self % n`
23    fn modulo(self, n: Self) -> Self {
24        unimplemented!();
25    }
26    fn signed_modulo(self, _n: Self) -> Self {
27        unimplemented!();
28    }
29    /// `|self|` (coefficient-wise)
30    #[cfg_attr(feature = "use_attributes", in_hacspec)]
31    fn absolute(self) -> Self {
32        unimplemented!();
33    }
34}
35impl<T: Numeric + SecretInteger + Copy> Numeric for Seq<T> {
36    /// Return largest value that can be represented.
37    fn max_val() -> Self {
38        unimplemented!();
39    }
40
41    fn wrap_add(self, rhs: Self) -> Self {
42        self + rhs
43    }
44    fn wrap_sub(self, rhs: Self) -> Self {
45        self - rhs
46    }
47    fn wrap_mul(self, rhs: Self) -> Self {
48        self * rhs
49    }
50    fn wrap_div(self, rhs: Self) -> Self {
51        unimplemented!();
52    }
53
54    /// `self ^ exp` where `exp` is a `u32`.
55    fn exp(self, exp: u32) -> Self {
56        unimplemented!();
57    }
58    /// `self ^ exp` where `exp` is a `Self`.
59    fn pow_self(self, exp: Self) -> Self {
60        unimplemented!();
61    }
62    /// Division.
63    fn divide(self, rhs: Self) -> Self {
64        unimplemented!();
65    }
66    /// Invert self modulo n.
67    fn inv(self, n: Self) -> Self {
68        unimplemented!();
69    }
70
71    // Comparison functions returning bool.
72    fn equal(self, other: Self) -> bool {
73        unimplemented!();
74    }
75    fn greater_than(self, other: Self) -> bool {
76        unimplemented!();
77    }
78    fn greater_than_or_equal(self, other: Self) -> bool {
79        unimplemented!();
80    }
81    fn less_than(self, other: Self) -> bool {
82        unimplemented!();
83    }
84    fn less_than_or_equal(self, other: Self) -> bool {
85        unimplemented!();
86    }
87
88    // Comparison functions returning a bit mask (0x0..0 or 0xF..F).
89    fn not_equal_bm(self, other: Self) -> Self {
90        unimplemented!();
91    }
92    fn equal_bm(self, other: Self) -> Self {
93        unimplemented!();
94    }
95    fn greater_than_bm(self, other: Self) -> Self {
96        unimplemented!();
97    }
98    fn greater_than_or_equal_bm(self, other: Self) -> Self {
99        unimplemented!();
100    }
101    fn less_than_bm(self, other: Self) -> Self {
102        unimplemented!();
103    }
104    fn less_than_or_equal_bm(self, other: Self) -> Self {
105        unimplemented!();
106    }
107}
108
109/// Polynomial multiplication on ℤ\[x\]
110impl<T: Numeric + SecretInteger + Copy> Mul for Seq<T> {
111    type Output = Self;
112    #[cfg_attr(feature = "use_attributes", in_hacspec)]
113    fn mul(self, rhs: Self) -> Self::Output {
114        vec_poly_mul(self, rhs, T::default())
115    }
116}
117
118/// Polynomial subtraction on ℤ\[x\]
119impl<T: Numeric + SecretInteger + Copy> Sub for Seq<T> {
120    type Output = Self;
121    #[cfg_attr(feature = "use_attributes", in_hacspec)]
122    fn sub(self, rhs: Self) -> Self::Output {
123        vec_poly_sub(self, rhs, T::default())
124    }
125}
126
127/// Polynomial addition on ℤ\[x\]
128impl<T: Numeric + SecretInteger + Copy> Add for Seq<T> {
129    type Output = Self;
130    #[cfg_attr(feature = "use_attributes", in_hacspec)]
131    fn add(self, rhs: Self) -> Self::Output {
132        vec_poly_add(self, rhs, T::default())
133    }
134}
135
136impl<T: Numeric + SecretInteger + Copy> Not for Seq<T> {
137    type Output = Seq<T>;
138    #[cfg_attr(feature = "use_attributes", in_hacspec)]
139    fn not(self) -> Self::Output {
140        let mut out = Self::new(self.len());
141        for (a, b) in out.b.iter_mut().zip(self.b.iter()) {
142            *a = !*b;
143        }
144        out
145    }
146}
147
148impl<T: Numeric + SecretInteger + Copy> BitOr for Seq<T> {
149    type Output = Seq<T>;
150    #[cfg_attr(feature = "use_attributes", in_hacspec)]
151    fn bitor(self, rhs: Self) -> Self::Output {
152        let mut out = Self::new(self.len());
153        for (a, (b, c)) in out.b.iter_mut().zip(self.b.iter().zip(rhs.b.iter())) {
154            *a = *b | *c;
155        }
156        out
157    }
158}
159
160impl<T: Numeric + SecretInteger + Copy> BitXor for Seq<T> {
161    type Output = Seq<T>;
162    #[cfg_attr(feature = "use_attributes", in_hacspec)]
163    fn bitxor(self, rhs: Self) -> Self::Output {
164        let mut out = Self::new(self.len());
165        for (a, (b, c)) in out.b.iter_mut().zip(self.b.iter().zip(rhs.b.iter())) {
166            *a = *b ^ *c;
167        }
168        out
169    }
170}
171
172impl<T: Numeric + SecretInteger + Copy> BitAnd for Seq<T> {
173    type Output = Seq<T>;
174    #[cfg_attr(feature = "use_attributes", in_hacspec)]
175    fn bitand(self, rhs: Self) -> Self::Output {
176        let mut out = Self::new(self.len());
177        for (a, (b, c)) in out.b.iter_mut().zip(self.b.iter().zip(rhs.b.iter())) {
178            *a = *b & *c;
179        }
180        out
181    }
182}
183
184impl<T: Numeric + SecretInteger + Copy> Shr<usize> for Seq<T> {
185    type Output = Seq<T>;
186    #[cfg_attr(feature = "use_attributes", in_hacspec)]
187    fn shr(self, rhs: usize) -> Self::Output {
188        unimplemented!();
189    }
190}
191
192impl<T: Numeric + SecretInteger + Copy> Shl<usize> for Seq<T> {
193    type Output = Seq<T>;
194    #[cfg_attr(feature = "use_attributes", in_hacspec)]
195    fn shl(self, rhs: usize) -> Self::Output {
196        unimplemented!();
197    }
198}