hacspec_lib/
vec_integers_public.rs

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