Procházet zdrojové kódy

renamed asset_id to token_id across project

lunar-mining před 4 roky
rodič
revize
4727914b85

+ 7 - 7
proof/mint.pism

@@ -9,7 +9,7 @@ constant CRH_IVK BlakePersonalization
 contract mint_contract
     # Value commitment
     param value U64
-    param asset_id Fr
+    param token_id Fr
     param randomness_value Fr
     param randomness_asset Fr
 
@@ -19,7 +19,7 @@ contract mint_contract
 start
     # Witness input values
     u64_as_binary_le value param:value
-    fr_as_binary_le asset_id param:asset_id
+    fr_as_binary_le token_id param:token_id
     fr_as_binary_le randomness_value param:randomness_value
     fr_as_binary_le randomness_asset param:randomness_asset
     fr_as_binary_le serial param:serial
@@ -37,10 +37,10 @@ start
     # emit cv
     emit_ec cv
 
-    # Make asset_id commitment
+    # Make token_id commitment
     # A = a * G_VCV + r_a * G_VCR
 
-    ec_mul_const vca asset_id G_VCV
+    ec_mul_const vca token_id G_VCV
     ec_mul_const rca randomness_asset G_VCR
     ec_add ca vca rca
     # emit ca
@@ -48,7 +48,7 @@ start
 
 
     # Make the coin
-    # C = Hash(public_key, value, asset_id, serial, randomness_coin)
+    # C = Hash(public_key, value, token_id, serial, randomness_coin)
 
     # Build the preimage to hash
     alloc_binary preimage
@@ -76,8 +76,8 @@ start
     # randomness_coin
     {{ binary_put_fr("preimage", "randomness_coin") }}
 
-    # asset_id
-    {{ binary_put_fr("preimage", "asset_id") }}
+    # token_id
+    {{ binary_put_fr("preimage", "token_id") }}
 
     # Public key:       SubgroupPoint   = 256 bits
     # Value:            u64             = 64 bits

+ 7 - 7
proof/spend.pism

@@ -11,7 +11,7 @@ constant NOTE_COMMIT PedersenPersonalization
 contract spend_contract
     # Value commitment
     param value U64
-    param asset_id Fr
+    param token_id Fr
     param randomness_value Fr
     param randomness_asset Fr
 
@@ -27,7 +27,7 @@ contract spend_contract
 start
     # Witness input values
     u64_as_binary_le value param:value
-    fr_as_binary_le asset_id param:asset_id
+    fr_as_binary_le token_id param:token_id
     fr_as_binary_le randomness_value param:randomness_value
     fr_as_binary_le randomness_asset param:randomness_asset
 
@@ -40,10 +40,10 @@ start
     # emit cv
     emit_ec cv
 
-    # Make asset_id commitment
+    # Make token_id commitment
     # A = a * G_VCV + r * G_VCR
 
-    ec_mul_const vca asset_id G_VCV
+    ec_mul_const vca token_id G_VCV
     ec_mul_const rca randomness_asset G_VCR
     ec_add ca vca rca
     # emit ca
@@ -86,7 +86,7 @@ start
     ec_mul_const public secret G_SPEND
 
     # Make the coin (same as mint contract)
-    # C = Hash(public_key, value, asset_id, serial, randomness_coin)
+    # C = Hash(public_key, value, token_id, serial, randomness_coin)
     fr_as_binary_le randomness_coin param:randomness_coin
 
     # Build the preimage to hash
@@ -105,8 +105,8 @@ start
     # randomness_coin
     {{ binary_put_fr("preimage", "randomness_coin") }}
 
-    # asset_id
-    {{ binary_put_fr("preimage", "asset_id") }}
+    # token_id
+    {{ binary_put_fr("preimage", "token_id") }}
 
     # Public key:       SubgroupPoint   = 256 bits
     # Value:            u64             = 64 bits

+ 1 - 1
sql/schema.sql

