mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-14 10:45:47 +00:00
Make EdwardsPoint (x, y) not public.
This commit is contained in:
parent
f155c01cf5
commit
7a9879eb54
@ -32,8 +32,8 @@ use super::boolean::Boolean;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct EdwardsPoint<E: Engine> {
|
||||
pub x: AllocatedNum<E>,
|
||||
pub y: AllocatedNum<E>
|
||||
x: AllocatedNum<E>,
|
||||
y: AllocatedNum<E>
|
||||
}
|
||||
|
||||
/// Perform a fixed-base scalar multiplication with
|
||||
@ -84,6 +84,14 @@ pub fn fixed_base_multiplication<E, CS>(
|
||||
}
|
||||
|
||||
impl<E: JubjubEngine> EdwardsPoint<E> {
|
||||
pub fn get_x(&self) -> &AllocatedNum<E> {
|
||||
&self.x
|
||||
}
|
||||
|
||||
pub fn get_y(&self) -> &AllocatedNum<E> {
|
||||
&self.y
|
||||
}
|
||||
|
||||
pub fn assert_not_small_order<CS>(
|
||||
&self,
|
||||
mut cs: CS,
|
||||
@ -183,12 +191,6 @@ impl<E: JubjubEngine> EdwardsPoint<E> {
|
||||
)
|
||||
}
|
||||
|
||||
/// This extracts the x-coordinate, which is an injective
|
||||
/// encoding for elements of the prime order subgroup.
|
||||
pub fn into_num(&self) -> AllocatedNum<E> {
|
||||
self.x.clone()
|
||||
}
|
||||
|
||||
/// Returns `self` if condition is true, and the neutral
|
||||
/// element (0, 1) otherwise.
|
||||
pub fn conditionally_select<CS>(
|
||||
|
@ -229,7 +229,7 @@ impl<'a, E: JubjubEngine> Circuit<E> for Spend<'a, E> {
|
||||
let mut position_bits = vec![];
|
||||
|
||||
// Injective encoding.
|
||||
let mut cur = cm.x.clone();
|
||||
let mut cur = cm.get_x().clone();
|
||||
|
||||
for (i, e) in self.auth_path.into_iter().enumerate() {
|
||||
let cs = &mut cs.namespace(|| format!("merkle tree hash {}", i));
|
||||
@ -268,7 +268,7 @@ impl<'a, E: JubjubEngine> Circuit<E> for Spend<'a, E> {
|
||||
pedersen_hash::Personalization::MerkleTree(i),
|
||||
&preimage,
|
||||
self.params
|
||||
)?.x; // Injective encoding
|
||||
)?.get_x().clone(); // Injective encoding
|
||||
}
|
||||
|
||||
assert_eq!(position_bits.len(), tree_depth);
|
||||
@ -473,7 +473,7 @@ impl<'a, E: JubjubEngine> Circuit<E> for Output<'a, E> {
|
||||
// since we know it is prime order, and we know that
|
||||
// the x-coordinate is an injective encoding for
|
||||
// prime-order elements.
|
||||
cm.x.inputize(cs.namespace(|| "commitment"))?;
|
||||
cm.get_x().inputize(cs.namespace(|| "commitment"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -176,8 +176,8 @@ mod test {
|
||||
params
|
||||
).into_xy();
|
||||
|
||||
assert_eq!(res.x.get_value().unwrap(), expected.0);
|
||||
assert_eq!(res.y.get_value().unwrap(), expected.1);
|
||||
assert_eq!(res.get_x().get_value().unwrap(), expected.0);
|
||||
assert_eq!(res.get_y().get_value().unwrap(), expected.1);
|
||||
|
||||
// Test against the output of a different personalization
|
||||
let unexpected = ::pedersen_hash::pedersen_hash::<Bls12, _>(
|
||||
@ -186,8 +186,8 @@ mod test {
|
||||
params
|
||||
).into_xy();
|
||||
|
||||
assert!(res.x.get_value().unwrap() != unexpected.0);
|
||||
assert!(res.y.get_value().unwrap() != unexpected.1);
|
||||
assert!(res.get_x().get_value().unwrap() != unexpected.0);
|
||||
assert!(res.get_y().get_value().unwrap() != unexpected.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user