crypto: minor cleanup

This commit is contained in:
Dastan-glitch
2022-01-16 18:40:22 -05:00
committed by parazyd
parent ba8085ac74
commit 167b015fff
3 changed files with 9 additions and 8 deletions

View File

@@ -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(())

View File

@@ -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;

View File

@@ -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 }