Browse Source

sdk-py: Fix import errors

freerangedev 3 years ago
parent
commit
533594bbab

+ 5 - 4
src/sdk/src/sdk-py/Cargo.toml

@@ -14,8 +14,9 @@ name = "darkfi_sdk_py"
 crate-type = ["cdylib"]
 crate-type = ["cdylib"]
 
 
 [dependencies]
 [dependencies]
-pyo3 = "0.19.0"
-darkfi-sdk = { path = "../../../sdk" }
-rand = "0.8.5"
-halo2_gadgets = "0.3.0"
 darkfi = { path = "../../../../", features = ["zk", "zkas"] }
 darkfi = { path = "../../../../", features = ["zk", "zkas"] }
+darkfi-sdk = { path = "../../" }
+halo2_gadgets = "0.3.0"
+pasta_curves = "0.5.1"
+pyo3 = "0.19.0"
+rand = "0.8.5"

+ 1 - 1
src/sdk/src/sdk-py/src/affine.rs

@@ -17,7 +17,7 @@
  */
  */
 
 
 use crate::base::Base;
 use crate::base::Base;
-use darkfi_sdk::{crypto::pallas, pasta::arithmetic::CurveAffine};
+use pasta_curves::{arithmetic::CurveAffine, pallas};
 use pyo3::prelude::*;
 use pyo3::prelude::*;
 
 
 /// A Pallas point in the affine coordinate space (or the point at infinity).
 /// A Pallas point in the affine coordinate space (or the point at infinity).

+ 6 - 7
src/sdk/src/sdk-py/src/base.rs

@@ -17,13 +17,12 @@
  */
  */
 
 
 use darkfi_sdk::{
 use darkfi_sdk::{
-    crypto::{
-        pallas,
-        pasta_prelude::{Field, PrimeField},
-        poseidon_hash, MerkleNode,
-    },
-    incrementalmerkletree::Hashable,
-    pasta::group::ff::FromUniformBytes,
+    bridgetree::Hashable,
+    crypto::{poseidon_hash, MerkleNode},
+};
+use pasta_curves::{
+    group::ff::{Field, FromUniformBytes, PrimeField},
+    pallas,
 };
 };
 use pyo3::prelude::*;
 use pyo3::prelude::*;
 use rand::rngs::OsRng;
 use rand::rngs::OsRng;

+ 4 - 7
src/sdk/src/sdk-py/src/point.rs

@@ -19,14 +19,10 @@
 use crate::{affine::Affine, base::Base, scalar::Scalar};
 use crate::{affine::Affine, base::Base, scalar::Scalar};
 use darkfi_sdk::{
 use darkfi_sdk::{
     crypto::{
     crypto::{
-        constants::{
-            fixed_bases::{
-                VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_R_BYTES,
-                VALUE_COMMITMENT_V_BYTES,
-            },
-            NullifierK,
+        constants::fixed_bases::{
+            NullifierK, VALUE_COMMITMENT_PERSONALIZATION, VALUE_COMMITMENT_R_BYTES,
+            VALUE_COMMITMENT_V_BYTES,
         },
         },
-        pallas,
         util::mod_r_p,
         util::mod_r_p,
         ValueCommit,
         ValueCommit,
     },
     },
@@ -36,6 +32,7 @@ use darkfi_sdk::{
     },
     },
 };
 };
 use halo2_gadgets::ecc::chip::FixedPoint;
 use halo2_gadgets::ecc::chip::FixedPoint;
+use pasta_curves::pallas;
 use pyo3::prelude::*;
 use pyo3::prelude::*;
 use std::ops::{Add, Mul};
 use std::ops::{Add, Mul};
 
 

+ 1 - 1
src/sdk/src/sdk-py/src/proof.rs

@@ -20,7 +20,7 @@ use crate::{
     base::Base, proving_key::ProvingKey, verifying_key::VerifyingKey, zk_circuit::ZkCircuit,
     base::Base, proving_key::ProvingKey, verifying_key::VerifyingKey, zk_circuit::ZkCircuit,
 };
 };
 use darkfi::zk::{proof, vm};
 use darkfi::zk::{proof, vm};
-use darkfi_sdk::crypto::pallas;
+use pasta_curves::pallas;
 use pyo3::prelude::*;
 use pyo3::prelude::*;
 use rand::rngs::OsRng;
 use rand::rngs::OsRng;
 use std::ops::Deref;
 use std::ops::Deref;

+ 2 - 4
src/sdk/src/sdk-py/src/scalar.rs

@@ -16,10 +16,8 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
  */
 
 
-use darkfi_sdk::crypto::{
-    pallas,
-    pasta_prelude::{Field, PrimeField},
-};
+use darkfi_sdk::crypto::pasta_prelude::{Field, PrimeField};
+use pasta_curves::pallas;
 use pyo3::prelude::*;
 use pyo3::prelude::*;
 use rand::rngs::OsRng;
 use rand::rngs::OsRng;
 
 

+ 1 - 1
src/sdk/src/sdk-py/src/zk_binary.rs

@@ -58,7 +58,7 @@ impl ZkBinary {
                 let opcode = format!("{opcode_:?}");
                 let opcode = format!("{opcode_:?}");
                 let args = args_
                 let args = args_
                     .iter()
                     .iter()
-                    .map(|(heap_type, heap_idx)| (format!("{heap_type:?}"), heap_idx.clone()))
+                    .map(|(heap_type, heap_idx)| (format!("{heap_type:?}"), *heap_idx))
                     .collect();
                     .collect();
                 (opcode, args)
                 (opcode, args)
             })
             })

+ 2 - 2
src/sdk/src/sdk-py/src/zk_circuit.rs

@@ -32,13 +32,13 @@ impl ZkCircuit {
     fn new(circuit_code: &PyCell<ZkBinary>) -> Self {
     fn new(circuit_code: &PyCell<ZkBinary>) -> Self {
         let circuit_code = circuit_code.borrow().deref().0.clone();
         let circuit_code = circuit_code.borrow().deref().0.clone();
         // DUMMY CIRCUIT
         // DUMMY CIRCUIT
-        let circuit = vm::ZkCircuit::new(vec![], circuit_code.clone());
+        let circuit = vm::ZkCircuit::new(vec![], circuit_code);
         Self(circuit, vec![])
         Self(circuit, vec![])
     }
     }
 
 
     fn build(&self, circuit_code: &PyCell<ZkBinary>) -> Self {
     fn build(&self, circuit_code: &PyCell<ZkBinary>) -> Self {
         let circuit_code = circuit_code.borrow().deref().0.clone();
         let circuit_code = circuit_code.borrow().deref().0.clone();
-        let circuit = vm::ZkCircuit::new(self.1.clone(), circuit_code.clone());
+        let circuit = vm::ZkCircuit::new(self.1.clone(), circuit_code);
         Self(circuit, self.1.clone())
         Self(circuit, self.1.clone())
     }
     }