skoupidi 1 rok temu
rodzic
commit
c7195be6cd
3 zmienionych plików z 12 dodań i 12 usunięć
  1. 8 8
      src/sdk/python/src/merkle.rs
  2. 2 2
      src/sdk/python/src/pasta.rs
  3. 2 2
      src/util/pcg.rs

+ 8 - 8
src/sdk/python/src/merkle.rs

@@ -37,22 +37,22 @@ impl MerkleTree {
         Self(merkle_node::MerkleTree::new(1))
     }
 
-    fn append(&mut self, node: &Bound<Fp>) -> PyResult<bool> {
-        Ok(self.0.append(MerkleNode::from(node.borrow().deref().0)))
+    fn append(&mut self, node: &Bound<Fp>) -> bool {
+        self.0.append(MerkleNode::from(node.borrow().deref().0))
     }
 
-    fn mark(&mut self) -> PyResult<u32> {
-        Ok(u64::from(self.0.mark().unwrap()) as u32)
+    fn mark(&mut self) -> u32 {
+        u64::from(self.0.mark().unwrap()) as u32
     }
 
-    fn root(&self, checkpoint_depth: usize) -> PyResult<Fp> {
+    fn root(&self, checkpoint_depth: usize) -> Fp {
         let root = self.0.root(checkpoint_depth).unwrap();
-        Ok(Fp(root.inner()))
+        Fp(root.inner())
     }
 
-    fn witness(&self, position: u32, checkpoint_depth: usize) -> PyResult<Vec<Fp>> {
+    fn witness(&self, position: u32, checkpoint_depth: usize) -> Vec<Fp> {
         let path = self.0.witness((position as u64).into(), checkpoint_depth).unwrap();
-        Ok(path.iter().map(|x| Fp(x.inner())).collect())
+        path.iter().map(|x| Fp(x.inner())).collect()
     }
 }
 

+ 2 - 2
src/sdk/python/src/pasta.rs

@@ -290,8 +290,8 @@ pub fn nullifier_k() -> EpAffine {
 
 #[pyfunction]
 /// Convert Fp to Fq safely.
-pub fn fp_mod_fv(x: &Bound<Fp>) -> PyResult<Fq> {
-    Ok(Fq(util::fp_mod_fv(x.borrow().deref().0)))
+pub fn fp_mod_fv(x: &Bound<Fp>) -> Fq {
+    Fq(util::fp_mod_fv(x.borrow().deref().0))
 }
 
 pub fn create_module(py: pyo3::Python<'_>) -> PyResult<Bound<PyModule>> {

+ 2 - 2
src/util/pcg.rs

@@ -39,7 +39,7 @@ impl Pcg32 {
         self.state = old_state.wrapping_mul(Self::MULTIPLIER).wrapping_add(self.increment);
         let xorshifted = ((old_state >> 18) ^ old_state) >> 27;
         let rot = old_state >> 59;
-        (xorshifted >> rot | xorshifted << ((!rot).wrapping_add(1) & 31)) as u32
+        ((xorshifted >> rot) | (xorshifted << ((!rot).wrapping_add(1) & 31))) as u32
     }
 }
 
@@ -51,7 +51,7 @@ impl RngCore for Pcg32 {
     }
 
     fn next_u64(&mut self) -> u64 {
-        (self.next_u32() as u64) << 32 | (self.next_u32() as u64)
+        ((self.next_u32() as u64) << 32) | (self.next_u32() as u64)
     }
 
     fn fill_bytes(&mut self, dest: &mut [u8]) {