clock_curve_math/bigint/
arithmetic.rs1use core::cmp::Ordering;
4
5use super::BigInt;
6
7pub trait BigIntOps {
11 fn add(&self, rhs: &Self) -> Self;
13
14 fn sub(&self, rhs: &Self) -> Self;
16
17 fn mul(&self, rhs: &Self) -> Self;
21
22 fn mul_wide(&self, rhs: &Self) -> (Self, Self)
24 where
25 Self: Sized;
26
27 fn shl(&self, bits: u32) -> Self;
29
30 fn shr(&self, bits: u32) -> Self;
32
33 fn cmp(&self, rhs: &Self) -> Ordering;
35
36 fn is_zero(&self) -> bool;
38}
39
40impl BigIntOps for BigInt {
41 fn add(&self, rhs: &Self) -> Self {
42 self.add(rhs)
43 }
44
45 fn sub(&self, rhs: &Self) -> Self {
46 self.sub(rhs)
47 }
48
49 fn mul(&self, rhs: &Self) -> Self {
50 self.mul(rhs)
51 }
52
53 fn mul_wide(&self, rhs: &Self) -> (Self, Self) {
54 self.mul_wide(rhs)
55 }
56
57 fn shl(&self, bits: u32) -> Self {
58 self.shl(bits)
59 }
60
61 fn shr(&self, bits: u32) -> Self {
62 self.shr(bits)
63 }
64
65 fn cmp(&self, rhs: &Self) -> Ordering {
66 self.cmp(rhs)
67 }
68
69 fn is_zero(&self) -> bool {
70 self.is_zero()
71 }
72}