WIP: Sketch out public Rust API for Multiplier

This commit is contained in:
Oskar Thoren 2022-01-19 11:47:40 +08:00
parent b85950f827
commit c96ab25bc6
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
2 changed files with 51 additions and 0 deletions

View File

@ -1 +1,2 @@
pub mod public;
pub mod ffi;

50
multiplier/src/public.rs Normal file
View File

@ -0,0 +1,50 @@
use ark_circom::{CircomBuilder, CircomConfig, CircomCircuit};
use ark_std::rand::thread_rng;
use ark_bn254::Bn254;
use ark_groth16::generate_random_parameters;
use ark_groth16::ProvingKey;
pub struct Multiplier {
circom: CircomCircuit<Bn254>,
params: ProvingKey<Bn254>
}
impl Multiplier {
// TODO Break this apart here
pub fn new() -> Multiplier {
let cfg = CircomConfig::<Bn254>::new(
"./resources/circom2_multiplier2.wasm",
"./resources/circom2_multiplier2.r1cs",
).unwrap();
let mut builder = CircomBuilder::new(cfg);
builder.push_input("a", 3);
builder.push_input("b", 11);
// create an empty instance for setting it up
let circom = builder.setup();
let mut rng = thread_rng();
let params = generate_random_parameters::<Bn254, _, _>(circom, &mut rng)
.unwrap();
let circom = builder.build().unwrap();
let inputs = circom.get_public_inputs().unwrap();
Multiplier { circom, params }
}
// TODO Return proof
pub fn prove() -> bool {
false
}
// TODO Return proof
pub fn verify() -> bool {
false
}
}