Skip to content

Commit

Permalink
refactor: print_proof_hex is redundant with proof file (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-camuto authored Feb 14, 2024
1 parent abcd538 commit 1b637a7
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 43 deletions.
8 changes: 0 additions & 8 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,12 +795,4 @@ pub enum Commands {
#[arg(long)]
addr_vk: Option<H160>,
},

/// Print the proof in hexadecimal
#[command(name = "print-proof-hex")]
PrintProofHex {
/// The path to the proof file
#[arg(long, default_value = DEFAULT_PROOF)]
proof_path: PathBuf,
},
}
11 changes: 0 additions & 11 deletions src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ pub async fn run(command: Commands) -> Result<String, Box<dyn Error>> {
addr_da,
addr_vk,
} => verify_evm(proof_path, addr_verifier, rpc_url, addr_da, addr_vk).await,
Commands::PrintProofHex { proof_path } => print_proof_hex(proof_path),
}
}

Expand Down Expand Up @@ -1169,16 +1168,6 @@ pub(crate) fn mock(
Ok(String::new())
}

pub(crate) fn print_proof_hex(proof_path: PathBuf) -> Result<String, Box<dyn Error>> {
let proof = Snark::load::<KZGCommitmentScheme<Bn256>>(&proof_path)?;
for instance in proof.instances {
println!("{:?}", instance);
}
let hex_str = hex::encode(proof.proof);
info!("0x{}", hex_str);
Ok(format!("0x{}", hex_str))
}

#[cfg(feature = "render")]
pub(crate) fn render(
model: PathBuf,
Expand Down
13 changes: 1 addition & 12 deletions src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::graph::{
use crate::pfsys::evm::aggregation::AggregationCircuit;
use crate::pfsys::{
load_pk, load_vk, save_params, save_vk, srs::gen_srs as ezkl_gen_srs, srs::load_srs, ProofType,
Snark, TranscriptType,
TranscriptType,
};
use crate::RunArgs;
use ethers::types::H160;
Expand Down Expand Up @@ -1097,16 +1097,6 @@ fn create_evm_verifier_aggr(
Ok(true)
}

/// print hex representation of a proof
#[pyfunction(signature = (proof_path))]
fn print_proof_hex(proof_path: PathBuf) -> Result<String, PyErr> {
let proof = Snark::load::<KZGCommitmentScheme<Bn256>>(&proof_path)
.map_err(|_| PyIOError::new_err("Failed to load proof"))?;

let hex_str = hex::encode(proof.proof);
Ok(format!("0x{}", hex_str))
}

// Python Module
#[pymodule]
fn ezkl(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
Expand Down Expand Up @@ -1145,7 +1135,6 @@ fn ezkl(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(deploy_vk_evm, m)?)?;
m.add_function(wrap_pyfunction!(deploy_da_evm, m)?)?;
m.add_function(wrap_pyfunction!(verify_evm, m)?)?;
m.add_function(wrap_pyfunction!(print_proof_hex, m)?)?;
m.add_function(wrap_pyfunction!(setup_test_evm_witness, m)?)?;
m.add_function(wrap_pyfunction!(create_evm_verifier_aggr, m)?)?;
m.add_function(wrap_pyfunction!(create_evm_data_attestation, m)?)?;
Expand Down
4 changes: 1 addition & 3 deletions tests/python/binding_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,7 @@ def test_prove_evm():
assert res['transcript_type'] == 'EVM'
assert os.path.isfile(proof_path)

res = ezkl.print_proof_hex(proof_path)
# to figure out a better way of testing print_proof_hex
assert type(res) == str



def test_create_evm_verifier():
Expand Down
9 changes: 0 additions & 9 deletions tests/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,6 @@ mod wasm32 {
assert!(value);
}

#[wasm_bindgen_test]
async fn print_proof_hex_test() {
let proof = printProofHex(wasm_bindgen::Clamped(PROOF.to_vec()))
.map_err(|_| "failed")
.unwrap();

assert!(proof.len() > 0);
}

#[wasm_bindgen_test]
async fn verify_validations() {
// Run witness validation on network (should fail)
Expand Down

0 comments on commit 1b637a7

Please sign in to comment.