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
use zcash_primitives::{
constants::VALUE_COMMITMENT_VALUE_GENERATOR, transaction::components::Amount,
};
mod prover;
mod verifier;
pub use self::prover::SaplingProvingContext;
pub use self::verifier::SaplingVerificationContext;
fn compute_value_balance(value: Amount) -> Option<jubjub::ExtendedPoint> {
let abs = match i64::from(value).checked_abs() {
Some(a) => a as u64,
None => return None,
};
let is_negative = value.is_negative();
let mut value_balance = VALUE_COMMITMENT_VALUE_GENERATOR * jubjub::Fr::from(abs);
if is_negative {
value_balance = -value_balance;
}
Some(value_balance.into())
}