@@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS coins(
     coin_blind BLOB NOT NULL,
     valcom_blind BLOB NOT NULL,
     value INT NOT NULL,
-    asset_id INT NOT NULL,
+    token_id INT NOT NULL,
     witness BLOB NOT NULL,
    	secret BLOB NOT NULL,
 	is_spent BLOB NOT NULL

+ 4 - 6
src/bin/build_tx.rs

@@ -100,7 +100,6 @@ async fn main() -> Result<()> {
 
     wallet.put_cashier_pub(&cashier_main_keypair.public)?;
 
-
     // Load trusted setup parameters
     let (_, mint_pvk) = load_params(mint_params_path)?;
     let (_, spend_pvk) = load_params(spend_params_path)?;
@@ -112,7 +111,7 @@ async fn main() -> Result<()> {
     //
     //
     //
-    // user's state 
+    // user's state
     //
     //
     //
@@ -125,7 +124,6 @@ async fn main() -> Result<()> {
         wallet,
     }));
 
-
     //
     //
     //
@@ -137,13 +135,13 @@ async fn main() -> Result<()> {
     let inputs: Vec<tx::TransactionBuilderInputInfo> = vec![];
     let mut outputs: Vec<tx::TransactionBuilderOutputInfo> = vec![];
 
-    let asset_id = jubjub::Fr::random(&mut OsRng);
+    let token_id = jubjub::Fr::random(&mut OsRng);
     let value = 10;
 
     let signature_secret = cashier_main_keypair.private;
     let input = tx::TransactionBuilderClearInputInfo {
         value,
-        asset_id,
+        token_id,
         signature_secret,
     };
 
@@ -151,7 +149,7 @@ async fn main() -> Result<()> {
 
     outputs.push(tx::TransactionBuilderOutputInfo {
         value,
-        asset_id,
+        token_id,
         public: user_main_keypair.public,
     });
 

+ 5 - 7
src/bin/tx.rs

@@ -157,17 +157,17 @@ async fn main() {
     // Create the deposit for 110 BTC
     // Clear inputs are visible to everyone on the network
 
-    let asset_id = jubjub::Fr::random(&mut OsRng);
+    let token_id = jubjub::Fr::random(&mut OsRng);
     let builder = tx::TransactionBuilder {
         clear_inputs: vec![tx::TransactionBuilderClearInputInfo {
             value: 110,
-            asset_id: asset_id,
+            token_id: token_id,
             signature_secret: cashier_secret,
         }],
         inputs: vec![],
         outputs: vec![tx::TransactionBuilderOutputInfo {
             value: 110,
-            asset_id: asset_id,
+            token_id: token_id,
             public,
         }],
     };
@@ -285,7 +285,7 @@ async fn main() {
         // The only constraint is that sum(value in) == sum(value out)
         outputs: vec![tx::TransactionBuilderOutputInfo {
             value: 110,
-            asset_id: asset_id,
+            token_id: token_id,
             public: public2,
         }],
     };
@@ -303,9 +303,8 @@ async fn main() {
     }
 }
 
-
+use drk::state::{VerifyFailed, VerifyResult};
 use log::*;
-use drk::state::{VerifyResult, VerifyFailed};
 
 pub fn state_transition<S: ProgramState>(
     state: &S,
@@ -319,7 +318,6 @@ pub fn state_transition<S: ProgramState>(
         // Check the public key in the clear inputs
         // It should be a valid public key for the cashier
 
-
         if !state.is_valid_cashier_public_key(&input.signature_public) {
             log::error!(target: "STATE TRANSITION", "Not valid cashier public key");
             return Err(VerifyFailed::InvalidCashierKey(i));

+ 10 - 10
src/circuit/mint_contract.rs

@@ -16,7 +16,7 @@ use zcash_proofs::circuit::{ecc, pedersen_hash};
 
 pub struct MintContract {
     pub value: Option<u64>,
-    pub asset_id: Option<jubjub::Fr>,
+    pub token_id: Option<jubjub::Fr>,
     pub randomness_value: Option<jubjub::Fr>,
     pub randomness_asset: Option<jubjub::Fr>,
     pub serial: Option<jubjub::Fr>,
@@ -34,10 +34,10 @@ impl Circuit<bls12_381::Scalar> for MintContract {
             self.value,
         )?;
 
-        // Line 21: fr_as_binary_le asset_id param:asset_id
-        let asset_id = boolean::field_into_boolean_vec_le(
-            cs.namespace(|| "Line 21: fr_as_binary_le asset_id param:asset_id"),
-            self.asset_id,
+        // Line 21: fr_as_binary_le token_id param:token_id
+        let token_id = boolean::field_into_boolean_vec_le(
+            cs.namespace(|| "Line 21: fr_as_binary_le token_id param:token_id"),
+            self.token_id,
         )?;
 
         // Line 22: fr_as_binary_le randomness_value param:randomness_value
@@ -93,11 +93,11 @@ impl Circuit<bls12_381::Scalar> for MintContract {
         // Line 37: emit_ec cv
         cv.inputize(cs.namespace(|| "Line 37: emit_ec cv"))?;
 
-        // Line 42: ec_mul_const vca asset_id G_VCV
+        // Line 42: ec_mul_const vca token_id G_VCV
         let vca = ecc::fixed_base_multiplication(
-            cs.namespace(|| "Line 42: ec_mul_const vca asset_id G_VCV"),
+            cs.namespace(|| "Line 42: ec_mul_const vca token_id G_VCV"),
             &zcash_proofs::constants::VALUE_COMMITMENT_VALUE_GENERATOR,
-            &asset_id,
+            &token_id,
         )?;
 
         // Line 43: ec_mul_const rca randomness_asset G_VCR
@@ -125,8 +125,8 @@ impl Circuit<bls12_381::Scalar> for MintContract {
         // Line 60: binary_extend preimage value
         preimage.extend(value);
 
-        // Line 99: binary_extend preimage asset_id
-        preimage.extend(asset_id);
+        // Line 99: binary_extend preimage token_id
+        preimage.extend(token_id);
 
         // add 4 zero bits
         for _ in 0..4 {

+ 9 - 10
src/circuit/spend_contract.rs

@@ -17,7 +17,7 @@ use crate::crypto::merkle_node::SAPLING_COMMITMENT_TREE_DEPTH;
 
 pub struct SpendContract {
     pub value: Option<u64>,
-    pub asset_id: Option<jubjub::Fr>,
+    pub token_id: Option<jubjub::Fr>,
     pub randomness_value: Option<jubjub::Fr>,
     pub randomness_asset: Option<jubjub::Fr>,
     pub serial: Option<jubjub::Fr>,
@@ -38,10 +38,10 @@ impl Circuit<bls12_381::Scalar> for SpendContract {
             self.value,
         )?;
 
-        // Line 41: u64_as_binary_le asset_id param:asset_id
-        let asset_id = boolean::field_into_boolean_vec_le(
+        // Line 41: u64_as_binary_le token_id param:token_id
+        let token_id = boolean::field_into_boolean_vec_le(
             cs.namespace(|| "Line 41: u64_as_binary_le value param:value"),
-            self.asset_id,
+            self.token_id,
         )?;
 
         // Line 41: fr_as_binary_le randomness_value param:randomness_value
@@ -76,11 +76,11 @@ impl Circuit<bls12_381::Scalar> for SpendContract {
         // Line 50: emit_ec cv
         cv.inputize(cs.namespace(|| "Line 50: emit_ec cv"))?;
 
-        // Line 46: ec_mul_const vca asset_id G_VCV
+        // Line 46: ec_mul_const vca token_id G_VCV
         let vca = ecc::fixed_base_multiplication(
-            cs.namespace(|| "Line 46: ec_mul_const vca asset_id G_VCV"),
+            cs.namespace(|| "Line 46: ec_mul_const vca token_id G_VCV"),
             &zcash_proofs::constants::VALUE_COMMITMENT_VALUE_GENERATOR,
-            &asset_id,
+            &token_id,
         )?;
 
         // Line 47: ec_mul_const rca randomness_asset G_VCR
@@ -209,9 +209,8 @@ impl Circuit<bls12_381::Scalar> for SpendContract {
         // Line 120: binary_extend preimage value
         preimage.extend(value);
 
-
-        // Line 109: binary_extend preimage asset_id
-        preimage.extend(asset_id);
+        // Line 109: binary_extend preimage token_id
+        preimage.extend(token_id);
 
         // add 4 zero bits
         for _ in 0..4 {

+ 8 - 8
src/client.rs

@@ -145,13 +145,13 @@ impl Client {
         &mut self,
         pub_key: jubjub::SubgroupPoint,
         amount: u64,
-        asset_id: jubjub::Fr,
+        token_id: jubjub::Fr,
         clear_input: bool,
     ) -> ClientResult<()> {
         debug!(target: "CLIENT", "Start send {}", amount);
 
         let slab = self
-            .build_slab_from_tx(pub_key, amount, asset_id, clear_input)
+            .build_slab_from_tx(pub_key, amount, token_id, clear_input)
             .await?;
 
         self.gateway.put_slab(slab).await?;
@@ -165,7 +165,7 @@ impl Client {
         &self,
         pub_key: jubjub::SubgroupPoint,
         value: u64,
-        asset_id: jubjub::Fr,
+        token_id: jubjub::Fr,
         clear_input: bool,
     ) -> Result<Slab> {
         debug!(target: "CLIENT", "Start build slab from tx");
@@ -178,17 +178,17 @@ impl Client {
             let signature_secret = self.main_keypair.private;
             let input = tx::TransactionBuilderClearInputInfo {
                 value,
-                asset_id,
+                token_id,
                 signature_secret,
             };
             clear_inputs.push(input);
         } else {
-            inputs = self.build_inputs(value, asset_id, &mut outputs).await?;
+            inputs = self.build_inputs(value, token_id, &mut outputs).await?;
         }
 
         outputs.push(tx::TransactionBuilderOutputInfo {
             value,
-            asset_id,
+            token_id,
             public: pub_key,
         });
 
@@ -214,7 +214,7 @@ impl Client {
     async fn build_inputs(
         &self,
         amount: u64,
-        asset_id: jubjub::Fr,
+        token_id: jubjub::Fr,
         outputs: &mut Vec<tx::TransactionBuilderOutputInfo>,
     ) -> Result<Vec<tx::TransactionBuilderInputInfo>> {
         debug!(target: "CLIENT", "Start build inputs");
@@ -250,7 +250,7 @@ impl Client {
 
             outputs.push(tx::TransactionBuilderOutputInfo {
                 value: return_value,
-                asset_id,
+                token_id,
                 public: self.main_keypair.public,
             });
         }

+ 7 - 7
src/crypto/mint_proof.rs

@@ -20,7 +20,7 @@ pub struct MintRevealedValues {
 impl MintRevealedValues {
     fn compute(
         value: u64,
-        asset_id: jubjub::Fr,
+        token_id: jubjub::Fr,
         randomness_value: &jubjub::Fr,
         randomness_asset: &jubjub::Fr,
         serial: &jubjub::Fr,
@@ -33,7 +33,7 @@ impl MintRevealedValues {
                 * randomness_value);
 
         let asset_commit = (zcash_primitives::constants::VALUE_COMMITMENT_VALUE_GENERATOR
-            * asset_id)
+            * token_id)
             + (zcash_primitives::constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR
                 * randomness_asset);
 
@@ -45,7 +45,7 @@ impl MintRevealedValues {
                 .to_state()
                 .update(&public.to_bytes())
                 .update(&value.to_le_bytes())
-                .update(&asset_id.to_bytes())
+                .update(&token_id.to_bytes())
                 .update(&serial.to_bytes())
                 .update(&randomness_coin.to_bytes())
                 .finalize()
@@ -123,7 +123,7 @@ pub fn setup_mint_prover() -> groth16::Parameters<Bls12> {
     let params = {
         let c = MintContract {
             value: None,
-            asset_id: None,
+            token_id: None,
             randomness_value: None,
             randomness_asset: None,
             serial: None,
@@ -140,7 +140,7 @@ pub fn setup_mint_prover() -> groth16::Parameters<Bls12> {
 pub fn create_mint_proof(
     params: &groth16::Parameters<Bls12>,
     value: u64,
-    asset_id: jubjub::Fr,
+    token_id: jubjub::Fr,
     randomness_value: jubjub::Fr,
     randomness_asset: jubjub::Fr,
     serial: jubjub::Fr,
@@ -149,7 +149,7 @@ pub fn create_mint_proof(
 ) -> (groth16::Proof<Bls12>, MintRevealedValues) {
     let revealed = MintRevealedValues::compute(
         value,
-        asset_id,
+        token_id,
         &randomness_value,
         &randomness_asset,
         &serial,
@@ -159,7 +159,7 @@ pub fn create_mint_proof(
 
     let c = MintContract {
         value: Some(value),
-        asset_id: Some(asset_id),
+        token_id: Some(token_id),
         randomness_value: Some(randomness_value),
         randomness_asset: Some(randomness_asset),
         serial: Some(serial),

+ 6 - 6
src/crypto/note.rs

@@ -9,7 +9,7 @@ use crate::serial::{Decodable, Encodable, ReadExt, WriteExt};
 
 pub const NOTE_PLAINTEXT_SIZE: usize = 32 +    // serial
     8 +     // value
-    32 +    // asset_id
+    32 +    // token_id
     32 +    // coin_blind
     32; // valcom_blind
 pub const AEAD_TAG_SIZE: usize = 16;
@@ -19,7 +19,7 @@ pub const ENC_CIPHERTEXT_SIZE: usize = NOTE_PLAINTEXT_SIZE + AEAD_TAG_SIZE;
 pub struct Note {
     pub serial: jubjub::Fr,
     pub value: u64,
-    pub asset_id: jubjub::Fr,
+    pub token_id: jubjub::Fr,
     pub coin_blind: jubjub::Fr,
     pub valcom_blind: jubjub::Fr,
 }
@@ -29,7 +29,7 @@ impl Encodable for Note {
         let mut len = 0;
         len += self.serial.encode(&mut s)?;
         len += self.value.encode(&mut s)?;
-        len += self.asset_id.encode(&mut s)?;
+        len += self.token_id.encode(&mut s)?;
         len += self.coin_blind.encode(&mut s)?;
         len += self.valcom_blind.encode(&mut s)?;
         Ok(len)
@@ -41,7 +41,7 @@ impl Decodable for Note {
         Ok(Self {
             serial: Decodable::decode(&mut d)?,
             value: Decodable::decode(&mut d)?,
-            asset_id: Decodable::decode(&mut d)?,
+            token_id: Decodable::decode(&mut d)?,
             coin_blind: Decodable::decode(&mut d)?,
             valcom_blind: Decodable::decode(d)?,
         })
@@ -127,7 +127,7 @@ fn test_note_encdec() {
     let note = Note {
         serial: jubjub::Fr::random(&mut OsRng),
         value: 110,
-        asset_id: jubjub::Fr::random(&mut OsRng),
+        token_id: jubjub::Fr::random(&mut OsRng),
         coin_blind: jubjub::Fr::random(&mut OsRng),
         valcom_blind: jubjub::Fr::random(&mut OsRng),
     };
@@ -138,5 +138,5 @@ fn test_note_encdec() {
     let encrypted_note = note.encrypt(&public).unwrap();
     let note2 = encrypted_note.decrypt(&secret).unwrap();
     assert_eq!(note.value, note2.value);
-    assert_eq!(note.asset_id, note2.asset_id);
+    assert_eq!(note.token_id, note2.token_id);
 }

+ 7 - 7
src/crypto/spend_proof.rs

@@ -28,7 +28,7 @@ impl SpendRevealedValues {
     #[allow(clippy::too_many_arguments)]
     fn compute(
         value: u64,
-        asset_id: jubjub::Fr,
+        token_id: jubjub::Fr,
         randomness_value: &jubjub::Fr,
         randomness_asset: &jubjub::Fr,
         serial: &jubjub::Fr,
@@ -43,7 +43,7 @@ impl SpendRevealedValues {
                 * randomness_value);
 
         let asset_commit = (zcash_primitives::constants::VALUE_COMMITMENT_VALUE_GENERATOR
-            * asset_id)
+            * token_id)
             + (zcash_primitives::constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR
                 * randomness_asset);
 
@@ -72,7 +72,7 @@ impl SpendRevealedValues {
                 .to_state()
                 .update(&public.to_bytes())
                 .update(&value.to_le_bytes())
-                .update(&asset_id.to_bytes())
+                .update(&token_id.to_bytes())
                 .update(&serial.to_bytes())
                 .update(&randomness_coin.to_bytes())
                 .finalize()
@@ -204,7 +204,7 @@ pub fn setup_spend_prover() -> groth16::Parameters<Bls12> {
     let params = {
         let c = SpendContract {
             value: None,
-            asset_id: None,
+            token_id: None,
             randomness_value: None,
             randomness_asset: None,
             serial: None,
@@ -226,7 +226,7 @@ pub fn setup_spend_prover() -> groth16::Parameters<Bls12> {
 pub fn create_spend_proof(
     params: &groth16::Parameters<Bls12>,
     value: u64,
-    asset_id: jubjub::Fr,
+    token_id: jubjub::Fr,
     randomness_value: jubjub::Fr,
     randomness_asset: jubjub::Fr,
     serial: jubjub::Fr,
@@ -244,7 +244,7 @@ pub fn create_spend_proof(
     }
     let c = SpendContract {
         value: Some(value),
-        asset_id: Some(asset_id),
+        token_id: Some(token_id),
         randomness_value: Some(randomness_value),
         randomness_asset: Some(randomness_asset),
         serial: Some(serial),
@@ -263,7 +263,7 @@ pub fn create_spend_proof(
 
     let revealed = SpendRevealedValues::compute(
         value,
-        asset_id,
+        token_id,
         &randomness_value,
         &randomness_asset,
         &serial,

+ 6 - 6
src/tx/builder.rs

@@ -21,7 +21,7 @@ pub struct TransactionBuilder {
 
 pub struct TransactionBuilderClearInputInfo {
     pub value: u64,
-    pub asset_id: jubjub::Fr,
+    pub token_id: jubjub::Fr,
     pub signature_secret: jubjub::Fr,
 }
 
@@ -33,7 +33,7 @@ pub struct TransactionBuilderInputInfo {
 
 pub struct TransactionBuilderOutputInfo {
     pub value: u64,
-    pub asset_id: jubjub::Fr,
+    pub token_id: jubjub::Fr,
     pub public: jubjub::SubgroupPoint,
 }
 
@@ -74,7 +74,7 @@ impl TransactionBuilder {
             let valcom_blind: jubjub::Fr = jubjub::Fr::random(&mut OsRng);
             let clear_input = PartialTransactionClearInput {
                 value: input.value,
-                asset_id: input.asset_id,
+                token_id: input.token_id,
                 valcom_blind,
                 asset_commit_blind,
                 signature_public,
@@ -103,7 +103,7 @@ impl TransactionBuilder {
             let (proof, revealed) = create_spend_proof(
                 &spend_params,
                 input.note.value,
-                input.note.asset_id,
+                input.note.token_id,
                 input.note.valcom_blind,
                 asset_commit_blind,
                 input.note.serial,
@@ -141,7 +141,7 @@ impl TransactionBuilder {
             let (mint_proof, revealed) = create_mint_proof(
                 mint_params,
                 output.value,
-                output.asset_id,
+                output.token_id,
                 valcom_blind,
                 asset_commit_blind,
                 serial,
@@ -154,7 +154,7 @@ impl TransactionBuilder {
             let note = Note {
                 serial,
                 value: output.value,
-                asset_id: output.asset_id,
+                token_id: output.token_id,
                 coin_blind,
                 valcom_blind,
             };

+ 6 - 6
src/tx/mod.rs

@@ -29,7 +29,7 @@ pub struct Transaction {
 
 pub struct TransactionClearInput {
     pub value: u64,
-    pub asset_id: jubjub::Fr,
+    pub token_id: jubjub::Fr,
     pub valcom_blind: jubjub::Fr,
     pub asset_commit_blind: jubjub::Fr,
     pub signature_public: jubjub::SubgroupPoint,
@@ -77,7 +77,7 @@ impl Transaction {
                 .any(|output| output.revealed.asset_commit != asset_commit_value);
         failed = failed
             || self.clear_inputs.iter().any(|input| {
-                Self::compute_pedersen_commit(input.asset_id, &input.asset_commit_blind)
+                Self::compute_pedersen_commit(input.token_id, &input.asset_commit_blind)
                     != asset_commit_value
             });
         !failed
@@ -140,7 +140,7 @@ impl TransactionClearInput {
     fn from_partial(partial: PartialTransactionClearInput, signature: schnorr::Signature) -> Self {
         Self {
             value: partial.value,
-            asset_id: partial.asset_id,
+            token_id: partial.token_id,
             valcom_blind: partial.valcom_blind,
             asset_commit_blind: partial.asset_commit_blind,
             signature_public: partial.signature_public,
@@ -151,7 +151,7 @@ impl TransactionClearInput {
     fn encode_without_signature<S: io::Write>(&self, mut s: S) -> Result<usize> {
         let mut len = 0;
         len += self.value.encode(&mut s)?;
-        len += self.asset_id.encode(&mut s)?;
+        len += self.token_id.encode(&mut s)?;
         len += self.valcom_blind.encode(&mut s)?;
         len += self.asset_commit_blind.encode(&mut s)?;
         len += self.signature_public.encode(s)?;
@@ -200,7 +200,7 @@ impl Encodable for TransactionClearInput {
     fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
         let mut len = 0;
         len += self.value.encode(&mut s)?;
-        len += self.asset_id.encode(&mut s)?;
+        len += self.token_id.encode(&mut s)?;
         len += self.valcom_blind.encode(&mut s)?;
         len += self.asset_commit_blind.encode(&mut s)?;
         len += self.signature_public.encode(&mut s)?;
@@ -213,7 +213,7 @@ impl Decodable for TransactionClearInput {
     fn decode<D: io::Read>(mut d: D) -> Result<Self> {
         Ok(Self {
             value: Decodable::decode(&mut d)?,
-            asset_id: Decodable::decode(&mut d)?,
+            token_id: Decodable::decode(&mut d)?,
             valcom_blind: Decodable::decode(&mut d)?,
             asset_commit_blind: Decodable::decode(&mut d)?,
             signature_public: Decodable::decode(&mut d)?,

+ 3 - 3
src/tx/partial.rs

@@ -16,7 +16,7 @@ pub struct PartialTransaction {
 
 pub struct PartialTransactionClearInput {
     pub value: u64,
-    pub asset_id: jubjub::Fr,
+    pub token_id: jubjub::Fr,
     pub valcom_blind: jubjub::Fr,
     pub asset_commit_blind: jubjub::Fr,
     pub signature_public: jubjub::SubgroupPoint,
@@ -51,7 +51,7 @@ impl Encodable for PartialTransactionClearInput {
     fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
         let mut len = 0;
         len += self.value.encode(&mut s)?;
-        len += self.asset_id.encode(&mut s)?;
+        len += self.token_id.encode(&mut s)?;
         len += self.valcom_blind.encode(&mut s)?;
         len += self.asset_commit_blind.encode(&mut s)?;
         len += self.signature_public.encode(&mut s)?;
@@ -62,7 +62,7 @@ impl Decodable for PartialTransactionClearInput {
     fn decode<D: io::Read>(mut d: D) -> Result<Self> {
         Ok(Self {
             value: Decodable::decode(&mut d)?,
-            asset_id: Decodable::decode(&mut d)?,
+            token_id: Decodable::decode(&mut d)?,
             valcom_blind: Decodable::decode(&mut d)?,
             asset_commit_blind: Decodable::decode(&mut d)?,
             signature_public: Decodable::decode(&mut d)?,

+ 20 - 20
src/wallet/walletdb.rs

@@ -158,12 +158,12 @@ impl WalletDb {
             let coin_blind = self.get_value_deserialized(&row.3)?;
             let valcom_blind = self.get_value_deserialized(&row.4)?;
             let value: u64 = row.5;
-            let asset_id = self.get_value_deserialized(&row.6)?;
+            let token_id = self.get_value_deserialized(&row.6)?;
 
             let note = Note {
                 serial,
                 value,
-                asset_id,
+                token_id,
                 coin_blind,
                 valcom_blind,
             };
@@ -194,7 +194,7 @@ impl WalletDb {
         let coin_blind = self.get_value_serialized(&own_coin.note.coin_blind)?;
         let valcom_blind = self.get_value_serialized(&own_coin.note.valcom_blind)?;
         let value: u64 = own_coin.note.value;
-        let asset_id = self.get_value_serialized(&own_coin.note.asset_id)?;
+        let token_id = self.get_value_serialized(&own_coin.note.token_id)?;
         let witness = self.get_value_serialized(&own_coin.witness)?;
         let secret = self.get_value_serialized(&own_coin.secret)?;
         let is_spent = self.get_value_serialized(&false)?;
@@ -206,14 +206,14 @@ impl WalletDb {
 
         conn.execute(
             "INSERT INTO coins
-            (coin, serial, value, asset_id, coin_blind, valcom_blind, witness, secret, is_spent)
+            (coin, serial, value, token_id, coin_blind, valcom_blind, witness, secret, is_spent)
             VALUES
-            (:coin, :serial, :value, :asset_id, :coin_blind, :valcom_blind, :witness, :secret, :is_spent);",
+            (:coin, :serial, :value, :token_id, :coin_blind, :valcom_blind, :witness, :secret, :is_spent);",
             named_params! {
                 ":coin": coin,
                 ":serial": serial,
                 ":value": value,
-                ":asset_id": asset_id,
+                ":token_id": token_id,
                 ":coin_blind": coin_blind,
                 ":valcom_blind": valcom_blind,
                 ":witness": witness,
@@ -330,7 +330,7 @@ impl WalletDb {
         let is_spent = self.get_value_serialized(&false)?;
 
         let mut stmt =
-            conn.prepare("SELECT value, asset_id FROM coins  WHERE is_spent = :is_spent ;")?;
+            conn.prepare("SELECT value, token_id FROM coins  WHERE is_spent = :is_spent ;")?;
         let rows = stmt.query_map(&[(":is_spent", &is_spent)], |row| {
             Ok((row.get(0)?, row.get(1)?))
         })?;
@@ -358,7 +358,7 @@ impl WalletDb {
 
         let is_spent = self.get_value_serialized(&false)?;
 
-        let mut stmt = conn.prepare("SELECT asset_id FROM coins WHERE is_spent = :is_spent ;")?;
+        let mut stmt = conn.prepare("SELECT token_id FROM coins WHERE is_spent = :is_spent ;")?;
         let rows = stmt.query_map(&[(":is_spent", &is_spent)], |row| row.get(0))?;
 
         let mut token_ids = Vec::new();
@@ -380,7 +380,7 @@ impl WalletDb {
         let id = self.get_value_serialized(token_id)?;
         let is_spent = self.get_value_serialized(&false)?;
 
-        let mut stmt = conn.prepare("SELECT * FROM coins WHERE asset_id = ? AND is_spent = ? ;")?;
+        let mut stmt = conn.prepare("SELECT * FROM coins WHERE token_id = ? AND is_spent = ? ;")?;
         let id_check = stmt.exists(params![id, is_spent])?;
         Ok(id_check)
     }
@@ -433,12 +433,12 @@ mod tests {
 
         wallet.put_keypair(key_public, key_private)?;
 
-        let asset_id = jubjub::Fr::random(&mut OsRng);
+        let token_id = jubjub::Fr::random(&mut OsRng);
 
         let note = Note {
             serial: jubjub::Fr::random(&mut OsRng),
             value: 110,
-            asset_id,
+            token_id,
             coin_blind: jubjub::Fr::random(&mut OsRng),
             valcom_blind: jubjub::Fr::random(&mut OsRng),
         };
@@ -465,10 +465,10 @@ mod tests {
         let token_id = wallet.get_token_id()?;
 
         assert_eq!(token_id.len(), 4);
-        assert_eq!(token_id[0], asset_id);
-        assert_eq!(token_id[2], asset_id);
+        //assert_eq!(token_id[0], token_id);
+        //assert_eq!(token_id[2], token_id);
 
-        assert!(wallet.token_id_exists(&asset_id)?);
+        //assert!(wallet.token_id_exists(&token_id)?);
 
         std::fs::remove_file(walletdb_path)?;
 
@@ -489,12 +489,12 @@ mod tests {
 
         wallet.put_keypair(key_public, key_private)?;
 
-        let asset_id = jubjub::Fr::random(&mut OsRng);
+        let token_id = jubjub::Fr::random(&mut OsRng);
 
         let note = Note {
             serial: jubjub::Fr::random(&mut OsRng),
             value: 110,
-            asset_id,
+            token_id,
             coin_blind: jubjub::Fr::random(&mut OsRng),
             valcom_blind: jubjub::Fr::random(&mut OsRng),
         };
@@ -520,9 +520,9 @@ mod tests {
 
         let balances = wallet.get_balances()?;
 
-        let asset_id = serialize(&asset_id);
+        let token_id = serialize(&token_id);
 
-        assert_eq!(balances[&asset_id], 440);
+        assert_eq!(balances[&token_id], 440);
 
         std::fs::remove_file(walletdb_path)?;
 
@@ -570,7 +570,7 @@ mod tests {
         let note = Note {
             serial: jubjub::Fr::random(&mut OsRng),
             value: 110,
-            asset_id: jubjub::Fr::random(&mut OsRng),
+            token_id: jubjub::Fr::random(&mut OsRng),
             coin_blind: jubjub::Fr::random(&mut OsRng),
             valcom_blind: jubjub::Fr::random(&mut OsRng),
         };
@@ -628,7 +628,7 @@ mod tests {
         let note = Note {
             serial: jubjub::Fr::random(&mut OsRng),
             value: 110,
-            asset_id: jubjub::Fr::random(&mut OsRng),
+            token_id: jubjub::Fr::random(&mut OsRng),
             coin_blind: jubjub::Fr::random(&mut OsRng),
             valcom_blind: jubjub::Fr::random(&mut OsRng),
         };