1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#![allow(unused_variables)]
use crate::prelude::*;

// TODO: this won't allow us to split between signed and unsigned.
impl<T: Numeric + SecretInteger + Copy> ModNumeric for Seq<T> {
    /// (self - rhs) % n.
    fn sub_mod(self, rhs: Self, n: Self) -> Self {
        unimplemented!();
    }
    /// `(self + rhs) % n`
    fn add_mod(self, rhs: Self, n: Self) -> Self {
        unimplemented!();
    }
    /// `(self * rhs) % n`
    fn mul_mod(self, rhs: Self, n: Self) -> Self {
        unimplemented!();
    }
    /// `(self ^ exp) % n`
    fn pow_mod(self, exp: Self, n: Self) -> Self {
        unimplemented!();
    }
    /// `self % n`
    fn modulo(self, n: Self) -> Self {
        unimplemented!();
    }
    fn signed_modulo(self, _n: Self) -> Self {
        unimplemented!();
    }
    /// `|self|` (coefficient-wise)
    #[cfg_attr(feature = "use_attributes", in_hacspec)]
    fn absolute(self) -> Self {
        unimplemented!();
    }
}
impl<T: Numeric + SecretInteger + Copy> Numeric for Seq<T> {
    /// Return largest value that can be represented.
    fn max_val() -> Self {
        unimplemented!();
    }

    fn wrap_add(self, rhs: Self) -> Self {
        self + rhs
    }
    fn wrap_sub(self, rhs: Self) -> Self {
        self - rhs
    }
    fn wrap_mul(self, rhs: Self) -> Self {
        self * rhs
    }
    fn wrap_div(self, rhs: Self) -> Self {
        unimplemented!();
    }

    /// `self ^ exp` where `exp` is a `u32`.
    fn exp(self, exp: u32) -> Self {
        unimplemented!();
    }
    /// `self ^ exp` where `exp` is a `Self`.
    fn pow_self(self, exp: Self) -> Self {
        unimplemented!();
    }
    /// Division.
    fn divide(self, rhs: Self) -> Self {
        unimplemented!();
    }
    /// Invert self modulo n.
    fn inv(self, n: Self) -> Self {
        unimplemented!();
    }

    // Comparison functions returning bool.
    fn equal(self, other: Self) -> bool {
        unimplemented!();
    }
    fn greater_than(self, other: Self) -> bool {
        unimplemented!();
    }
    fn greater_than_or_equal(self, other: Self) -> bool {
        unimplemented!();
    }
    fn less_than(self, other: Self) -> bool {
        unimplemented!();
    }
    fn less_than_or_equal(self, other: Self) -> bool {
        unimplemented!();
    }

    // Comparison functions returning a bit mask (0x0..0 or 0xF..F).
    fn not_equal_bm(self, other: Self) -> Self {
        unimplemented!();
    }
    fn equal_bm(self, other: Self) -> Self {
        unimplemented!();
    }
    fn greater_than_bm(self, other: Self) -> Self {
        unimplemented!();
    }
    fn greater_than_or_equal_bm(self, other: Self) -> Self {
        unimplemented!();
    }
    fn less_than_bm(self, other: Self) -> Self {
        unimplemented!();
    }
    fn less_than_or_equal_bm(self, other: Self) -> Self {
        unimplemented!();
    }
}

/// Polynomial multiplication on ℤ\[x\]
impl<T: Numeric + SecretInteger + Copy> Mul for Seq<T> {
    type Output = Self;
    #[cfg_attr(feature = "use_attributes", in_hacspec)]
    fn mul(self, rhs: Self) -> Self::Output {
        vec_poly_mul(self, rhs, T::default())
    }
}

/// Polynomial subtraction on ℤ\[x\]
impl<T: Numeric + SecretInteger + Copy> Sub for Seq<T> {
    type Output = Self;
    #[cfg_attr(feature = "use_attributes", in_hacspec)]
    fn sub(self, rhs: Self) -> Self::Output {
        vec_poly_sub(self, rhs, T::default())
    }
}

/// Polynomial addition on ℤ\[x\]
impl<T: Numeric + SecretInteger + Copy> Add for Seq<T> {
    type Output = Self;
    #[cfg_attr(feature = "use_attributes", in_hacspec)]
    fn add(self, rhs: Self) -> Self::Output {
        vec_poly_add(self, rhs, T::default())
    }
}

impl<T: Numeric + SecretInteger + Copy> Not for Seq<T> {
    type Output = Seq<T>;
    #[cfg_attr(feature = "use_attributes", in_hacspec)]
    fn not(self) -> Self::Output {
        let mut out = Self::new(self.len());
        for (a, b) in out.b.iter_mut().zip(self.b.iter()) {
            *a = !*b;
        }
        out
    }
}

impl<T: Numeric + SecretInteger + Copy> BitOr for Seq<T> {
    type Output = Seq<T>;
    #[cfg_attr(feature = "use_attributes", in_hacspec)]
    fn bitor(self, rhs: Self) -> Self::Output {
        let mut out = Self::new(self.len());
        for (a, (b, c)) in out.b.iter_mut().zip(self.b.iter().zip(rhs.b.iter())) {
            *a = *b | *c;
        }
        out
    }
}

impl<T: Numeric + SecretInteger + Copy> BitXor for Seq<T> {
    type Output = Seq<T>;
    #[cfg_attr(feature = "use_attributes", in_hacspec)]
    fn bitxor(self, rhs: Self) -> Self::Output {
        let mut out = Self::new(self.len());
        for (a, (b, c)) in out.b.iter_mut().zip(self.b.iter().zip(rhs.b.iter())) {
            *a = *b ^ *c;
        }
        out
    }
}

impl<T: Numeric + SecretInteger + Copy> BitAnd for Seq<T> {
    type Output = Seq<T>;
    #[cfg_attr(feature = "use_attributes", in_hacspec)]
    fn bitand(self, rhs: Self) -> Self::Output {
        let mut out = Self::new(self.len());
        for (a, (b, c)) in out.b.iter_mut().zip(self.b.iter().zip(rhs.b.iter())) {
            *a = *b & *c;
        }
        out
    }
}

impl<T: Numeric + SecretInteger + Copy> Shr<usize> for Seq<T> {
    type Output = Seq<T>;
    #[cfg_attr(feature = "use_attributes", in_hacspec)]
    fn shr(self, rhs: usize) -> Self::Output {
        unimplemented!();
    }
}

impl<T: Numeric + SecretInteger + Copy> Shl<usize> for Seq<T> {
    type Output = Seq<T>;
    #[cfg_attr(feature = "use_attributes", in_hacspec)]
    fn shl(self, rhs: usize) -> Self::Output {
        unimplemented!();
    }
}