mirror of
https://github.com/zkonduit/ezkl.git
synced 2026-01-13 08:17:57 -05:00
Compare commits
2 Commits
v23.0.0
...
ac/simpler
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
704813cc15 | ||
|
|
8cf28456b3 |
@@ -152,7 +152,6 @@ fn runcnvrl(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -119,7 +119,6 @@ fn rundot(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -174,7 +174,6 @@ fn runmatmul(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -154,7 +154,6 @@ fn runmatmul(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -157,7 +157,6 @@ fn runmatmul(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -116,7 +116,6 @@ fn runsum(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -131,7 +131,6 @@ fn runsumpool(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -118,7 +118,6 @@ fn runadd(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -117,7 +117,6 @@ fn runpow(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -104,7 +104,6 @@ fn runposeidon(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -130,7 +130,6 @@ fn runrelu(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -124,7 +124,6 @@ fn runrelu(c: &mut Criterion) {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::UNSAFE,
|
||||
ezkl::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
" gip_run_args.param_scale = 19\n",
|
||||
" gip_run_args.logrows = 8\n",
|
||||
" run_args = ezkl.gen_settings(py_run_args=gip_run_args)\n",
|
||||
" await ezkl.get_srs(commitment=ezkl.PyCommitments.KZG)\n",
|
||||
" await ezkl.get_srs()\n",
|
||||
" ezkl.compile_circuit()\n",
|
||||
" res = ezkl.gen_witness()\n",
|
||||
" print(res)\n",
|
||||
@@ -127,4 +127,4 @@
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@
|
||||
"run_args.param_scale = 0\n",
|
||||
"run_args.logrows = 18\n",
|
||||
"\n",
|
||||
"ezkl.get_srs(logrows=run_args.logrows, commitment=ezkl.PyCommitments.KZG)\n"
|
||||
"ezkl.get_srs(logrows=run_args.logrows, )\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
"run_args.input_scale = 2\n",
|
||||
"run_args.logrows = 15\n",
|
||||
"\n",
|
||||
"ezkl.get_srs(logrows=run_args.logrows, commitment=ezkl.PyCommitments.KZG)"
|
||||
"ezkl.get_srs(logrows=run_args.logrows, )"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
41
ezkl.pyi
41
ezkl.pyi
@@ -31,14 +31,6 @@ class PyRunArgs:
|
||||
|
||||
...
|
||||
|
||||
class PyCommitments(Enum):
|
||||
r"""
|
||||
pyclass representing an enum, denoting the type of commitment
|
||||
"""
|
||||
|
||||
KZG = auto()
|
||||
IPA = auto()
|
||||
|
||||
class PyInputType(Enum):
|
||||
Bool = auto()
|
||||
F16 = auto()
|
||||
@@ -421,7 +413,6 @@ def get_srs(
|
||||
settings_path: typing.Optional[str | os.PathLike | pathlib.Path],
|
||||
logrows: typing.Optional[int],
|
||||
srs_path: typing.Optional[str | os.PathLike | pathlib.Path],
|
||||
commitment: typing.Optional[PyCommitments],
|
||||
) -> typing.Any:
|
||||
r"""
|
||||
Gets a public srs
|
||||
@@ -437,44 +428,12 @@ def get_srs(
|
||||
srs_path: str
|
||||
Path to the create the SRS file
|
||||
|
||||
commitment: str
|
||||
Specify the commitment used ("kzg", "ipa")
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
"""
|
||||
...
|
||||
|
||||
def ipa_commit(
|
||||
message: typing.Sequence[str],
|
||||
vk_path: str | os.PathLike | pathlib.Path,
|
||||
settings_path: str | os.PathLike | pathlib.Path,
|
||||
srs_path: typing.Optional[str | os.PathLike | pathlib.Path],
|
||||
) -> list[PyG1Affine]:
|
||||
r"""
|
||||
Generate an ipa commitment.
|
||||
|
||||
Arguments
|
||||
-------
|
||||
message: list[str]
|
||||
List of field elements represnted as strings
|
||||
|
||||
vk_path: str
|
||||
Path to the verification key
|
||||
|
||||
settings_path: str
|
||||
Path to the settings file
|
||||
|
||||
srs_path: str
|
||||
Path to the Structure Reference String (SRS) file
|
||||
|
||||
Returns
|
||||
-------
|
||||
list[PyG1Affine]
|
||||
"""
|
||||
...
|
||||
|
||||
def kzg_commit(
|
||||
message: typing.Sequence[str],
|
||||
vk_path: str | os.PathLike | pathlib.Path,
|
||||
|
||||
@@ -15,9 +15,7 @@ use crate::graph::{
|
||||
use crate::pfsys::{
|
||||
load_pk, load_vk, save_params, save_vk, srs::gen_srs as ezkl_gen_srs, srs::load_srs_prover,
|
||||
};
|
||||
use crate::Commitments;
|
||||
use crate::RunArgs;
|
||||
use halo2_proofs::poly::ipa::commitment::IPACommitmentScheme;
|
||||
use halo2_proofs::poly::kzg::commitment::KZGCommitmentScheme;
|
||||
use halo2curves::bn256::{Bn256, Fq, Fr, G1Affine, G1};
|
||||
use pyo3::exceptions::{PyIOError, PyRuntimeError};
|
||||
@@ -171,9 +169,6 @@ struct PyRunArgs {
|
||||
#[pyo3(get, set)]
|
||||
/// str: check mode, accepts `safe`, `unsafe`
|
||||
pub check_mode: CheckMode,
|
||||
#[pyo3(get, set)]
|
||||
/// str: commitment type, accepts `kzg`, `ipa`
|
||||
pub commitment: PyCommitments,
|
||||
/// int: The base used for decomposition
|
||||
#[pyo3(get, set)]
|
||||
pub decomp_base: usize,
|
||||
@@ -221,7 +216,6 @@ impl From<PyRunArgs> for RunArgs {
|
||||
variables: py_run_args.variables,
|
||||
rebase_frac_zero_constants: py_run_args.rebase_frac_zero_constants,
|
||||
check_mode: py_run_args.check_mode,
|
||||
commitment: Some(py_run_args.commitment.into()),
|
||||
decomp_base: py_run_args.decomp_base,
|
||||
decomp_legs: py_run_args.decomp_legs,
|
||||
ignore_range_check_inputs_outputs: py_run_args.ignore_range_check_inputs_outputs,
|
||||
@@ -249,7 +243,6 @@ impl Into<PyRunArgs> for RunArgs {
|
||||
variables: self.variables,
|
||||
rebase_frac_zero_constants: self.rebase_frac_zero_constants,
|
||||
check_mode: self.check_mode,
|
||||
commitment: self.commitment.into(),
|
||||
decomp_base: self.decomp_base,
|
||||
decomp_legs: self.decomp_legs,
|
||||
ignore_range_check_inputs_outputs: self.ignore_range_check_inputs_outputs,
|
||||
@@ -259,56 +252,6 @@ impl Into<PyRunArgs> for RunArgs {
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass]
|
||||
#[derive(Debug, Clone)]
|
||||
#[gen_stub_pyclass_enum]
|
||||
/// pyclass representing an enum, denoting the type of commitment
|
||||
pub enum PyCommitments {
|
||||
/// KZG commitment
|
||||
KZG,
|
||||
/// IPA commitment
|
||||
IPA,
|
||||
}
|
||||
|
||||
impl From<Option<Commitments>> for PyCommitments {
|
||||
fn from(commitment: Option<Commitments>) -> Self {
|
||||
match commitment {
|
||||
Some(Commitments::KZG) => PyCommitments::KZG,
|
||||
Some(Commitments::IPA) => PyCommitments::IPA,
|
||||
None => PyCommitments::KZG,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PyCommitments> for Commitments {
|
||||
fn from(py_commitments: PyCommitments) -> Self {
|
||||
match py_commitments {
|
||||
PyCommitments::KZG => Commitments::KZG,
|
||||
PyCommitments::IPA => Commitments::IPA,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<PyCommitments> for Commitments {
|
||||
fn into(self) -> PyCommitments {
|
||||
match self {
|
||||
Commitments::KZG => PyCommitments::KZG,
|
||||
Commitments::IPA => PyCommitments::IPA,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for PyCommitments {
|
||||
type Err = String;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s.to_lowercase().as_str() {
|
||||
"kzg" => Ok(PyCommitments::KZG),
|
||||
"ipa" => Ok(PyCommitments::IPA),
|
||||
_ => Err("Invalid value for Commitments".to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass]
|
||||
#[derive(Debug, Clone)]
|
||||
#[gen_stub_pyclass_enum]
|
||||
@@ -621,8 +564,7 @@ fn kzg_commit(
|
||||
let settings = GraphSettings::load(&settings_path)
|
||||
.map_err(|_| PyIOError::new_err("Failed to load circuit settings"))?;
|
||||
|
||||
let srs_path =
|
||||
crate::execute::get_srs_path(settings.run_args.logrows, srs_path, Commitments::KZG);
|
||||
let srs_path = crate::execute::get_srs_path(settings.run_args.logrows, srs_path);
|
||||
|
||||
let srs = load_srs_prover::<KZGCommitmentScheme<Bn256>>(srs_path)
|
||||
.map_err(|_| PyIOError::new_err("Failed to load srs"))?;
|
||||
@@ -639,65 +581,6 @@ fn kzg_commit(
|
||||
Ok(output.iter().map(|x| (*x).into()).collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
/// Generate an ipa commitment.
|
||||
///
|
||||
/// Arguments
|
||||
/// -------
|
||||
/// message: list[str]
|
||||
/// List of field elements represented as strings
|
||||
///
|
||||
/// vk_path: str
|
||||
/// Path to the verification key
|
||||
///
|
||||
/// settings_path: str
|
||||
/// Path to the settings file
|
||||
///
|
||||
/// srs_path: str
|
||||
/// Path to the Structure Reference String (SRS) file
|
||||
///
|
||||
/// Returns
|
||||
/// -------
|
||||
/// list[PyG1Affine]
|
||||
///
|
||||
#[pyfunction(signature = (
|
||||
message,
|
||||
vk_path=PathBuf::from(DEFAULT_VK),
|
||||
settings_path=PathBuf::from(DEFAULT_SETTINGS),
|
||||
srs_path=None
|
||||
))]
|
||||
#[gen_stub_pyfunction]
|
||||
fn ipa_commit(
|
||||
message: Vec<PyFelt>,
|
||||
vk_path: PathBuf,
|
||||
settings_path: PathBuf,
|
||||
srs_path: Option<PathBuf>,
|
||||
) -> PyResult<Vec<PyG1Affine>> {
|
||||
let message: Vec<Fr> = message
|
||||
.iter()
|
||||
.map(crate::pfsys::string_to_field::<Fr>)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let settings = GraphSettings::load(&settings_path)
|
||||
.map_err(|_| PyIOError::new_err("Failed to load circuit settings"))?;
|
||||
|
||||
let srs_path =
|
||||
crate::execute::get_srs_path(settings.run_args.logrows, srs_path, Commitments::IPA);
|
||||
|
||||
let srs = load_srs_prover::<IPACommitmentScheme<G1Affine>>(srs_path)
|
||||
.map_err(|_| PyIOError::new_err("Failed to load srs"))?;
|
||||
|
||||
let vk = load_vk::<IPACommitmentScheme<G1Affine>, GraphCircuit>(vk_path, settings)
|
||||
.map_err(|_| PyIOError::new_err("Failed to load vk"))?;
|
||||
|
||||
let output = PolyCommitChip::commit::<IPACommitmentScheme<G1Affine>>(
|
||||
message,
|
||||
(vk.cs().blinding_factors() + 1) as u32,
|
||||
&srs,
|
||||
);
|
||||
|
||||
Ok(output.iter().map(|x| (*x).into()).collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
/// Swap the commitments in a proof
|
||||
///
|
||||
/// Arguments
|
||||
@@ -825,8 +708,6 @@ fn gen_srs(srs_path: PathBuf, logrows: usize) -> PyResult<()> {
|
||||
/// srs_path: str
|
||||
/// Path to the create the SRS file
|
||||
///
|
||||
/// commitment: str
|
||||
/// Specify the commitment used ("kzg", "ipa")
|
||||
///
|
||||
/// Returns
|
||||
/// -------
|
||||
@@ -836,7 +717,6 @@ fn gen_srs(srs_path: PathBuf, logrows: usize) -> PyResult<()> {
|
||||
settings_path=PathBuf::from(DEFAULT_SETTINGS),
|
||||
logrows=None,
|
||||
srs_path=None,
|
||||
commitment=None,
|
||||
))]
|
||||
#[gen_stub_pyfunction]
|
||||
fn get_srs(
|
||||
@@ -844,15 +724,9 @@ fn get_srs(
|
||||
settings_path: Option<PathBuf>,
|
||||
logrows: Option<u32>,
|
||||
srs_path: Option<PathBuf>,
|
||||
commitment: Option<PyCommitments>,
|
||||
) -> PyResult<Bound<'_, PyAny>> {
|
||||
let commitment: Option<Commitments> = match commitment {
|
||||
Some(c) => Some(c.into()),
|
||||
None => None,
|
||||
};
|
||||
|
||||
pyo3_async_runtimes::tokio::future_into_py(py, async move {
|
||||
crate::execute::get_srs_cmd(srs_path, settings_path, logrows, commitment)
|
||||
crate::execute::get_srs_cmd(srs_path, settings_path, logrows)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
let err_str = format!("Failed to get srs: {}", e);
|
||||
@@ -1602,14 +1476,12 @@ fn ezkl(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||
m.add_class::<PyG1Affine>()?;
|
||||
m.add_class::<PyG1>()?;
|
||||
m.add_class::<PyTestDataSource>()?;
|
||||
m.add_class::<PyCommitments>()?;
|
||||
m.add_class::<PyInputType>()?;
|
||||
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
|
||||
m.add_function(wrap_pyfunction!(felt_to_big_endian, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(felt_to_int, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(felt_to_float, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(kzg_commit, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(ipa_commit, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(swap_proof_commitments, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(poseidon_hash, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(float_to_felt, m)?)?;
|
||||
|
||||
@@ -159,18 +159,17 @@ pub fn diff_less_than<F: PrimeField + TensorType + PartialOrd + std::hash::Hash>
|
||||
values: &[&ValTensor<F>; 2],
|
||||
constant: F,
|
||||
) -> Result<(), CircuitError> {
|
||||
let distance = l1_distance(config, region, values)?;
|
||||
|
||||
let constant = create_constant_tensor(constant, 1);
|
||||
let is_less = less(config, region, &[&distance, &constant])?;
|
||||
|
||||
// assert the result is 1
|
||||
let comparison_unit = create_constant_tensor(F::ONE, is_less.len());
|
||||
enforce_equality(config, region, &[&is_less, &comparison_unit])?;
|
||||
let diff = pairwise(config, region, values, BaseOp::Sub)?;
|
||||
let int_rep_constant = felt_to_integer_rep(constant);
|
||||
range_check(
|
||||
config,
|
||||
region,
|
||||
&[&diff],
|
||||
&(-int_rep_constant + 1, int_rep_constant - 1),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Performs division of a tensor by a constant value.
|
||||
///
|
||||
/// This function divides each element in a tensor by a scalar divisor value, using
|
||||
|
||||
@@ -359,7 +359,6 @@ mod matmul_col_ultra_overflow_double_col {
|
||||
&pk,
|
||||
// use safe mode to verify that the proof is correct
|
||||
CheckMode::SAFE,
|
||||
crate::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
@@ -479,7 +478,6 @@ mod matmul_col_ultra_overflow {
|
||||
&pk,
|
||||
// use safe mode to verify that the proof is correct
|
||||
CheckMode::SAFE,
|
||||
crate::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
@@ -1296,7 +1294,6 @@ mod conv_col_ultra_overflow {
|
||||
&pk,
|
||||
// use safe mode to verify that the proof is correct
|
||||
CheckMode::SAFE,
|
||||
crate::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
@@ -1464,7 +1461,6 @@ mod conv_relu_col_ultra_overflow {
|
||||
¶ms,
|
||||
&pk,
|
||||
CheckMode::SAFE,
|
||||
crate::Commitments::KZG,
|
||||
// use safe mode to verify that the proof is correct
|
||||
None,
|
||||
None,
|
||||
@@ -2639,7 +2635,6 @@ mod lookup_ultra_overflow {
|
||||
&pk,
|
||||
// use safe mode to verify that the proof is correct
|
||||
CheckMode::SAFE,
|
||||
crate::Commitments::KZG,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use tosubcommand::{ToFlags, ToSubcommand};
|
||||
|
||||
use crate::{Commitments, RunArgs};
|
||||
use crate::RunArgs;
|
||||
|
||||
use crate::circuit::CheckMode;
|
||||
|
||||
@@ -492,9 +492,6 @@ pub enum Commands {
|
||||
/// number of logrows to use for srs
|
||||
#[arg(long, value_hint = clap::ValueHint::Other)]
|
||||
logrows: usize,
|
||||
/// commitment used
|
||||
#[arg(long, default_value = DEFAULT_COMMITMENT, value_hint = clap::ValueHint::Other)]
|
||||
commitment: Option<Commitments>,
|
||||
},
|
||||
|
||||
/// Gets an SRS from a circuit settings file.
|
||||
@@ -509,9 +506,6 @@ pub enum Commands {
|
||||
/// Number of logrows to use for srs. Overrides settings_path if specified.
|
||||
#[arg(long, default_value = None, value_hint = clap::ValueHint::Other)]
|
||||
logrows: Option<u32>,
|
||||
/// Commitment used
|
||||
#[arg(long, default_value = None, value_hint = clap::ValueHint::Other)]
|
||||
commitment: Option<Commitments>,
|
||||
},
|
||||
/// Loads model and input and runs mock prover (for testing)
|
||||
Mock {
|
||||
|
||||
368
src/execute.rs
368
src/execute.rs
@@ -10,15 +10,15 @@ use crate::eth::register_vka_via_rv;
|
||||
use crate::eth::{get_contract_artifacts, verify_proof_via_solidity};
|
||||
use crate::graph::input::GraphData;
|
||||
use crate::graph::{GraphCircuit, GraphSettings, GraphWitness, Model};
|
||||
use crate::pfsys::{create_keys, load_pk, load_vk, save_params, save_pk, Snark};
|
||||
use crate::pfsys::{
|
||||
create_proof_circuit, swap_proof_commitments_polycommit, verify_proof_circuit, ProofSplitCommit,
|
||||
create_keys, load_pk, load_vk, save_params, save_pk, swap_proof_commitments, Snark,
|
||||
};
|
||||
use crate::pfsys::{create_proof_circuit, verify_proof_circuit, ProofSplitCommit};
|
||||
use crate::pfsys::{encode_calldata, save_vk, srs::*};
|
||||
use crate::tensor::TensorError;
|
||||
use crate::RunArgs;
|
||||
use crate::EZKL_BUF_CAPACITY;
|
||||
use crate::{commands::*, EZKLError};
|
||||
use crate::{Commitments, RunArgs};
|
||||
use colored::Colorize;
|
||||
#[cfg(unix)]
|
||||
use gag::Gag;
|
||||
@@ -28,9 +28,7 @@ use halo2_proofs::icicle::try_load_and_set_backend_device;
|
||||
use halo2_proofs::plonk::{self, Circuit};
|
||||
use halo2_proofs::poly::commitment::Verifier;
|
||||
use halo2_proofs::poly::commitment::{CommitmentScheme, Params};
|
||||
use halo2_proofs::poly::ipa::commitment::{IPACommitmentScheme, ParamsIPA};
|
||||
use halo2_proofs::poly::ipa::multiopen::{ProverIPA, VerifierIPA};
|
||||
use halo2_proofs::poly::ipa::strategy::SingleStrategy as IPASingleStrategy;
|
||||
|
||||
use halo2_proofs::poly::kzg::commitment::KZGCommitmentScheme;
|
||||
use halo2_proofs::poly::kzg::multiopen::{ProverSHPLONK, VerifierSHPLONK};
|
||||
use halo2_proofs::poly::kzg::{
|
||||
@@ -62,7 +60,6 @@ use std::io::Cursor;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use tabled::Tabled;
|
||||
use thiserror::Error;
|
||||
@@ -128,21 +125,12 @@ pub async fn run(command: Commands) -> Result<String, EZKLError> {
|
||||
match command {
|
||||
#[cfg(feature = "empty-cmd")]
|
||||
Commands::Empty => Ok(String::new()),
|
||||
Commands::GenSrs {
|
||||
srs_path,
|
||||
logrows,
|
||||
commitment,
|
||||
} => gen_srs_cmd(
|
||||
srs_path,
|
||||
logrows as u32,
|
||||
commitment.unwrap_or_else(|| Commitments::from_str(DEFAULT_COMMITMENT).unwrap()),
|
||||
),
|
||||
Commands::GenSrs { srs_path, logrows } => gen_srs_cmd(srs_path, logrows as u32),
|
||||
Commands::GetSrs {
|
||||
srs_path,
|
||||
settings_path,
|
||||
logrows,
|
||||
commitment,
|
||||
} => get_srs_cmd(srs_path, settings_path, logrows, commitment).await,
|
||||
} => get_srs_cmd(srs_path, settings_path, logrows).await,
|
||||
Commands::Table { model, args } => table(model.unwrap_or(DEFAULT_MODEL.into()), args),
|
||||
Commands::GenSettings {
|
||||
model,
|
||||
@@ -448,39 +436,24 @@ fn update_ezkl_binary(version: &Option<String>) -> Result<String, EZKLError> {
|
||||
}
|
||||
|
||||
/// Get the srs path
|
||||
pub fn get_srs_path(logrows: u32, srs_path: Option<PathBuf>, commitment: Commitments) -> PathBuf {
|
||||
pub fn get_srs_path(logrows: u32, srs_path: Option<PathBuf>) -> PathBuf {
|
||||
if let Some(srs_path) = srs_path {
|
||||
srs_path
|
||||
} else {
|
||||
if !Path::new(&*EZKL_SRS_REPO_PATH).exists() {
|
||||
std::fs::create_dir_all(&*EZKL_SRS_REPO_PATH).unwrap();
|
||||
}
|
||||
match commitment {
|
||||
Commitments::KZG => Path::new(&*EZKL_SRS_REPO_PATH).join(format!("kzg{}.srs", logrows)),
|
||||
Commitments::IPA => Path::new(&*EZKL_SRS_REPO_PATH).join(format!("ipa{}.srs", logrows)),
|
||||
}
|
||||
Path::new(&*EZKL_SRS_REPO_PATH).join(format!("kzg{}.srs", logrows))
|
||||
}
|
||||
}
|
||||
|
||||
fn srs_exists_check(logrows: u32, srs_path: Option<PathBuf>, commitment: Commitments) -> bool {
|
||||
Path::new(&get_srs_path(logrows, srs_path, commitment)).exists()
|
||||
fn srs_exists_check(logrows: u32, srs_path: Option<PathBuf>) -> bool {
|
||||
Path::new(&get_srs_path(logrows, srs_path)).exists()
|
||||
}
|
||||
|
||||
pub(crate) fn gen_srs_cmd(
|
||||
srs_path: PathBuf,
|
||||
logrows: u32,
|
||||
commitment: Commitments,
|
||||
) -> Result<String, EZKLError> {
|
||||
match commitment {
|
||||
Commitments::KZG => {
|
||||
let params = gen_srs::<KZGCommitmentScheme<Bn256>>(logrows);
|
||||
save_params::<KZGCommitmentScheme<Bn256>>(&srs_path, ¶ms)?;
|
||||
}
|
||||
Commitments::IPA => {
|
||||
let params = gen_srs::<IPACommitmentScheme<G1Affine>>(logrows);
|
||||
save_params::<IPACommitmentScheme<G1Affine>>(&srs_path, ¶ms)?;
|
||||
}
|
||||
}
|
||||
pub(crate) fn gen_srs_cmd(srs_path: PathBuf, logrows: u32) -> Result<String, EZKLError> {
|
||||
let params = gen_srs::<KZGCommitmentScheme<Bn256>>(logrows);
|
||||
save_params::<KZGCommitmentScheme<Bn256>>(&srs_path, ¶ms)?;
|
||||
Ok(String::new())
|
||||
}
|
||||
|
||||
@@ -521,12 +494,8 @@ pub(crate) fn get_file_hash(path: &PathBuf) -> Result<String, EZKLError> {
|
||||
Ok(hash)
|
||||
}
|
||||
|
||||
fn check_srs_hash(
|
||||
logrows: u32,
|
||||
srs_path: Option<PathBuf>,
|
||||
commitment: Commitments,
|
||||
) -> Result<String, EZKLError> {
|
||||
let path = get_srs_path(logrows, srs_path, commitment);
|
||||
fn check_srs_hash(logrows: u32, srs_path: Option<PathBuf>) -> Result<String, EZKLError> {
|
||||
let path = get_srs_path(logrows, srs_path);
|
||||
let hash = get_file_hash(&path)?;
|
||||
|
||||
let predefined_hash = match crate::srs_sha::PUBLIC_SRS_SHA256_HASHES.get(&logrows) {
|
||||
@@ -550,7 +519,6 @@ pub(crate) async fn get_srs_cmd(
|
||||
srs_path: Option<PathBuf>,
|
||||
settings_path: Option<PathBuf>,
|
||||
logrows: Option<u32>,
|
||||
commitment: Option<Commitments>,
|
||||
) -> Result<String, EZKLError> {
|
||||
// logrows overrides settings
|
||||
|
||||
@@ -569,53 +537,33 @@ pub(crate) async fn get_srs_cmd(
|
||||
return Err(err_string.into());
|
||||
};
|
||||
|
||||
let commitment = if let Some(c) = commitment {
|
||||
c
|
||||
} else if let Some(settings_p) = settings_path {
|
||||
if settings_p.exists() {
|
||||
let settings = GraphSettings::load(&settings_p)?;
|
||||
settings.run_args.commitment.into()
|
||||
} else {
|
||||
return Err(err_string.into());
|
||||
}
|
||||
} else {
|
||||
return Err(err_string.into());
|
||||
};
|
||||
if !srs_exists_check(k, srs_path.clone()) {
|
||||
info!("SRS does not exist, downloading...");
|
||||
let srs_uri = format!("{}{}", PUBLIC_SRS_URL, k);
|
||||
let mut reader = Cursor::new(fetch_srs(&srs_uri).await?);
|
||||
// check the SRS
|
||||
let pb = init_spinner();
|
||||
pb.set_message("Validating SRS (this may take a while) ...");
|
||||
let params = ParamsKZG::<Bn256>::read(&mut reader)?;
|
||||
pb.finish_with_message("SRS validated.");
|
||||
|
||||
if !srs_exists_check(k, srs_path.clone(), commitment) {
|
||||
if matches!(commitment, Commitments::KZG) {
|
||||
info!("SRS does not exist, downloading...");
|
||||
let srs_uri = format!("{}{}", PUBLIC_SRS_URL, k);
|
||||
let mut reader = Cursor::new(fetch_srs(&srs_uri).await?);
|
||||
// check the SRS
|
||||
let pb = init_spinner();
|
||||
pb.set_message("Validating SRS (this may take a while) ...");
|
||||
let params = ParamsKZG::<Bn256>::read(&mut reader)?;
|
||||
pb.finish_with_message("SRS validated.");
|
||||
info!("Saving SRS to disk...");
|
||||
let computed_srs_path = get_srs_path(k, srs_path.clone());
|
||||
let mut file = std::fs::File::create(&computed_srs_path)?;
|
||||
let mut buffer = BufWriter::with_capacity(*EZKL_BUF_CAPACITY, &mut file);
|
||||
params.write(&mut buffer)?;
|
||||
|
||||
info!("Saving SRS to disk...");
|
||||
let computed_srs_path = get_srs_path(k, srs_path.clone(), commitment);
|
||||
let mut file = std::fs::File::create(&computed_srs_path)?;
|
||||
let mut buffer = BufWriter::with_capacity(*EZKL_BUF_CAPACITY, &mut file);
|
||||
params.write(&mut buffer)?;
|
||||
info!(
|
||||
"Saved SRS to {}.",
|
||||
computed_srs_path.as_os_str().to_str().unwrap_or("disk")
|
||||
);
|
||||
|
||||
info!(
|
||||
"Saved SRS to {}.",
|
||||
computed_srs_path.as_os_str().to_str().unwrap_or("disk")
|
||||
);
|
||||
|
||||
info!("SRS downloaded");
|
||||
} else {
|
||||
let path = get_srs_path(k, srs_path.clone(), commitment);
|
||||
gen_srs_cmd(path, k, commitment)?;
|
||||
}
|
||||
info!("SRS downloaded");
|
||||
} else {
|
||||
info!("SRS already exists at that path");
|
||||
};
|
||||
// check the hash
|
||||
if matches!(commitment, Commitments::KZG) {
|
||||
check_srs_hash(k, srs_path.clone(), commitment)?;
|
||||
}
|
||||
check_srs_hash(k, srs_path.clone())?;
|
||||
|
||||
Ok(String::new())
|
||||
}
|
||||
@@ -654,43 +602,22 @@ pub(crate) fn gen_witness(
|
||||
|
||||
// if any of the settings have kzg visibility then we need to load the srs
|
||||
|
||||
let commitment: Commitments = settings.run_args.commitment.into();
|
||||
|
||||
let region_settings =
|
||||
RegionSettings::all_true(settings.run_args.decomp_base, settings.run_args.decomp_legs);
|
||||
|
||||
let start_time = Instant::now();
|
||||
let witness = if settings.module_requires_polycommit() {
|
||||
if get_srs_path(settings.run_args.logrows, srs_path.clone(), commitment).exists() {
|
||||
match Commitments::from(settings.run_args.commitment) {
|
||||
Commitments::KZG => {
|
||||
let srs: ParamsKZG<Bn256> = load_params_prover::<KZGCommitmentScheme<Bn256>>(
|
||||
srs_path.clone(),
|
||||
settings.run_args.logrows,
|
||||
commitment,
|
||||
)?;
|
||||
circuit.forward::<KZGCommitmentScheme<_>>(
|
||||
&mut input,
|
||||
vk.as_ref(),
|
||||
Some(&srs),
|
||||
region_settings,
|
||||
)?
|
||||
}
|
||||
Commitments::IPA => {
|
||||
let srs: ParamsIPA<G1Affine> =
|
||||
load_params_prover::<IPACommitmentScheme<G1Affine>>(
|
||||
srs_path.clone(),
|
||||
settings.run_args.logrows,
|
||||
commitment,
|
||||
)?;
|
||||
circuit.forward::<IPACommitmentScheme<_>>(
|
||||
&mut input,
|
||||
vk.as_ref(),
|
||||
Some(&srs),
|
||||
region_settings,
|
||||
)?
|
||||
}
|
||||
}
|
||||
if get_srs_path(settings.run_args.logrows, srs_path.clone()).exists() {
|
||||
let srs: ParamsKZG<Bn256> = load_params_prover::<KZGCommitmentScheme<Bn256>>(
|
||||
srs_path.clone(),
|
||||
settings.run_args.logrows,
|
||||
)?;
|
||||
circuit.forward::<KZGCommitmentScheme<_>>(
|
||||
&mut input,
|
||||
vk.as_ref(),
|
||||
Some(&srs),
|
||||
region_settings,
|
||||
)?
|
||||
} else {
|
||||
warn!("SRS for poly commit does not exist (will be ignored)");
|
||||
circuit.forward::<KZGCommitmentScheme<Bn256>>(
|
||||
@@ -1386,12 +1313,8 @@ pub(crate) async fn create_evm_verifier(
|
||||
reusable: bool,
|
||||
) -> Result<String, EZKLError> {
|
||||
let settings = GraphSettings::load(&settings_path)?;
|
||||
let commitment: Commitments = settings.run_args.commitment.into();
|
||||
let params = load_params_verifier::<KZGCommitmentScheme<Bn256>>(
|
||||
srs_path,
|
||||
settings.run_args.logrows,
|
||||
commitment,
|
||||
)?;
|
||||
let params =
|
||||
load_params_verifier::<KZGCommitmentScheme<Bn256>>(srs_path, settings.run_args.logrows)?;
|
||||
|
||||
let num_instance = settings.total_instances();
|
||||
// create a scales array that is the same length as the number of instances, all populated with 0
|
||||
@@ -1436,12 +1359,8 @@ pub(crate) async fn create_evm_vka(
|
||||
) -> Result<String, EZKLError> {
|
||||
log::warn!("Reusable verifier support is experimental and may change in the future. Use at your own risk.");
|
||||
let settings = GraphSettings::load(&settings_path)?;
|
||||
let commitment: Commitments = settings.run_args.commitment.into();
|
||||
let params = load_params_verifier::<KZGCommitmentScheme<Bn256>>(
|
||||
srs_path,
|
||||
settings.run_args.logrows,
|
||||
commitment,
|
||||
)?;
|
||||
let params =
|
||||
load_params_verifier::<KZGCommitmentScheme<Bn256>>(srs_path, settings.run_args.logrows)?;
|
||||
|
||||
let num_poseidon_instance = settings.module_sizes.num_instances().iter().sum::<usize>();
|
||||
let num_fixed_point_instance = settings
|
||||
@@ -1554,7 +1473,7 @@ pub(crate) fn encode_evm_calldata(
|
||||
calldata_path: PathBuf,
|
||||
vka_path: Option<PathBuf>,
|
||||
) -> Result<Vec<u8>, EZKLError> {
|
||||
let snark = Snark::load::<IPACommitmentScheme<G1Affine>>(&proof_path)?;
|
||||
let snark = Snark::load::<KZGCommitmentScheme<Bn256>>(&proof_path)?;
|
||||
|
||||
let flattened_instances = snark.instances.into_iter().flatten();
|
||||
|
||||
@@ -1639,34 +1558,14 @@ pub(crate) fn setup(
|
||||
}
|
||||
|
||||
let logrows = circuit.settings().run_args.logrows;
|
||||
let commitment: Commitments = circuit.settings().run_args.commitment.into();
|
||||
|
||||
let pk = match commitment {
|
||||
Commitments::KZG => {
|
||||
let params = load_params_prover::<KZGCommitmentScheme<Bn256>>(
|
||||
srs_path,
|
||||
logrows,
|
||||
Commitments::KZG,
|
||||
)?;
|
||||
create_keys::<KZGCommitmentScheme<Bn256>, GraphCircuit>(
|
||||
&circuit,
|
||||
¶ms,
|
||||
disable_selector_compression,
|
||||
)?
|
||||
}
|
||||
Commitments::IPA => {
|
||||
let params = load_params_prover::<IPACommitmentScheme<G1Affine>>(
|
||||
srs_path,
|
||||
logrows,
|
||||
Commitments::IPA,
|
||||
)?;
|
||||
create_keys::<IPACommitmentScheme<G1Affine>, GraphCircuit>(
|
||||
&circuit,
|
||||
¶ms,
|
||||
disable_selector_compression,
|
||||
)?
|
||||
}
|
||||
};
|
||||
let params = load_params_prover::<KZGCommitmentScheme<Bn256>>(srs_path, logrows)?;
|
||||
let pk = create_keys::<KZGCommitmentScheme<Bn256>, GraphCircuit>(
|
||||
&circuit,
|
||||
¶ms,
|
||||
disable_selector_compression,
|
||||
)?;
|
||||
|
||||
save_vk::<G1Affine>(&vk_path, pk.get_vk())?;
|
||||
save_pk::<G1Affine>(&pk_path, &pk)?;
|
||||
Ok(String::new())
|
||||
@@ -1693,69 +1592,30 @@ pub(crate) fn prove(
|
||||
|
||||
let proof_split_commits: Option<ProofSplitCommit> = data.into();
|
||||
|
||||
let commitment = circuit_settings.run_args.commitment.into();
|
||||
let logrows = circuit_settings.run_args.logrows;
|
||||
// creates and verifies the proof
|
||||
let mut snark = match commitment {
|
||||
Commitments::KZG => {
|
||||
let pk =
|
||||
load_pk::<KZGCommitmentScheme<Bn256>, GraphCircuit>(pk_path, circuit.params())?;
|
||||
|
||||
let params = load_params_prover::<KZGCommitmentScheme<Bn256>>(
|
||||
srs_path,
|
||||
logrows,
|
||||
Commitments::KZG,
|
||||
)?;
|
||||
create_proof_circuit::<
|
||||
KZGCommitmentScheme<Bn256>,
|
||||
_,
|
||||
ProverSHPLONK<_>,
|
||||
VerifierSHPLONK<_>,
|
||||
KZGSingleStrategy<_>,
|
||||
_,
|
||||
EvmTranscript<_, _, _, _>,
|
||||
EvmTranscript<_, _, _, _>,
|
||||
>(
|
||||
circuit,
|
||||
vec![public_inputs],
|
||||
¶ms,
|
||||
&pk,
|
||||
check_mode,
|
||||
commitment,
|
||||
proof_split_commits,
|
||||
None,
|
||||
)
|
||||
}
|
||||
Commitments::IPA => {
|
||||
let pk =
|
||||
load_pk::<IPACommitmentScheme<G1Affine>, GraphCircuit>(pk_path, circuit.params())?;
|
||||
let pk = load_pk::<KZGCommitmentScheme<Bn256>, GraphCircuit>(pk_path, circuit.params())?;
|
||||
|
||||
let params = load_params_prover::<IPACommitmentScheme<G1Affine>>(
|
||||
srs_path,
|
||||
circuit_settings.run_args.logrows,
|
||||
Commitments::IPA,
|
||||
)?;
|
||||
create_proof_circuit::<
|
||||
IPACommitmentScheme<G1Affine>,
|
||||
_,
|
||||
ProverIPA<_>,
|
||||
VerifierIPA<_>,
|
||||
IPASingleStrategy<_>,
|
||||
_,
|
||||
EvmTranscript<_, _, _, _>,
|
||||
EvmTranscript<_, _, _, _>,
|
||||
>(
|
||||
circuit,
|
||||
vec![public_inputs],
|
||||
¶ms,
|
||||
&pk,
|
||||
check_mode,
|
||||
commitment,
|
||||
proof_split_commits,
|
||||
None,
|
||||
)
|
||||
}
|
||||
}?;
|
||||
let params = load_params_prover::<KZGCommitmentScheme<Bn256>>(srs_path, logrows)?;
|
||||
let mut snark = create_proof_circuit::<
|
||||
KZGCommitmentScheme<Bn256>,
|
||||
_,
|
||||
ProverSHPLONK<_>,
|
||||
VerifierSHPLONK<_>,
|
||||
KZGSingleStrategy<_>,
|
||||
_,
|
||||
EvmTranscript<_, _, _, _>,
|
||||
EvmTranscript<_, _, _, _>,
|
||||
>(
|
||||
circuit,
|
||||
vec![public_inputs],
|
||||
¶ms,
|
||||
&pk,
|
||||
check_mode,
|
||||
proof_split_commits,
|
||||
None,
|
||||
)?;
|
||||
|
||||
snark.pretty_public_inputs = pretty_public_inputs;
|
||||
|
||||
@@ -1774,7 +1634,11 @@ pub(crate) fn swap_proof_commitments_cmd(
|
||||
let witness = GraphWitness::from_path(witness)?;
|
||||
let commitments = witness.get_polycommitments();
|
||||
|
||||
let snark_new = swap_proof_commitments_polycommit(&snark, &commitments)?;
|
||||
let snark_new = swap_proof_commitments::<
|
||||
KZGCommitmentScheme<Bn256>,
|
||||
_,
|
||||
EvmTranscript<G1Affine, _, _, _>,
|
||||
>(&snark, &commitments)?;
|
||||
|
||||
if snark_new.proof != *snark.proof {
|
||||
log::warn!("swap proof has created a different proof");
|
||||
@@ -1794,51 +1658,23 @@ pub(crate) fn verify(
|
||||
let circuit_settings = GraphSettings::load(&settings_path)?;
|
||||
|
||||
let logrows = circuit_settings.run_args.logrows;
|
||||
let commitment = circuit_settings.run_args.commitment.into();
|
||||
|
||||
match commitment {
|
||||
Commitments::KZG => {
|
||||
let params: ParamsKZG<Bn256> = if reduced_srs {
|
||||
// only need G_0 for the verification with shplonk
|
||||
load_params_verifier::<KZGCommitmentScheme<Bn256>>(srs_path, 1, Commitments::KZG)?
|
||||
} else {
|
||||
load_params_verifier::<KZGCommitmentScheme<Bn256>>(
|
||||
srs_path,
|
||||
logrows,
|
||||
Commitments::KZG,
|
||||
)?
|
||||
};
|
||||
{
|
||||
verify_commitment::<
|
||||
KZGCommitmentScheme<Bn256>,
|
||||
VerifierSHPLONK<'_, Bn256>,
|
||||
_,
|
||||
KZGSingleStrategy<_>,
|
||||
EvmTranscript<G1Affine, _, _, _>,
|
||||
GraphCircuit,
|
||||
_,
|
||||
>(proof_path, circuit_settings, vk_path, ¶ms, logrows)
|
||||
}
|
||||
}
|
||||
Commitments::IPA => {
|
||||
let params: ParamsIPA<_> = load_params_verifier::<IPACommitmentScheme<G1Affine>>(
|
||||
srs_path,
|
||||
logrows,
|
||||
Commitments::IPA,
|
||||
)?;
|
||||
{
|
||||
verify_commitment::<
|
||||
IPACommitmentScheme<G1Affine>,
|
||||
VerifierIPA<_>,
|
||||
_,
|
||||
IPASingleStrategy<_>,
|
||||
EvmTranscript<G1Affine, _, _, _>,
|
||||
GraphCircuit,
|
||||
_,
|
||||
>(proof_path, circuit_settings, vk_path, ¶ms, logrows)
|
||||
}
|
||||
}
|
||||
}
|
||||
let params: ParamsKZG<Bn256> = if reduced_srs {
|
||||
// only need G_0 for the verification with shplonk
|
||||
load_params_verifier::<KZGCommitmentScheme<Bn256>>(srs_path, 1)?
|
||||
} else {
|
||||
load_params_verifier::<KZGCommitmentScheme<Bn256>>(srs_path, logrows)?
|
||||
};
|
||||
|
||||
verify_commitment::<
|
||||
KZGCommitmentScheme<Bn256>,
|
||||
VerifierSHPLONK<'_, Bn256>,
|
||||
_,
|
||||
KZGSingleStrategy<_>,
|
||||
EvmTranscript<G1Affine, _, _, _>,
|
||||
GraphCircuit,
|
||||
_,
|
||||
>(proof_path, circuit_settings, vk_path, ¶ms, logrows)
|
||||
}
|
||||
|
||||
fn verify_commitment<
|
||||
@@ -1889,9 +1725,8 @@ where
|
||||
pub(crate) fn load_params_verifier<Scheme: CommitmentScheme>(
|
||||
srs_path: Option<PathBuf>,
|
||||
logrows: u32,
|
||||
commitment: Commitments,
|
||||
) -> Result<Scheme::ParamsVerifier, EZKLError> {
|
||||
let srs_path = get_srs_path(logrows, srs_path, commitment);
|
||||
let srs_path = get_srs_path(logrows, srs_path);
|
||||
let mut params = load_srs_verifier::<Scheme>(srs_path)?;
|
||||
if logrows < params.k() {
|
||||
info!("downsizing params to {} logrows", logrows);
|
||||
@@ -1904,9 +1739,8 @@ pub(crate) fn load_params_verifier<Scheme: CommitmentScheme>(
|
||||
pub(crate) fn load_params_prover<Scheme: CommitmentScheme>(
|
||||
srs_path: Option<PathBuf>,
|
||||
logrows: u32,
|
||||
commitment: Commitments,
|
||||
) -> Result<Scheme::ParamsProver, EZKLError> {
|
||||
let srs_path = get_srs_path(logrows, srs_path, commitment);
|
||||
let srs_path = get_srs_path(logrows, srs_path);
|
||||
let mut params = load_srs_prover::<Scheme>(srs_path)?;
|
||||
if logrows < params.k() {
|
||||
info!("downsizing params to {} logrows", logrows);
|
||||
|
||||
84
src/lib.rs
84
src/lib.rs
@@ -98,18 +98,11 @@ impl From<String> for EZKLError {
|
||||
EZKLError::UncategorizedError(s)
|
||||
}
|
||||
}
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use circuit::{table::Range, CheckMode};
|
||||
#[cfg(all(feature = "ezkl", not(target_arch = "wasm32")))]
|
||||
use clap::Args;
|
||||
use fieldutils::IntegerRep;
|
||||
use graph::{Visibility, MAX_PUBLIC_SRS};
|
||||
use halo2_proofs::poly::{
|
||||
ipa::commitment::IPACommitmentScheme, kzg::commitment::KZGCommitmentScheme,
|
||||
};
|
||||
use halo2curves::bn256::{Bn256, G1Affine};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(all(feature = "ezkl", not(target_arch = "wasm32")))]
|
||||
use tosubcommand::ToFlags;
|
||||
@@ -193,78 +186,6 @@ const EZKL_KEY_FORMAT: &str = "raw-bytes";
|
||||
#[cfg(any(not(feature = "ezkl"), target_arch = "wasm32"))]
|
||||
const EZKL_BUF_CAPACITY: &usize = &8000;
|
||||
|
||||
#[derive(
|
||||
Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize, Default, Copy,
|
||||
)]
|
||||
/// Commitment scheme
|
||||
pub enum Commitments {
|
||||
#[default]
|
||||
/// KZG
|
||||
KZG,
|
||||
/// IPA
|
||||
IPA,
|
||||
}
|
||||
|
||||
impl From<Option<Commitments>> for Commitments {
|
||||
fn from(value: Option<Commitments>) -> Self {
|
||||
value.unwrap_or(Commitments::KZG)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Commitments {
|
||||
type Err = String;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s.to_lowercase().as_str() {
|
||||
"kzg" => Ok(Commitments::KZG),
|
||||
"ipa" => Ok(Commitments::IPA),
|
||||
_ => Err("Invalid value for Commitments".to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<KZGCommitmentScheme<Bn256>> for Commitments {
|
||||
fn from(_value: KZGCommitmentScheme<Bn256>) -> Self {
|
||||
Commitments::KZG
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IPACommitmentScheme<G1Affine>> for Commitments {
|
||||
fn from(_value: IPACommitmentScheme<G1Affine>) -> Self {
|
||||
Commitments::IPA
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Commitments {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Commitments::KZG => write!(f, "kzg"),
|
||||
Commitments::IPA => write!(f, "ipa"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "ezkl", not(target_arch = "wasm32")))]
|
||||
impl ToFlags for Commitments {
|
||||
/// Convert the struct to a subcommand string
|
||||
fn to_flags(&self) -> Vec<String> {
|
||||
vec![format!("{}", self)]
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Commitments {
|
||||
fn from(value: String) -> Self {
|
||||
match value.to_lowercase().as_str() {
|
||||
"kzg" => Commitments::KZG,
|
||||
"ipa" => Commitments::IPA,
|
||||
_ => {
|
||||
log::error!("Invalid value for Commitments");
|
||||
log::warn!("defaulting to KZG");
|
||||
Commitments::KZG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Parameters specific to a proving run
|
||||
///
|
||||
/// RunArgs contains all configuration parameters needed to control the proving process,
|
||||
@@ -331,10 +252,6 @@ pub struct RunArgs {
|
||||
/// Controls level of constraint verification
|
||||
#[cfg_attr(all(feature = "ezkl", not(target_arch = "wasm32")), arg(long, default_value = "unsafe", value_hint = clap::ValueHint::Other))]
|
||||
pub check_mode: CheckMode,
|
||||
/// Commitment scheme for circuit proving
|
||||
/// Affects proof size and verification time
|
||||
#[cfg_attr(all(feature = "ezkl", not(target_arch = "wasm32")), arg(long, default_value = "kzg", value_hint = clap::ValueHint::Other))]
|
||||
pub commitment: Option<Commitments>,
|
||||
/// Base for number decomposition
|
||||
/// Must be a power of 2
|
||||
#[cfg_attr(all(feature = "ezkl", not(target_arch = "wasm32")), arg(long, default_value = "16384", value_hint = clap::ValueHint::Other))]
|
||||
@@ -395,7 +312,6 @@ impl Default for RunArgs {
|
||||
param_visibility: Visibility::Fixed,
|
||||
rebase_frac_zero_constants: false,
|
||||
check_mode: CheckMode::UNSAFE,
|
||||
commitment: None,
|
||||
decomp_base: 16384,
|
||||
decomp_legs: 2,
|
||||
ignore_range_check_inputs_outputs: false,
|
||||
|
||||
@@ -10,13 +10,11 @@ use std::borrow::Borrow;
|
||||
|
||||
use crate::circuit::CheckMode;
|
||||
use crate::graph::GraphWitness;
|
||||
use crate::{Commitments, EZKL_BUF_CAPACITY, EZKL_KEY_FORMAT};
|
||||
use crate::{EZKL_BUF_CAPACITY, EZKL_KEY_FORMAT};
|
||||
use halo2_proofs::plonk::{
|
||||
create_proof, keygen_pk, keygen_vk_custom, verify_proof, Circuit, ProvingKey, VerifyingKey,
|
||||
};
|
||||
use halo2_proofs::poly::commitment::{CommitmentScheme, Params, ParamsProver, Prover, Verifier};
|
||||
use halo2_proofs::poly::ipa::commitment::IPACommitmentScheme;
|
||||
use halo2_proofs::poly::kzg::commitment::KZGCommitmentScheme;
|
||||
use halo2_proofs::poly::VerificationStrategy;
|
||||
use halo2_proofs::transcript::{EncodedChallenge, TranscriptReadBuffer, TranscriptWriterBuffer};
|
||||
use halo2curves::ff::{FromUniformBytes, PrimeField, WithSmallOrderMulGroup};
|
||||
@@ -30,7 +28,6 @@ use rand::rngs::OsRng;
|
||||
use rand::rngs::StdRng;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use snark_verifier::system::halo2::transcript::evm::EvmTranscript;
|
||||
use snark_verifier::verifier::plonk::PlonkProtocol;
|
||||
use std::fs::File;
|
||||
use std::io::{self, BufReader, BufWriter, Cursor, Write};
|
||||
@@ -41,8 +38,6 @@ use thiserror::Error as thisError;
|
||||
#[cfg(feature = "python-bindings")]
|
||||
use pyo3::types::PyDictMethods;
|
||||
|
||||
use halo2curves::bn256::{Bn256, Fr, G1Affine};
|
||||
|
||||
/// Converts a string to a `SerdeFormat`.
|
||||
/// # Panics
|
||||
/// Panics if the provided `s` is not a valid `SerdeFormat` (i.e. not one of "processed", "raw-bytes-unchecked", or "raw-bytes").
|
||||
@@ -138,6 +133,9 @@ pub enum PfSysError {
|
||||
PackingExponent,
|
||||
}
|
||||
|
||||
#[cfg(feature = "python-bindings")]
|
||||
use halo2curves::bn256::G1Affine;
|
||||
|
||||
#[cfg(feature = "python-bindings")]
|
||||
///
|
||||
pub fn g1affine_to_pydict(g1affine_dict: &pyo3::Bound<'_, PyDict>, g1affine: &G1Affine) {
|
||||
@@ -216,8 +214,6 @@ where
|
||||
pub pretty_public_inputs: Option<PrettyElements>,
|
||||
/// timestamp
|
||||
pub timestamp: Option<u128>,
|
||||
/// commitment
|
||||
pub commitment: Option<Commitments>,
|
||||
/// (optional) version of ezkl used to generate the proof
|
||||
version: Option<String>,
|
||||
}
|
||||
@@ -266,7 +262,6 @@ where
|
||||
hex_proof: Option<String>,
|
||||
split: Option<ProofSplitCommit>,
|
||||
pretty_public_inputs: Option<PrettyElements>,
|
||||
commitment: Option<Commitments>,
|
||||
) -> Self {
|
||||
Self {
|
||||
protocol,
|
||||
@@ -282,7 +277,6 @@ where
|
||||
.unwrap()
|
||||
.as_millis(),
|
||||
),
|
||||
commitment,
|
||||
version: Some(crate::version().to_string()),
|
||||
}
|
||||
}
|
||||
@@ -423,7 +417,6 @@ pub fn create_proof_circuit<
|
||||
params: &'params Scheme::ParamsProver,
|
||||
pk: &ProvingKey<Scheme::Curve>,
|
||||
check_mode: CheckMode,
|
||||
commitment: Commitments,
|
||||
split: Option<ProofSplitCommit>,
|
||||
protocol: Option<PlonkProtocol<Scheme::Curve>>,
|
||||
) -> Result<Snark<Scheme::Scalar, Scheme::Curve>, PfsysError>
|
||||
@@ -471,15 +464,7 @@ where
|
||||
let proof = transcript.finalize();
|
||||
let hex_proof = format!("0x{}", hex::encode(&proof));
|
||||
|
||||
let checkable_pf = Snark::new(
|
||||
protocol,
|
||||
instances,
|
||||
proof,
|
||||
Some(hex_proof),
|
||||
split,
|
||||
None,
|
||||
Some(commitment),
|
||||
);
|
||||
let checkable_pf = Snark::new(protocol, instances, proof, Some(hex_proof), split, None);
|
||||
|
||||
// sanity check that the generated proof is valid
|
||||
if check_mode == CheckMode::SAFE {
|
||||
@@ -568,30 +553,6 @@ where
|
||||
Ok(proof_first_bytes)
|
||||
}
|
||||
|
||||
/// Swap the proof commitments to a new set in the proof for KZG
|
||||
pub fn swap_proof_commitments_polycommit(
|
||||
snark: &Snark<Fr, G1Affine>,
|
||||
commitments: &[G1Affine],
|
||||
) -> Result<Snark<Fr, G1Affine>, PfsysError> {
|
||||
let proof = match snark.commitment {
|
||||
Some(Commitments::KZG) => swap_proof_commitments::<
|
||||
KZGCommitmentScheme<Bn256>,
|
||||
_,
|
||||
EvmTranscript<G1Affine, _, _, _>,
|
||||
>(snark, commitments)?,
|
||||
Some(Commitments::IPA) => swap_proof_commitments::<
|
||||
IPACommitmentScheme<G1Affine>,
|
||||
_,
|
||||
EvmTranscript<G1Affine, _, _, _>,
|
||||
>(snark, commitments)?,
|
||||
None => {
|
||||
return Err(PfsysError::InvalidCommitmentScheme);
|
||||
}
|
||||
};
|
||||
|
||||
Ok(proof)
|
||||
}
|
||||
|
||||
/// A wrapper around halo2's verify_proof
|
||||
pub fn verify_proof_circuit<
|
||||
'params,
|
||||
@@ -753,7 +714,6 @@ mod tests {
|
||||
split: None,
|
||||
pretty_public_inputs: None,
|
||||
timestamp: None,
|
||||
commitment: None,
|
||||
version: None,
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ mod native_tests {
|
||||
use ezkl::graph::input::GraphData;
|
||||
use ezkl::graph::GraphSettings;
|
||||
use ezkl::pfsys::Snark;
|
||||
use ezkl::Commitments;
|
||||
use halo2_proofs::poly::kzg::commitment::KZGCommitmentScheme;
|
||||
use halo2curves::bn256::Bn256;
|
||||
use lazy_static::lazy_static;
|
||||
@@ -92,16 +91,10 @@ mod native_tests {
|
||||
});
|
||||
}
|
||||
|
||||
fn download_srs(logrows: u32, commitment: Commitments) {
|
||||
fn download_srs(logrows: u32) {
|
||||
// if does not exist, download it
|
||||
let status = Command::new(format!("{}/{}", *CARGO_TARGET_DIR, TEST_BINARY))
|
||||
.args([
|
||||
"get-srs",
|
||||
"--logrows",
|
||||
&format!("{}", logrows),
|
||||
"--commitment",
|
||||
&commitment.to_string(),
|
||||
])
|
||||
.args(["get-srs", "--logrows", &format!("{}", logrows)])
|
||||
.status()
|
||||
.expect("failed to execute process");
|
||||
assert!(status.success());
|
||||
@@ -116,7 +109,7 @@ mod native_tests {
|
||||
let settings: GraphSettings = serde_json::from_str(&settings).unwrap();
|
||||
let logrows = settings.run_args.logrows;
|
||||
|
||||
download_srs(logrows, settings.run_args.commitment.into());
|
||||
download_srs(logrows);
|
||||
}
|
||||
|
||||
fn mv_test_(test_dir: &str, test: &str) {
|
||||
@@ -346,7 +339,6 @@ mod native_tests {
|
||||
use crate::native_tests::model_serialization_different_binaries;
|
||||
|
||||
use tempdir::TempDir;
|
||||
use ezkl::Commitments;
|
||||
|
||||
#[test]
|
||||
fn model_serialization_different_binaries_() {
|
||||
@@ -625,7 +617,7 @@ mod native_tests {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -634,7 +626,7 @@ mod native_tests {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 3, None, false, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 3, None, false, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -643,7 +635,7 @@ mod native_tests {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 4, None, false, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 4, None, false, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -652,7 +644,7 @@ mod native_tests {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 8, None, false, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 8, None, false, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -661,7 +653,7 @@ mod native_tests {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -672,25 +664,17 @@ mod native_tests {
|
||||
let path = test_dir.into_path();
|
||||
let path = path.to_str().unwrap();
|
||||
crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, Commitments::KZG, 1);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, 1);
|
||||
// test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
#(#[test_case(TESTS[N])])*
|
||||
fn ipa_prove_and_verify_(test: &str) {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, Commitments::IPA, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
#(#[test_case(TESTS[N])])*
|
||||
fn kzg_prove_and_verify_public_input_(test: &str) {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "public", "private", "public", 1, None, false, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "public", "private", "public", 1, None, false, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -699,7 +683,7 @@ mod native_tests {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "fixed", "public", 1, None, false, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "fixed", "public", 1, None, false, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -708,7 +692,7 @@ mod native_tests {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "hashed", 1, None, false, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "hashed", 1, None, false, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -717,16 +701,7 @@ mod native_tests {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "polycommit", 1, None, false, Commitments::KZG, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
#(#[test_case(TESTS[N])])*
|
||||
fn ipa_prove_and_verify_ipa_output(test: &str) {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "polycommit", 1, None, false, Commitments::IPA, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "polycommit", 1, None, false, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -740,7 +715,7 @@ mod native_tests {
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
env_logger::init();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, true, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, true, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -750,7 +725,7 @@ mod native_tests {
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
env_logger::init();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "hashed", "private", "public", 1, None, true, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "hashed", "private", "public", 1, None, true, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -760,7 +735,7 @@ mod native_tests {
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
env_logger::init();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "fixed", "public", 1, None, true, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "safe", "private", "fixed", "public", 1, None, true, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -774,7 +749,7 @@ mod native_tests {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
prove_and_verify(path, test.to_string(), "unsafe", "private", "fixed", "public", 1, None, false, Commitments::KZG, 2);
|
||||
prove_and_verify(path, test.to_string(), "unsafe", "private", "fixed", "public", 1, None, false, 2);
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
|
||||
@@ -1146,7 +1121,6 @@ mod native_tests {
|
||||
cal_target,
|
||||
scales_to_use,
|
||||
2,
|
||||
Commitments::KZG,
|
||||
2,
|
||||
bounded_lookup_log,
|
||||
decomp_base,
|
||||
@@ -1177,7 +1151,6 @@ mod native_tests {
|
||||
cal_target: &str,
|
||||
scales_to_use: Option<Vec<u32>>,
|
||||
num_inner_columns: usize,
|
||||
commitment: Commitments,
|
||||
lookup_safety_margin: usize,
|
||||
bounded_lookup_log: bool,
|
||||
decomp_base: Option<usize>,
|
||||
@@ -1199,7 +1172,6 @@ mod native_tests {
|
||||
format!("--param-visibility={}", param_visibility),
|
||||
format!("--output-visibility={}", output_visibility),
|
||||
format!("--num-inner-cols={}", num_inner_columns),
|
||||
format!("--commitment={}", commitment),
|
||||
format!("--logrows={}", 22),
|
||||
];
|
||||
|
||||
@@ -1310,7 +1282,6 @@ mod native_tests {
|
||||
cal_target,
|
||||
None,
|
||||
2,
|
||||
Commitments::KZG,
|
||||
2,
|
||||
false,
|
||||
None,
|
||||
@@ -1349,7 +1320,7 @@ mod native_tests {
|
||||
num_inner_columns: usize,
|
||||
scales_to_use: Option<Vec<u32>>,
|
||||
overflow: bool,
|
||||
commitment: Commitments,
|
||||
|
||||
lookup_safety_margin: usize,
|
||||
) {
|
||||
let target_str = if overflow {
|
||||
@@ -1368,7 +1339,6 @@ mod native_tests {
|
||||
target_str,
|
||||
scales_to_use,
|
||||
num_inner_columns,
|
||||
commitment,
|
||||
lookup_safety_margin,
|
||||
false,
|
||||
None,
|
||||
@@ -1436,15 +1406,8 @@ mod native_tests {
|
||||
.expect("failed to execute process");
|
||||
assert!(status.success());
|
||||
|
||||
// load settings file
|
||||
let settings =
|
||||
std::fs::read_to_string(settings_path.clone()).expect("failed to read settings file");
|
||||
|
||||
let graph_settings = serde_json::from_str::<GraphSettings>(&settings)
|
||||
.expect("failed to parse settings file");
|
||||
|
||||
// get_srs for the graph_settings_num_instances
|
||||
download_srs(1, graph_settings.run_args.commitment.into());
|
||||
download_srs(1);
|
||||
|
||||
let status = Command::new(format!("{}/{}", *CARGO_TARGET_DIR, TEST_BINARY))
|
||||
.args([
|
||||
@@ -1482,7 +1445,6 @@ mod native_tests {
|
||||
num_inner_columns,
|
||||
None,
|
||||
false,
|
||||
Commitments::KZG,
|
||||
2,
|
||||
);
|
||||
|
||||
@@ -1608,7 +1570,6 @@ mod native_tests {
|
||||
num_inner_columns,
|
||||
None,
|
||||
overflow,
|
||||
Commitments::KZG,
|
||||
2,
|
||||
);
|
||||
|
||||
|
||||
@@ -199,7 +199,8 @@ async def test_get_srs():
|
||||
another_srs_path = os.path.join(folder_path, "kzg_test_k8.params")
|
||||
|
||||
res = await ezkl.get_srs(
|
||||
logrows=8, srs_path=another_srs_path, commitment=ezkl.PyCommitments.KZG
|
||||
logrows=8,
|
||||
srs_path=another_srs_path,
|
||||
)
|
||||
|
||||
assert os.path.isfile(another_srs_path)
|
||||
|
||||
Reference in New Issue
Block a user