Просмотр исходного кода

crypto: Introduce type aliases.

parazyd 4 лет назад
Родитель
Сommit
9faae1ab25
2 измененных файлов с 22 добавлено и 1 удалено
  1. 2 1
      src/crypto/mod.rs
  2. 20 0
      src/crypto/types.rs

+ 2 - 1
src/crypto/mod.rs

@@ -8,6 +8,7 @@ pub mod note;
 pub mod nullifier;
 pub mod schnorr;
 pub mod spend_proof;
+pub mod types;
 pub mod util;
 
 use bellman::groth16;
@@ -25,7 +26,7 @@ pub struct OwnCoin {
     pub note: note::Note,
     pub secret: jubjub::Fr,
     pub witness: merkle::IncrementalWitness<merkle_node::MerkleNode>,
-    pub nullifier: nullifier::Nullifier 
+    pub nullifier: nullifier::Nullifier,
 }
 
 pub type OwnCoins = Vec<OwnCoin>;

+ 20 - 0
src/crypto/types.rs

@@ -0,0 +1,20 @@
+//! Type aliases used in the codebase.
+// Helpful for changing the curve and crypto we're using.
+
+pub type PublicKey = jubjub::SubgroupPoint;
+
+pub type SecretKey = jubjub::Fr;
+
+pub fn derive_publickey(secret: SecretKey) -> PublicKey {
+    zcash_primitives::constants::SPENDING_KEY_GENERATOR * secret
+}
+
+pub type TokenId = jubjub::Fr;
+
+pub type NullifierSerial = jubjub::Fr;
+
+pub type CoinBlind = jubjub::Fr;
+
+pub type ValueCommitBlind = jubjub::Fr;
+
+pub type TokenCommitBlind = jubjub::Fr;