mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-31 12:31:22 +00:00
Rename into_ -> to_ where &self is used.
This commit is contained in:
@@ -168,7 +168,7 @@ impl<E: JubjubEngine> Point<E, Unknown> {
|
||||
|
||||
impl<E: JubjubEngine, Subgroup> Point<E, Subgroup> {
|
||||
pub fn write<W: Write>(&self, writer: W) -> io::Result<()> {
|
||||
let (x, y) = self.into_xy();
|
||||
let (x, y) = self.to_xy();
|
||||
|
||||
assert_eq!(E::Fr::NUM_BITS, 255);
|
||||
|
||||
@@ -183,7 +183,7 @@ impl<E: JubjubEngine, Subgroup> Point<E, Subgroup> {
|
||||
|
||||
/// Convert from a Montgomery point
|
||||
pub fn from_montgomery(m: &montgomery::Point<E, Subgroup>, params: &E::Params) -> Self {
|
||||
match m.into_xy() {
|
||||
match m.to_xy() {
|
||||
None => {
|
||||
// Map the point at infinity to the neutral element.
|
||||
Point::zero()
|
||||
@@ -306,7 +306,7 @@ impl<E: JubjubEngine, Subgroup> Point<E, Subgroup> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_xy(&self) -> (E::Fr, E::Fr) {
|
||||
pub fn to_xy(&self) -> (E::Fr, E::Fr) {
|
||||
let zinv = self.z.inverse().unwrap();
|
||||
|
||||
let mut x = self.x;
|
||||
|
@@ -384,7 +384,7 @@ impl JubjubBls12 {
|
||||
|
||||
// coeffs = g, g*2, g*3, g*4
|
||||
for _ in 0..4 {
|
||||
coeffs.push(g.into_xy().expect("cannot produce O"));
|
||||
coeffs.push(g.to_xy().expect("cannot produce O"));
|
||||
g = g.add(&gen, &tmp_params);
|
||||
}
|
||||
windows.push(coeffs);
|
||||
@@ -411,7 +411,7 @@ impl JubjubBls12 {
|
||||
let mut coeffs = vec![(Fr::zero(), Fr::one())];
|
||||
let mut g = gen.clone();
|
||||
for _ in 0..7 {
|
||||
coeffs.push(g.into_xy());
|
||||
coeffs.push(g.to_xy());
|
||||
g = g.add(&gen, &tmp_params);
|
||||
}
|
||||
windows.push(coeffs);
|
||||
|
@@ -98,7 +98,7 @@ impl<E: JubjubEngine> Point<E, Unknown> {
|
||||
impl<E: JubjubEngine, Subgroup> Point<E, Subgroup> {
|
||||
/// Convert from an Edwards point
|
||||
pub fn from_edwards(e: &edwards::Point<E, Subgroup>, params: &E::Params) -> Self {
|
||||
let (x, y) = e.into_xy();
|
||||
let (x, y) = e.to_xy();
|
||||
|
||||
if y == E::Fr::one() {
|
||||
// The only solution for y = 1 is x = 0. (0, 1) is
|
||||
@@ -177,7 +177,7 @@ impl<E: JubjubEngine, Subgroup> Point<E, Subgroup> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_xy(&self) -> Option<(E::Fr, E::Fr)> {
|
||||
pub fn to_xy(&self) -> Option<(E::Fr, E::Fr)> {
|
||||
if self.infinity {
|
||||
None
|
||||
} else {
|
||||
|
@@ -119,13 +119,13 @@ fn test_mul_associativity<E: JubjubEngine>(params: &E::Params) {
|
||||
assert!(res2 == res3);
|
||||
assert!(res3 == res4);
|
||||
|
||||
let (x, y) = res1.into_xy();
|
||||
let (x, y) = res1.to_xy();
|
||||
assert!(is_on_twisted_edwards_curve(x, y, params));
|
||||
|
||||
let (x, y) = res2.into_xy();
|
||||
let (x, y) = res2.to_xy();
|
||||
assert!(is_on_twisted_edwards_curve(x, y, params));
|
||||
|
||||
let (x, y) = res3.into_xy();
|
||||
let (x, y) = res3.to_xy();
|
||||
assert!(is_on_twisted_edwards_curve(x, y, params));
|
||||
}
|
||||
}
|
||||
@@ -238,7 +238,7 @@ fn test_get_for<E: JubjubEngine>(params: &E::Params) {
|
||||
let sign = rng.next_u32() % 2 == 1;
|
||||
|
||||
if let Some(mut p) = edwards::Point::<E, _>::get_for_y(y, sign, params) {
|
||||
assert!(p.into_xy().0.into_repr().is_odd() == sign);
|
||||
assert!(p.to_xy().0.into_repr().is_odd() == sign);
|
||||
p = p.negate();
|
||||
assert!(edwards::Point::<E, _>::get_for_y(y, !sign, params).unwrap() == p);
|
||||
}
|
||||
@@ -274,12 +274,12 @@ fn test_rand<E: JubjubEngine>(params: &E::Params) {
|
||||
let e = edwards::Point::<E, _>::rand(rng, params);
|
||||
|
||||
{
|
||||
let (x, y) = p.into_xy().unwrap();
|
||||
let (x, y) = p.to_xy().unwrap();
|
||||
assert!(is_on_mont_curve(x, y, params));
|
||||
}
|
||||
|
||||
{
|
||||
let (x, y) = e.into_xy();
|
||||
let (x, y) = e.to_xy();
|
||||
assert!(is_on_twisted_edwards_curve(x, y, params));
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ pub struct ProofGenerationKey<E: JubjubEngine> {
|
||||
}
|
||||
|
||||
impl<E: JubjubEngine> ProofGenerationKey<E> {
|
||||
pub fn into_viewing_key(&self, params: &E::Params) -> ViewingKey<E> {
|
||||
pub fn to_viewing_key(&self, params: &E::Params) -> ViewingKey<E> {
|
||||
ViewingKey {
|
||||
ak: self.ak.clone(),
|
||||
nk: params
|
||||
@@ -89,7 +89,7 @@ impl<E: JubjubEngine> ViewingKey<E> {
|
||||
E::Fs::from_repr(e).expect("should be a valid scalar")
|
||||
}
|
||||
|
||||
pub fn into_payment_address(
|
||||
pub fn to_payment_address(
|
||||
&self,
|
||||
diversifier: Diversifier,
|
||||
params: &E::Params,
|
||||
@@ -242,6 +242,6 @@ impl<E: JubjubEngine> Note<E> {
|
||||
pub fn cm(&self, params: &E::Params) -> E::Fr {
|
||||
// The commitment is in the prime order subgroup, so mapping the
|
||||
// commitment to the x-coordinate is an injective encoding.
|
||||
self.cm_full_point(params).into_xy().0
|
||||
self.cm_full_point(params).to_xy().0
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ pub fn merkle_hash(depth: usize, lhs: &FrRepr, rhs: &FrRepr) -> FrRepr {
|
||||
.chain(rhs.iter().copied().take(Fr::NUM_BITS as usize)),
|
||||
&JUBJUB,
|
||||
)
|
||||
.into_xy()
|
||||
.to_xy()
|
||||
.0
|
||||
.into_repr()
|
||||
}
|
||||
|
@@ -394,7 +394,7 @@ impl<R: RngCore + CryptoRng> Builder<R> {
|
||||
|
||||
let mut nullifier = [0u8; 32];
|
||||
nullifier.copy_from_slice(&spend.note.nf(
|
||||
&proof_generation_key.into_viewing_key(&JUBJUB),
|
||||
&proof_generation_key.to_viewing_key(&JUBJUB),
|
||||
spend.witness.position,
|
||||
&JUBJUB,
|
||||
));
|
||||
|
@@ -434,7 +434,7 @@ impl ExtendedFullViewingKey {
|
||||
Ok(ret) => ret,
|
||||
Err(()) => return Err(()),
|
||||
};
|
||||
match self.fvk.vk.into_payment_address(d_j, &JUBJUB) {
|
||||
match self.fvk.vk.to_payment_address(d_j, &JUBJUB) {
|
||||
Some(addr) => Ok((j, addr)),
|
||||
None => Err(()),
|
||||
}
|
||||
|
Reference in New Issue
Block a user