Sfoglia il codice sorgente

crypto: Add structs to hold proof verification and proving keys.

parazyd 4 anni fa
parent
commit
9d67289bd2
2 ha cambiato i file con 34 aggiunte e 0 eliminazioni
  1. 17 0
      src/crypto/mint_proof.rs
  2. 17 0
      src/crypto/spend_proof.rs

+ 17 - 0
src/crypto/mint_proof.rs

@@ -22,6 +22,23 @@ use crate::{
     Result,
     Result,
 };
 };
 
 
+pub struct MintProofKeys {
+    pub vk: VerifyingKey,
+    pub pk: ProvingKey,
+}
+
+impl MintProofKeys {
+    pub fn initialize() -> Self {
+        let start = Instant::now();
+        debug!("Building proof verifying key for the mint contract...");
+        let vk = VerifyingKey::build(11, MintContract::default());
+        debug!("Building proof proving key for the mint contract...");
+        let pk = ProvingKey::build(11, MintContract::default());
+        debug!("Setup: [{:?}]", start.elapsed());
+        MintProofKeys { vk, pk }
+    }
+}
+
 pub struct MintRevealedValues {
 pub struct MintRevealedValues {
     pub value_commit: DrkValueCommit,
     pub value_commit: DrkValueCommit,
     pub token_commit: DrkValueCommit,
     pub token_commit: DrkValueCommit,

+ 17 - 0
src/crypto/spend_proof.rs

@@ -25,6 +25,23 @@ use crate::{
     Result,
     Result,
 };
 };
 
 
+pub struct SpendProofKeys {
+    pub vk: VerifyingKey,
+    pub pk: ProvingKey,
+}
+
+impl SpendProofKeys {
+    pub fn initialize() -> Self {
+        let start = Instant::now();
+        debug!("Building proof verifying key for the spend contract...");
+        let vk = VerifyingKey::build(11, SpendContract::default());
+        debug!("Building proof proving key for the spend contract...");
+        let pk = ProvingKey::build(11, SpendContract::default());
+        debug!("Setup: [{:?}]", start.elapsed());
+        SpendProofKeys { vk, pk }
+    }
+}
+
 pub struct SpendRevealedValues {
 pub struct SpendRevealedValues {
     pub value_commit: DrkValueCommit,
     pub value_commit: DrkValueCommit,
     pub token_commit: DrkValueCommit,
     pub token_commit: DrkValueCommit,