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
use dusk_pki::Ownable;
use dusk_pki::StealthAddress;
#[cfg(feature = "canon")]
use canonical_derive::Canon;
use dusk_poseidon::sponge::hash;
use crate::BlsScalar;
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "canon", derive(Canon))]
pub struct Remainder {
pub(crate) gas_changes: u64,
pub(crate) stealth_address: StealthAddress,
}
impl PartialEq for Remainder {
fn eq(&self, other: &Self) -> bool {
self.hash() == other.hash()
}
}
impl Eq for Remainder {}
impl Remainder {
pub fn hash(&self) -> BlsScalar {
let pk_r = self.stealth_address().pk_r().as_ref().to_hash_inputs();
hash(&[BlsScalar::from(self.gas_changes), pk_r[0], pk_r[1]])
}
}
impl Ownable for Remainder {
fn stealth_address(&self) -> &StealthAddress {
&self.stealth_address
}
}