zkstd/arithmetic/
utils.rs

1use sp_std::vec::Vec;
2
3#[inline(always)]
4pub const fn sbb(a: u64, b: u64, brw: u64) -> (u64, u64) {
5    let t = (a as u128).wrapping_sub((b as u128) + (brw >> 63) as u128);
6    (t as u64, (t >> 64) as u64)
7}
8
9#[derive(Clone, Copy, Eq, PartialEq, Debug)]
10pub enum Naf {
11    Zero = 0,
12    Plus = 1,
13    Minus = 2,
14}
15
16impl From<i8> for Naf {
17    fn from(value: i8) -> Self {
18        match value {
19            0 => Naf::Zero,
20            1 => Naf::Plus,
21            -1 => Naf::Minus,
22            _ => unimplemented!(),
23        }
24    }
25}
26
27pub type Bits = Vec<u8>;
28
29pub type Nafs = Vec<Naf>;