mirror of
https://github.com/arnaucube/sonobe-light-btc.git
synced 2026-01-18 19:51:34 +01:00
chore: update sh with instance type + save sol and calldata to file
This commit is contained in:
764
Cargo.lock
generated
764
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,9 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ark-r1cs-std = { git = "https://github.com/arnaucube/ark-r1cs-std-cherry-picked/" }
|
ark-r1cs-std = { git = "https://github.com/arnaucube/ark-r1cs-std-cherry-picked/" }
|
||||||
folding-schemes = { git = "https://github.com/privacy-scaling-explorations/folding-schemes.git", package = "folding-schemes", branch="feature/solidity-decider-verifier" }
|
folding-schemes = { git = "https://github.com/privacy-scaling-explorations/folding-schemes.git", branch="feature/solidity-decider-verifier" }
|
||||||
|
solidity-verifiers = { git = "https://github.com/privacy-scaling-explorations/folding-schemes.git", package="solidity-verifiers", branch="feature/solidity-decider-verifier" }
|
||||||
|
test-lib = { path = "/Users/pierredm/work/personal/test-lib" }
|
||||||
ark-light-bitcoin-client = { git = "https://github.com/dmpierre/ark-light-bitcoin-client.git" }
|
ark-light-bitcoin-client = { git = "https://github.com/dmpierre/ark-light-bitcoin-client.git" }
|
||||||
ark-ff = "0.4.0"
|
ark-ff = "0.4.0"
|
||||||
ark-relations = "0.4.0"
|
ark-relations = "0.4.0"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# running on m7i.metal-24xl instance
|
||||||
# run with `source ./setup-machine-and-run-proving.sh`
|
# run with `source ./setup-machine-and-run-proving.sh`
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt install build-essential -y
|
sudo apt install build-essential -y
|
||||||
|
|||||||
55
src/main.rs
55
src/main.rs
@@ -11,16 +11,22 @@ use ark_light_bitcoin_client::{
|
|||||||
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar};
|
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar};
|
||||||
use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
|
use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
|
||||||
use ark_std::rand;
|
use ark_std::rand;
|
||||||
use folding_schemes::Decider as DeciderTrait;
|
|
||||||
use folding_schemes::{
|
use folding_schemes::{
|
||||||
commitment::{kzg::KZG, pedersen::Pedersen},
|
commitment::{kzg::KZG, pedersen::Pedersen},
|
||||||
folding::nova::{decider_eth::Decider, Nova},
|
folding::nova::{decider_eth::Decider, Nova},
|
||||||
frontend::FCircuit,
|
frontend::FCircuit,
|
||||||
};
|
};
|
||||||
|
use folding_schemes::{folding::nova::decider_eth::prepare_calldata, Decider as DeciderTrait};
|
||||||
use folding_schemes::{folding::nova::decider_eth_circuit::DeciderEthCircuit, FoldingScheme};
|
use folding_schemes::{folding::nova::decider_eth_circuit::DeciderEthCircuit, FoldingScheme};
|
||||||
use num_bigint::BigUint;
|
use num_bigint::BigUint;
|
||||||
use num_traits::Num;
|
use num_traits::Num;
|
||||||
use std::{marker::PhantomData, time::Instant};
|
use solidity_verifiers::{
|
||||||
|
evm::{compile_solidity, save_solidity, Evm},
|
||||||
|
get_decider_template_for_cyclefold_decider,
|
||||||
|
utils::get_function_selector_for_nova_cyclefold_verifier,
|
||||||
|
};
|
||||||
|
use solidity_verifiers::{Groth16Data, KzgData, NovaCyclefoldData};
|
||||||
|
use std::{fs, marker::PhantomData, time::Instant};
|
||||||
use utils::setup;
|
use utils::setup;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
@@ -166,7 +172,11 @@ fn main() {
|
|||||||
// decider proof generation
|
// decider proof generation
|
||||||
println!("Generating proof...");
|
println!("Generating proof...");
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let decider_pp = (poseidon_config.clone(), g16_pk, prover_params.cs_params);
|
let decider_pp = (
|
||||||
|
poseidon_config.clone(),
|
||||||
|
g16_pk,
|
||||||
|
prover_params.clone().cs_params,
|
||||||
|
);
|
||||||
let proof = DECIDER::prove(decider_pp, rng, nova.clone()).unwrap();
|
let proof = DECIDER::prove(decider_pp, rng, nova.clone()).unwrap();
|
||||||
let elapsed = now.elapsed();
|
let elapsed = now.elapsed();
|
||||||
println!("Proof generated in: {:.2?}", elapsed);
|
println!("Proof generated in: {:.2?}", elapsed);
|
||||||
@@ -176,12 +186,47 @@ fn main() {
|
|||||||
let verified = DECIDER::verify(
|
let verified = DECIDER::verify(
|
||||||
(g16_vk.clone(), kzg_vk.clone()),
|
(g16_vk.clone(), kzg_vk.clone()),
|
||||||
nova.i,
|
nova.i,
|
||||||
nova.z_0,
|
nova.z_0.clone(),
|
||||||
nova.z_i,
|
nova.z_i.clone(),
|
||||||
&nova.U_i,
|
&nova.U_i,
|
||||||
&nova.u_i,
|
&nova.u_i,
|
||||||
&proof,
|
&proof,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(verified);
|
assert!(verified);
|
||||||
|
|
||||||
|
let g16_data = Groth16Data::from(g16_vk);
|
||||||
|
let kzg_data = KzgData::from((
|
||||||
|
kzg_vk,
|
||||||
|
Some(prover_params.cs_params.powers_of_g[0..3].to_vec()),
|
||||||
|
));
|
||||||
|
let nova_cyclefold_data = NovaCyclefoldData::from((g16_data, kzg_data, nova.z_0.len()));
|
||||||
|
let function_selector =
|
||||||
|
get_function_selector_for_nova_cyclefold_verifier(nova.z_0.len() * 2 + 1);
|
||||||
|
|
||||||
|
let calldata: Vec<u8> = prepare_calldata(
|
||||||
|
function_selector,
|
||||||
|
nova.i,
|
||||||
|
nova.z_0,
|
||||||
|
nova.z_i,
|
||||||
|
&nova.U_i,
|
||||||
|
&nova.u_i,
|
||||||
|
proof,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let decider_template = get_decider_template_for_cyclefold_decider(nova_cyclefold_data);
|
||||||
|
save_solidity("./NovaLightBTCClientDecider.sol", &decider_template);
|
||||||
|
fs::write("./solidity-calldata.calldata", calldata).unwrap();
|
||||||
|
|
||||||
|
// save calldata
|
||||||
|
|
||||||
|
// let nova_cyclefold_verifier_bytecode = compile_solidity(decider_template, "NovaDecider");
|
||||||
|
//
|
||||||
|
// let mut evm = Evm::default();
|
||||||
|
// let verifier_address = evm.create(nova_cyclefold_verifier_bytecode);
|
||||||
|
//
|
||||||
|
// let (_, output) = evm.call(verifier_address, calldata.clone());
|
||||||
|
// println!("Output: {:?}", output);
|
||||||
|
// assert_eq!(*output.last().unwrap(), 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user