mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-30 20:11:23 +00:00
ff: Rename PrimeField::into_repr -> PrimeField::to_repr
This commit is contained in:
@@ -172,7 +172,7 @@ impl<E: JubjubEngine, Subgroup> Point<E, Subgroup> {
|
||||
|
||||
assert_eq!(E::Fr::NUM_BITS, 255);
|
||||
|
||||
let mut y_repr = y.into_repr();
|
||||
let mut y_repr = y.to_repr();
|
||||
if x.is_odd() {
|
||||
y_repr.as_mut()[31] |= 0x80;
|
||||
}
|
||||
|
@@ -122,7 +122,7 @@ impl ConstantTimeEq for Fs {
|
||||
|
||||
impl ::std::fmt::Display for Fs {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
write!(f, "Fs({})", self.into_repr())
|
||||
write!(f, "Fs({})", self.to_repr())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,13 +137,13 @@ impl From<u64> for Fs {
|
||||
|
||||
impl From<Fs> for FsRepr {
|
||||
fn from(e: Fs) -> FsRepr {
|
||||
e.into_repr()
|
||||
e.to_repr()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a Fs> for FsRepr {
|
||||
fn from(e: &'a Fs) -> FsRepr {
|
||||
e.into_repr()
|
||||
e.to_repr()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ impl PrimeField for Fs {
|
||||
}
|
||||
}
|
||||
|
||||
fn into_repr(&self) -> FsRepr {
|
||||
fn to_repr(&self) -> FsRepr {
|
||||
let mut r = *self;
|
||||
r.mont_reduce(self.0[0], self.0[1], self.0[2], self.0[3], 0, 0, 0, 0);
|
||||
|
||||
@@ -1095,7 +1095,7 @@ fn test_fs_sqrt() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fs_from_into_repr() {
|
||||
fn test_fs_from_to_repr() {
|
||||
// r + 1 should not be in the field
|
||||
assert!(Fs::from_repr(FsRepr([
|
||||
0xb8, 0x2c, 0xf7, 0xd6, 0x5e, 0x0e, 0x97, 0xd0, 0x82, 0x10, 0xc8, 0xcc, 0x93, 0x20, 0x68,
|
||||
@@ -1140,7 +1140,7 @@ fn test_fs_from_into_repr() {
|
||||
for _ in 0..1000 {
|
||||
// Try to turn Fs elements into representations and back again, and compare.
|
||||
let a = Fs::random(&mut rng);
|
||||
let a_repr = a.into_repr();
|
||||
let a_repr = a.to_repr();
|
||||
let b_repr = FsRepr::from(a);
|
||||
assert_eq!(a_repr, b_repr);
|
||||
let a_again = Fs::from_repr(a_repr).unwrap();
|
||||
|
@@ -374,7 +374,7 @@ fn test_jubjub_params<E: JubjubEngine>(params: &E::Params) {
|
||||
|
||||
let max = {
|
||||
// Grab char - 1 in little endian.
|
||||
let mut tmp = (-E::Fs::one()).into_repr();
|
||||
let mut tmp = (-E::Fs::one()).to_repr();
|
||||
<E::Fs as PrimeField>::ReprEndianness::toggle_little_endian(&mut tmp);
|
||||
|
||||
// Shift right by 1 bit.
|
||||
@@ -399,8 +399,8 @@ fn test_jubjub_params<E: JubjubEngine>(params: &E::Params) {
|
||||
pacc += &tmp;
|
||||
nacc -= &tmp; // The first subtraction wraps intentionally.
|
||||
|
||||
let mut pacc_repr = pacc.into_repr();
|
||||
let mut nacc_repr = nacc.into_repr();
|
||||
let mut pacc_repr = pacc.to_repr();
|
||||
let mut nacc_repr = nacc.to_repr();
|
||||
<E::Fs as PrimeField>::ReprEndianness::toggle_little_endian(&mut pacc_repr);
|
||||
<E::Fs as PrimeField>::ReprEndianness::toggle_little_endian(&mut nacc_repr);
|
||||
|
||||
|
@@ -91,8 +91,8 @@ impl<E: JubjubEngine> ExpandedSpendingKey<E> {
|
||||
}
|
||||
|
||||
pub fn write<W: Write>(&self, mut writer: W) -> io::Result<()> {
|
||||
writer.write_all(self.ask.into_repr().as_ref())?;
|
||||
writer.write_all(self.nsk.into_repr().as_ref())?;
|
||||
writer.write_all(self.ask.to_repr().as_ref())?;
|
||||
writer.write_all(self.nsk.to_repr().as_ref())?;
|
||||
writer.write_all(&self.ovk.0)?;
|
||||
|
||||
Ok(())
|
||||
|
@@ -211,13 +211,13 @@ impl<Node: Hashable> CommitmentTree<Node> {
|
||||
///
|
||||
/// let mut tree = CommitmentTree::<Node>::new();
|
||||
///
|
||||
/// tree.append(Node::new(Fr::random(&mut rng).into_repr()));
|
||||
/// tree.append(Node::new(Fr::random(&mut rng).into_repr()));
|
||||
/// tree.append(Node::new(Fr::random(&mut rng).to_repr()));
|
||||
/// tree.append(Node::new(Fr::random(&mut rng).to_repr()));
|
||||
/// let mut witness = IncrementalWitness::from_tree(&tree);
|
||||
/// assert_eq!(witness.position(), 1);
|
||||
/// assert_eq!(tree.root(), witness.root());
|
||||
///
|
||||
/// let cmu = Node::new(Fr::random(&mut rng).into_repr());
|
||||
/// let cmu = Node::new(Fr::random(&mut rng).to_repr());
|
||||
/// tree.append(cmu);
|
||||
/// witness.append(cmu);
|
||||
/// assert_eq!(tree.root(), witness.root());
|
||||
|
@@ -193,7 +193,7 @@ fn prf_ock(
|
||||
let mut ock_input = [0u8; 128];
|
||||
ock_input[0..32].copy_from_slice(&ovk.0);
|
||||
cv.write(&mut ock_input[32..64]).unwrap();
|
||||
ock_input[64..96].copy_from_slice(cmu.into_repr().as_ref());
|
||||
ock_input[64..96].copy_from_slice(cmu.to_repr().as_ref());
|
||||
epk.write(&mut ock_input[96..128]).unwrap();
|
||||
|
||||
Blake2bParams::new()
|
||||
@@ -303,7 +303,7 @@ impl SaplingNoteEncryption {
|
||||
(&mut input[12..20])
|
||||
.write_u64::<LittleEndian>(self.note.value)
|
||||
.unwrap();
|
||||
input[20..COMPACT_NOTE_SIZE].copy_from_slice(self.note.r.into_repr().as_ref());
|
||||
input[20..COMPACT_NOTE_SIZE].copy_from_slice(self.note.r.to_repr().as_ref());
|
||||
input[COMPACT_NOTE_SIZE..NOTE_PLAINTEXT_SIZE].copy_from_slice(&self.memo.0);
|
||||
|
||||
let mut output = [0u8; ENC_CIPHERTEXT_SIZE];
|
||||
@@ -327,7 +327,7 @@ impl SaplingNoteEncryption {
|
||||
|
||||
let mut input = [0u8; OUT_PLAINTEXT_SIZE];
|
||||
self.note.pk_d.write(&mut input[0..32]).unwrap();
|
||||
input[32..OUT_PLAINTEXT_SIZE].copy_from_slice(self.esk.into_repr().as_ref());
|
||||
input[32..OUT_PLAINTEXT_SIZE].copy_from_slice(self.esk.to_repr().as_ref());
|
||||
|
||||
let mut output = [0u8; OUT_CIPHERTEXT_SIZE];
|
||||
assert_eq!(
|
||||
@@ -366,7 +366,7 @@ fn parse_note_plaintext_without_memo(
|
||||
let diversifier = Diversifier(d);
|
||||
let pk_d = diversifier
|
||||
.g_d::<Bls12>(&JUBJUB)?
|
||||
.mul(ivk.into_repr(), &JUBJUB);
|
||||
.mul(ivk.to_repr(), &JUBJUB);
|
||||
|
||||
let to = PaymentAddress::from_parts(diversifier, pk_d)?;
|
||||
let note = to.create_note(v, rcm, &JUBJUB).unwrap();
|
||||
@@ -525,7 +525,7 @@ pub fn try_sapling_output_recovery(
|
||||
let diversifier = Diversifier(d);
|
||||
if diversifier
|
||||
.g_d::<Bls12>(&JUBJUB)?
|
||||
.mul(esk.into_repr(), &JUBJUB)
|
||||
.mul(esk.to_repr(), &JUBJUB)
|
||||
!= *epk
|
||||
{
|
||||
// Published epk doesn't match calculated epk
|
||||
|
@@ -89,7 +89,7 @@ where
|
||||
let window = JubjubBls12::pedersen_hash_exp_window_size() as usize;
|
||||
let window_mask = (1u64 << window) - 1;
|
||||
|
||||
let mut acc = acc.into_repr();
|
||||
let mut acc = acc.to_repr();
|
||||
<E::Fs as PrimeField>::ReprEndianness::toggle_little_endian(&mut acc);
|
||||
let num_limbs: usize = acc.as_ref().len() / 8;
|
||||
let mut limbs = vec![0u64; num_limbs + 1];
|
||||
|
@@ -20,7 +20,7 @@ fn read_scalar<E: JubjubEngine, R: Read>(mut reader: R) -> io::Result<E::Fs> {
|
||||
}
|
||||
|
||||
fn write_scalar<E: JubjubEngine, W: Write>(s: &E::Fs, mut writer: W) -> io::Result<()> {
|
||||
writer.write_all(s.into_repr().as_ref())
|
||||
writer.write_all(s.to_repr().as_ref())
|
||||
}
|
||||
|
||||
fn h_star<E: JubjubEngine>(a: &[u8], b: &[u8]) -> E::Fs {
|
||||
|
@@ -45,7 +45,7 @@ pub fn merkle_hash(depth: usize, lhs: &FrRepr, rhs: &FrRepr) -> FrRepr {
|
||||
)
|
||||
.to_xy()
|
||||
.0
|
||||
.into_repr()
|
||||
.to_repr()
|
||||
}
|
||||
|
||||
/// A node within the Sapling commitment tree.
|
||||
@@ -79,7 +79,7 @@ impl Hashable for Node {
|
||||
|
||||
fn blank() -> Self {
|
||||
Node {
|
||||
repr: Note::<Bls12>::uncommitted().into_repr(),
|
||||
repr: Note::<Bls12>::uncommitted().to_repr(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -745,7 +745,7 @@ mod tests {
|
||||
let note1 = to
|
||||
.create_note(50000, Fs::random(&mut rng), &JUBJUB)
|
||||
.unwrap();
|
||||
let cm1 = Node::new(note1.cm(&JUBJUB).into_repr());
|
||||
let cm1 = Node::new(note1.cm(&JUBJUB).to_repr());
|
||||
let mut tree = CommitmentTree::new();
|
||||
tree.append(cm1).unwrap();
|
||||
let witness1 = IncrementalWitness::from_tree(&tree);
|
||||
@@ -844,7 +844,7 @@ mod tests {
|
||||
let note1 = to
|
||||
.create_note(59999, Fs::random(&mut rng), &JUBJUB)
|
||||
.unwrap();
|
||||
let cm1 = Node::new(note1.cm(&JUBJUB).into_repr());
|
||||
let cm1 = Node::new(note1.cm(&JUBJUB).to_repr());
|
||||
let mut tree = CommitmentTree::new();
|
||||
tree.append(cm1).unwrap();
|
||||
let mut witness1 = IncrementalWitness::from_tree(&tree);
|
||||
@@ -882,7 +882,7 @@ mod tests {
|
||||
}
|
||||
|
||||
let note2 = to.create_note(1, Fs::random(&mut rng), &JUBJUB).unwrap();
|
||||
let cm2 = Node::new(note2.cm(&JUBJUB).into_repr());
|
||||
let cm2 = Node::new(note2.cm(&JUBJUB).to_repr());
|
||||
tree.append(cm2).unwrap();
|
||||
witness1.append(cm2).unwrap();
|
||||
let witness2 = IncrementalWitness::from_tree(&tree);
|
||||
|
@@ -176,7 +176,7 @@ impl SpendDescription {
|
||||
|
||||
pub fn write<W: Write>(&self, mut writer: W) -> io::Result<()> {
|
||||
self.cv.write(&mut writer)?;
|
||||
writer.write_all(self.anchor.into_repr().as_ref())?;
|
||||
writer.write_all(self.anchor.to_repr().as_ref())?;
|
||||
writer.write_all(&self.nullifier)?;
|
||||
self.rk.write(&mut writer)?;
|
||||
writer.write_all(&self.zkproof)?;
|
||||
@@ -254,7 +254,7 @@ impl OutputDescription {
|
||||
|
||||
pub fn write<W: Write>(&self, mut writer: W) -> io::Result<()> {
|
||||
self.cv.write(&mut writer)?;
|
||||
writer.write_all(self.cmu.into_repr().as_ref())?;
|
||||
writer.write_all(self.cmu.to_repr().as_ref())?;
|
||||
self.ephemeral_key.write(&mut writer)?;
|
||||
writer.write_all(&self.enc_ciphertext)?;
|
||||
writer.write_all(&self.out_ciphertext)?;
|
||||
|
@@ -128,7 +128,7 @@ fn shielded_spends_hash(tx: &TransactionData) -> Blake2bHash {
|
||||
let mut data = Vec::with_capacity(tx.shielded_spends.len() * 384);
|
||||
for s_spend in &tx.shielded_spends {
|
||||
s_spend.cv.write(&mut data).unwrap();
|
||||
data.extend_from_slice(s_spend.anchor.into_repr().as_ref());
|
||||
data.extend_from_slice(s_spend.anchor.to_repr().as_ref());
|
||||
data.extend_from_slice(&s_spend.nullifier);
|
||||
s_spend.rk.write(&mut data).unwrap();
|
||||
data.extend_from_slice(&s_spend.zkproof);
|
||||
|
@@ -1014,8 +1014,8 @@ mod tests {
|
||||
let xsk = &xsks[j];
|
||||
let tv = &test_vectors[j];
|
||||
|
||||
assert_eq!(xsk.expsk.ask.into_repr().as_ref(), tv.ask.unwrap());
|
||||
assert_eq!(xsk.expsk.nsk.into_repr().as_ref(), tv.nsk.unwrap());
|
||||
assert_eq!(xsk.expsk.ask.to_repr().as_ref(), tv.ask.unwrap());
|
||||
assert_eq!(xsk.expsk.nsk.to_repr().as_ref(), tv.nsk.unwrap());
|
||||
|
||||
assert_eq!(xsk.expsk.ovk.0, tv.ovk);
|
||||
assert_eq!(xsk.dk.0, tv.dk);
|
||||
@@ -1040,7 +1040,7 @@ mod tests {
|
||||
assert_eq!(xfvk.dk.0, tv.dk);
|
||||
assert_eq!(xfvk.chain_code.0, tv.c);
|
||||
|
||||
assert_eq!(xfvk.fvk.vk.ivk().into_repr().as_ref(), tv.ivk);
|
||||
assert_eq!(xfvk.fvk.vk.ivk().to_repr().as_ref(), tv.ivk);
|
||||
|
||||
let mut ser = vec![];
|
||||
xfvk.write(&mut ser).unwrap();
|
||||
|
Reference in New Issue
Block a user