Răsfoiți Sursa

Remove traces of pasta_curves crate from files where they shouldn't be.

parazyd 4 ani în urmă
părinte
comite
1227018081
8 a modificat fișierele cu 20 adăugiri și 19 ștergeri
  1. 3 3
      src/bin/darkfid.rs
  2. 4 3
      src/bin/tx.rs
  3. 6 6
      src/client.rs
  4. 1 1
      src/crypto/coin.rs
  5. 2 2
      src/crypto/keypair.rs
  6. 1 1
      src/crypto/mod.rs
  7. 1 1
      src/crypto/note.rs
  8. 2 2
      src/state.rs

+ 3 - 3
src/bin/darkfid.rs

@@ -8,7 +8,6 @@ use easy_parallel::Parallel;
 use incrementalmerkletree::bridgetree::BridgeTree;
 use log::{debug, info};
 use num_bigint::BigUint;
-use pasta_curves::pallas;
 use serde_json::{json, Value};
 use url::Url;
 
@@ -27,6 +26,7 @@ use drk::{
     },
     serial::{deserialize, serialize},
     state::{ProgramState, State},
+    types::DrkTokenId,
     util::{
         assign_id, decode_base10, encode_base10, expand_path, join_config_path, DrkTokenList,
         NetworkName, TokenList,
@@ -411,7 +411,7 @@ impl Darkfid {
             Err(e) => return JsonResult::Err(jsonerr(ServerError(-32004), Some(e.to_string()), id)),
         }
 
-        let token_id: &pallas::Base;
+        let token_id: &DrkTokenId;
 
         if let Some(tk_id) = self.drk_tokenlist.tokens[&network].get(&token.to_uppercase()) {
             token_id = tk_id;
@@ -498,7 +498,7 @@ impl Darkfid {
             (_, _, _, None) => return JsonResult::Err(jsonerr(InvalidAmountParam, None, id)),
         }
 
-        let token_id: &pallas::Base;
+        let token_id: &DrkTokenId;
 
         // get the id for the token
         if let Some(tk_id) = self.drk_tokenlist.tokens[&network].get(&token.to_uppercase()) {

+ 4 - 3
src/bin/tx.rs

@@ -1,5 +1,4 @@
 use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Tree};
-use pasta_curves::pallas;
 use rand::rngs::OsRng;
 
 use drk::{
@@ -13,7 +12,9 @@ use drk::{
         proof::{ProvingKey, VerifyingKey},
     },
     state::{state_transition, ProgramState, StateUpdate},
-    tx, Result,
+    tx,
+    types::DrkTokenId,
+    Result,
 };
 
 struct MemoryState {
@@ -117,7 +118,7 @@ fn main() -> Result<()> {
         secrets: vec![keypair.secret],
     };
 
-    let token_id = pallas::Base::from(110);
+    let token_id = DrkTokenId::from(110);
 
     let builder = tx::TransactionBuilder {
         clear_inputs: vec![tx::TransactionBuilderClearInputInfo {

+ 6 - 6
src/client.rs

@@ -1,7 +1,6 @@
 use async_std::sync::{Arc, Mutex};
 use incrementalmerkletree::Tree;
 use log::{debug, info, warn};
-use pasta_curves::pallas;
 use smol::Executor;
 use url::Url;
 
@@ -19,6 +18,7 @@ use crate::{
     service::GatewayClient,
     state::{state_transition, State},
     tx,
+    types::DrkTokenId,
     wallet::{
         cashierdb::CashierDbPtr,
         walletdb::{Balances, WalletPtr},
@@ -98,7 +98,9 @@ impl Client {
         let gateway = GatewayClient::new(gateway_addrs.0, gateway_addrs.1, slabstore)?;
 
         // TODO: These should go to a better place.
+        debug!("Building proving key for the mint contract...");
         let mint_pk = ProvingKey::build(11, MintContract::default());
+        debug!("Building proving key for the spend contract...");
         let spend_pk = ProvingKey::build(11, SpendContract::default());
 
         let client = Client { main_keypair, gateway, wallet, mint_pk, spend_pk };
@@ -113,7 +115,7 @@ impl Client {
         &mut self,
         pubkey: PublicKey,
         value: u64,
-        token_id: pallas::Base,
+        token_id: DrkTokenId,
         clear_input: bool,
         state: Arc<Mutex<State>>,
     ) -> ClientResult<Vec<Coin>> {
@@ -126,8 +128,6 @@ impl Client {
         if clear_input {
             // TODO: FIXME:
             let signature_secret = self.main_keypair.clone().secret;
-            let signature_public = PublicKey::from_secret(signature_secret);
-            debug!("SIGNATURE PUBLIC: {:?}", signature_public);
             let input = tx::TransactionBuilderClearInputInfo { value, token_id, signature_secret };
             clear_inputs.push(input);
         } else {
@@ -200,7 +200,7 @@ impl Client {
         &mut self,
         pubkey: PublicKey,
         amount: u64,
-        token_id: pallas::Base,
+        token_id: DrkTokenId,
         clear_input: bool,
         state: Arc<Mutex<State>>,
     ) -> ClientResult<()> {
@@ -222,7 +222,7 @@ impl Client {
 
     pub async fn transfer(
         &mut self,
-        token_id: pallas::Base,
+        token_id: DrkTokenId,
         pubkey: PublicKey,
         amount: u64,
         state: Arc<Mutex<State>>,

+ 1 - 1
src/crypto/coin.rs

@@ -7,7 +7,7 @@ use crate::{
     Result,
 };
 
-#[derive(Clone, Copy, Debug)]
+#[derive(Clone, Copy, PartialEq, Debug)]
 pub struct Coin(pub pallas::Base);
 
 impl Coin {

+ 2 - 2
src/crypto/keypair.rs

@@ -14,7 +14,7 @@ use crate::{
     Error, Result,
 };
 
-#[derive(Copy, Clone, Debug)]
+#[derive(Copy, Clone, PartialEq, Debug)]
 pub struct Keypair {
     pub secret: SecretKey,
     pub public: PublicKey,
@@ -32,7 +32,7 @@ impl Keypair {
     }
 }
 
-#[derive(Copy, Clone, Debug)]
+#[derive(Copy, Clone, PartialEq, Debug)]
 pub struct SecretKey(pub pallas::Base);
 
 impl SecretKey {

+ 1 - 1
src/crypto/mod.rs

@@ -18,7 +18,7 @@ pub(crate) use spend_proof::SpendRevealedValues;
 
 use keypair::SecretKey;
 
-#[derive(Clone)]
+#[derive(Copy, Clone, Debug, PartialEq)]
 pub struct OwnCoin {
     pub coin: coin::Coin,
     pub note: note::Note,

+ 1 - 1
src/crypto/note.rs

@@ -21,7 +21,7 @@ pub const NOTE_PLAINTEXT_SIZE: usize = 32 +    // serial
 pub const AEAD_TAG_SIZE: usize = 16;
 pub const ENC_CIPHERTEXT_SIZE: usize = NOTE_PLAINTEXT_SIZE + AEAD_TAG_SIZE;
 
-#[derive(Clone)]
+#[derive(Copy, Clone, Debug, PartialEq)]
 pub struct Note {
     pub serial: DrkSerial,
     pub value: u64,

+ 2 - 2
src/state.rs

@@ -88,9 +88,9 @@ pub fn state_transition<S: ProgramState>(state: &S, tx: Transaction) -> VerifyRe
         }
     }
 
-    debug!(target: "STATE TRANSITION", "Check the tx Verifies correctly");
-    // Check the tx verifies correctly
+    debug!(target: "STATE TRANSITION", "Check the tx verifies correctly");
     tx.verify(state.mint_vk(), state.spend_vk())?;
+    debug!(target: "STATE TRANSITION", "Verified successfully");
 
     let mut nullifiers = vec![];
     for input in tx.inputs {