Kaynağa Gözat

crypto: minor cleanup

Dastan-glitch 4 yıl önce
ebeveyn
işleme
167b015fff
3 değiştirilmiş dosya ile 9 ekleme ve 8 silme
  1. 3 3
      src/crypto/loader.rs
  2. 1 0
      src/crypto/mod.rs
  3. 5 5
      src/crypto/proof.rs

+ 3 - 3
src/crypto/loader.rs

@@ -2,11 +2,11 @@ use std::{fs::*, path::PathBuf, time::Instant};
 
 use crate::{
     crypto::proof::{ProvingKey, VerifyingKey},
+    util::serial::Decodable,
     zk::{circuit::MintContract, vm},
+    Result,
 };
 
-use super::{serial::Decodable, Result};
-
 pub struct ContractLoader {}
 
 impl ContractLoader {
@@ -69,7 +69,7 @@ impl ContractLoader {
 
     pub fn create_prk(name: String) -> Result<()> {
         // TODO: implement this
-        let _mint_vk = ProvingKey::build(11, MintContract::default());
+        let _mint_pk = ProvingKey::build(11, MintContract::default());
         let _file = File::create(name + ".prk")?;
         // TODO: serialize and save file
         Ok(())

+ 1 - 0
src/crypto/mod.rs

@@ -4,6 +4,7 @@ pub mod coin;
 pub mod constants;
 pub mod diffie_hellman;
 pub mod keypair;
+pub mod loader;
 pub mod merkle_node;
 pub mod mint_proof;
 pub mod note;

+ 5 - 5
src/crypto/proof.rs

@@ -4,7 +4,7 @@ use std::io;
 use halo2::{
     plonk,
     plonk::Circuit,
-    poly::commitment,
+    poly::commitment::Params,
     transcript::{Blake2bRead, Blake2bWrite},
 };
 use pasta_curves::vesta;
@@ -17,13 +17,13 @@ use crate::{
 
 #[derive(Debug)]
 pub struct VerifyingKey {
-    pub params: commitment::Params<vesta::Affine>,
+    pub params: Params<vesta::Affine>,
     pub vk: plonk::VerifyingKey<vesta::Affine>,
 }
 
 impl VerifyingKey {
     pub fn build(k: u32, c: impl Circuit<DrkCircuitField>) -> Self {
-        let params = commitment::Params::new(k);
+        let params = Params::new(k);
         let vk = plonk::keygen_vk(&params, &c).unwrap();
         VerifyingKey { params, vk }
     }
@@ -31,13 +31,13 @@ impl VerifyingKey {
 
 #[derive(Debug)]
 pub struct ProvingKey {
-    pub params: commitment::Params<vesta::Affine>,
+    pub params: Params<vesta::Affine>,
     pub pk: plonk::ProvingKey<vesta::Affine>,
 }
 
 impl ProvingKey {
     pub fn build(k: u32, c: impl Circuit<DrkCircuitField>) -> Self {
-        let params = commitment::Params::new(k);
+        let params = Params::new(k);
         let vk = plonk::keygen_vk(&params, &c).unwrap();
         let pk = plonk::keygen_pk(&params, vk, &c).unwrap();
         ProvingKey { params, pk }