mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-30 20:11:23 +00:00
Replace manual address decoding with PaymentAddress::from_bytes
This commit is contained in:
@@ -112,8 +112,7 @@ extern "C" {
|
||||
bool librustzcash_sapling_output_proof(
|
||||
void *ctx,
|
||||
const unsigned char *esk,
|
||||
const unsigned char *diversifier,
|
||||
const unsigned char *pk_d,
|
||||
const unsigned char *payment_address,
|
||||
const unsigned char *rcm,
|
||||
const uint64_t value,
|
||||
unsigned char *cv,
|
||||
|
@@ -927,8 +927,7 @@ pub extern "system" fn librustzcash_sprout_verify(
|
||||
pub extern "system" fn librustzcash_sapling_output_proof(
|
||||
ctx: *mut SaplingProvingContext,
|
||||
esk: *const [c_uchar; 32],
|
||||
diversifier: *const [c_uchar; 11],
|
||||
pk_d: *const [c_uchar; 32],
|
||||
payment_address: *const [c_uchar; 43],
|
||||
rcm: *const [c_uchar; 32],
|
||||
value: u64,
|
||||
cv: *mut [c_uchar; 32],
|
||||
@@ -940,26 +939,12 @@ pub extern "system" fn librustzcash_sapling_output_proof(
|
||||
Err(_) => return false,
|
||||
};
|
||||
|
||||
// Grab the diversifier from the caller.
|
||||
let diversifier = Diversifier(unsafe { *diversifier });
|
||||
|
||||
// Grab pk_d from the caller.
|
||||
let pk_d = match edwards::Point::<Bls12, Unknown>::read(&(unsafe { &*pk_d })[..], &JUBJUB) {
|
||||
Ok(p) => p,
|
||||
Err(_) => return false,
|
||||
};
|
||||
|
||||
// pk_d should be prime order.
|
||||
let pk_d = match pk_d.as_prime_order(&JUBJUB) {
|
||||
Some(p) => p,
|
||||
None => return false,
|
||||
};
|
||||
|
||||
// Construct a payment address
|
||||
let payment_address = PaymentAddress {
|
||||
pk_d: pk_d,
|
||||
diversifier: diversifier,
|
||||
};
|
||||
// Grab the payment address from the caller
|
||||
let payment_address =
|
||||
match PaymentAddress::<Bls12>::from_bytes(unsafe { &*payment_address }, &JUBJUB) {
|
||||
Some(pa) => pa,
|
||||
None => return false,
|
||||
};
|
||||
|
||||
// The caller provides the commitment randomness for the output note
|
||||
let rcm = match Fs::from_repr(read_fs(&(unsafe { &*rcm })[..])) {
|
||||
|
Reference in New Issue
Block a user