Compare commits

...

10 Commits

Author SHA1 Message Date
dante
5a8498894d feat: create encode-evm-calldata in cli and python (#803) 2024-05-29 21:03:16 -04:00
Snoppy
095c0ca5b4 chore: fix typos (#802) 2024-05-29 11:32:11 -04:00
dante
3fa482c9ef fix: remove error messages in calibration loop (confusing) (#800) 2024-05-22 09:32:52 +01:00
dante
6be3b1d663 chore: update alloy (#798) 2024-05-16 12:10:27 +09:00
dante
d5a1d1439c fix: elif syntax in install script 2024-05-14 03:31:26 +09:00
Ethan Cemer
ff8fd01f86 fix: patch invalid ${{ github.ref_name#v }} syntax on verify release script (#791) 2024-05-14 02:25:12 +09:00
dante
e9020f942e fix: python build matrix (#797) 2024-05-13 13:29:51 +09:00
dante
e7f54cb6ac fix: windows build (#796) 2024-05-13 12:47:36 +09:00
dante
ed65e8c090 Revert "fix: revert maturin version (#795)"
This reverts commit d9f2adad99.
2024-05-13 12:41:02 +09:00
dante
d9f2adad99 fix: revert maturin version (#795) 2024-05-13 12:21:35 +09:00
20 changed files with 210 additions and 51 deletions

View File

@@ -50,6 +50,7 @@ jobs:
target: ${{ matrix.target }}
args: --release --out dist --features python-bindings
- name: Install built wheel
if: matrix.target == 'universal2-apple-darwin'
run: |
pip install ezkl --no-index --find-links dist --force-reinstall
python -c "import ezkl"
@@ -110,7 +111,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
target: [x86_64, i686]
target: [x86_64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4

View File

@@ -26,22 +26,25 @@ jobs:
RELEASE_TAG: ${{ github.ref_name }}
run: |
sed -i "s|\"version\": \".*\"|\"version\": \"${{ github.ref_name }}\"|" in-browser-evm-verifier/package.json
- name: Prepare tag and fetch package integrity
run: |
CLEANED_TAG=${{ github.ref_name }} # Get the tag from ref_name
CLEANED_TAG="${CLEANED_TAG#v}" # Remove leading 'v'
echo "CLEANED_TAG=${CLEANED_TAG}" >> $GITHUB_ENV # Set it as an environment variable for later steps
ENGINE_INTEGRITY=$(npm view @ezkljs/engine@$CLEANED_TAG dist.integrity)
echo "ENGINE_INTEGRITY=$ENGINE_INTEGRITY" >> $GITHUB_ENV
- name: Update @ezkljs/engine version in package.json
shell: bash
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
sed -i "s|\"@ezkljs/engine\": \".*\"|\"@ezkljs/engine\": \"${{ github.ref_name#v }}\"|" in-browser-evm-verifier/package.json
sed -i "s|\"@ezkljs/engine\": \".*\"|\"@ezkljs/engine\": \"$CLEANED_TAG\"|" in-browser-evm-verifier/package.json
- name: Update the engine import in in-browser-evm-verifier to use @ezkljs/engine package instead of the local one;
run: |
sed -i "s|import { encodeVerifierCalldata } from '../nodejs/ezkl';|import { encodeVerifierCalldata } from '@ezkljs/engine';|" in-browser-evm-verifier/src/index.ts
- name: Fetch integrity
run: |
ENGINE_INTEGRITY=$(npm view @ezkljs/engine@${{ github.ref_name#v }} dist.integrity)
echo "ENGINE_INTEGRITY=$ENGINE_INTEGRITY" >> $GITHUB_ENV
- name: Update pnpm-lock.yaml versions and integrity
run: |
awk -v integrity="$ENGINE_INTEGRITY" -v tag="${{ github.ref_name#v }}" '
awk -v integrity="$ENGINE_INTEGRITY" -v tag="$CLEANED_TAG" '
NR==30{$0=" specifier: \"" tag "\""}
NR==31{$0=" version: \"" tag "\""}
NR==400{$0=" /@ezkljs/engine@" tag ":"}
@@ -60,6 +63,6 @@ jobs:
cd in-browser-evm-verifier
pnpm install --frozen-lockfile
pnpm run build
pnpm publish
pnpm publish --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

35
Cargo.lock generated
View File

@@ -58,7 +58,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]]
name = "alloy"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-consensus",
"alloy-contract",
@@ -80,7 +80,7 @@ dependencies = [
[[package]]
name = "alloy-consensus"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-eips",
"alloy-primitives 0.7.2",
@@ -93,7 +93,7 @@ dependencies = [
[[package]]
name = "alloy-contract"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-dyn-abi",
"alloy-json-abi",
@@ -140,7 +140,7 @@ dependencies = [
[[package]]
name = "alloy-eips"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-primitives 0.7.2",
"alloy-rlp",
@@ -154,7 +154,7 @@ dependencies = [
[[package]]
name = "alloy-genesis"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-primitives 0.7.2",
"alloy-serde",
@@ -177,7 +177,7 @@ dependencies = [
[[package]]
name = "alloy-json-rpc"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-primitives 0.7.2",
"serde",
@@ -189,7 +189,7 @@ dependencies = [
[[package]]
name = "alloy-network"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-consensus",
"alloy-eips",
@@ -206,7 +206,7 @@ dependencies = [
[[package]]
name = "alloy-node-bindings"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-genesis",
"alloy-primitives 0.7.2",
@@ -261,7 +261,7 @@ dependencies = [
[[package]]
name = "alloy-provider"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-eips",
"alloy-json-rpc",
@@ -281,6 +281,7 @@ dependencies = [
"futures",
"futures-utils-wasm",
"lru",
"pin-project",
"reqwest",
"serde_json",
"tokio",
@@ -313,7 +314,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-client"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-json-rpc",
"alloy-transport",
@@ -333,7 +334,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-consensus",
"alloy-eips",
@@ -351,7 +352,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-trace"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-primitives 0.7.2",
"alloy-rpc-types",
@@ -363,7 +364,7 @@ dependencies = [
[[package]]
name = "alloy-serde"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-primitives 0.7.2",
"serde",
@@ -373,7 +374,7 @@ dependencies = [
[[package]]
name = "alloy-signer"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-primitives 0.7.2",
"async-trait",
@@ -386,7 +387,7 @@ dependencies = [
[[package]]
name = "alloy-signer-wallet"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-consensus",
"alloy-network",
@@ -459,7 +460,7 @@ dependencies = [
[[package]]
name = "alloy-transport"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-json-rpc",
"base64 0.22.1",
@@ -477,7 +478,7 @@ dependencies = [
[[package]]
name = "alloy-transport-http"
version = "0.1.0"
source = "git+https://github.com/alloy-rs/alloy#e60d64cff86d995657f0acea85c2bbd52f9bd810"
source = "git+https://github.com/alloy-rs/alloy?rev=5fbf57bac99edef9d8475190109a7ea9fb7e5e83#5fbf57bac99edef9d8475190109a7ea9fb7e5e83"
dependencies = [
"alloy-json-rpc",
"alloy-transport",

View File

@@ -47,7 +47,7 @@ metal = { git = "https://github.com/gfx-rs/metal-rs", optional = true }
# evm related deps
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
alloy = { git = "https://github.com/alloy-rs/alloy", version = "0.1.0", features = ["provider-http", "signers", "contract", "rpc-types-eth", "signer-wallet", "node-bindings"] }
alloy = { git = "https://github.com/alloy-rs/alloy", version = "0.1.0", rev="5fbf57bac99edef9d8475190109a7ea9fb7e5e83", features = ["provider-http", "signers", "contract", "rpc-types-eth", "signer-wallet", "node-bindings"] }
foundry-compilers = {version = "0.4.1", features = ["svm-solc"]}
ethabi = "18"
indicatif = { version = "0.17.5", features = ["rayon"] }

View File

@@ -157,6 +157,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b78d3cbf",
"metadata": {},
"outputs": [],
"source": [
@@ -192,7 +193,7 @@
"outputs": [],
"source": [
"# srs path\n",
"res = await ezkl.get_srs( settings_path)"
"res = ezkl.get_srs( settings_path)"
]
},
{
@@ -298,7 +299,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.12.3"
}
},
"nbformat": 4,

View File

@@ -169,7 +169,7 @@
"json.dump(data, open(cal_path, 'w'))\n",
"\n",
"\n",
"ezkl.calibrate_settings(cal_path, model_path, settings_path, \"resources\")"
"await ezkl.calibrate_settings(cal_path, model_path, settings_path, \"resources\")"
]
},
{
@@ -302,4 +302,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}

View File

@@ -170,7 +170,7 @@
"json.dump(data, open(cal_path, 'w'))\n",
"\n",
"\n",
"ezkl.calibrate_settings(cal_path, model_path, settings_path, \"resources\")"
"await ezkl.calibrate_settings(cal_path, model_path, settings_path, \"resources\")"
]
},
{

View File

@@ -126,7 +126,6 @@ elif [ "$PLATFORM" == "macos" ]; then
echo "Cleaning up"
rm "$EZKL_DIR/build-artifacts.ezkl-macos-aarch64.tar.gz"
else
JSON_RESPONSE=$(curl -s "$RELEASE_URL")
FILE_URL=$(echo "$JSON_RESPONSE" | grep -o 'https://github.com[^"]*' | grep "build-artifacts.ezkl-macos.tar.gz")
@@ -155,7 +154,7 @@ elif [ "$PLATFORM" == "linux" ]; then
echo "Cleaning up"
rm "$EZKL_DIR/build-artifacts.ezkl-linux-gnu.tar.gz"
else if [ "$ARCHITECTURE" == "aarch64" ]; then
elif [ "$ARCHITECTURE" == "aarch64" ]; then
JSON_RESPONSE=$(curl -s "$RELEASE_URL")
FILE_URL=$(echo "$JSON_RESPONSE" | grep -o 'https://github.com[^"]*' | grep "build-artifacts.ezkl-linux-aarch64.tar.gz")

View File

@@ -3910,7 +3910,7 @@ pub(crate) fn range_check<F: PrimeField + TensorType + PartialOrd + std::hash::H
let int_values = w.get_int_evals()?;
for v in int_values.iter() {
if v < &range.0 || v > &range.1 {
log::error!("Value ({:?}) out of range: {:?}", v, range);
log::warn!("Value ({:?}) out of range: {:?}", v, range);
return Err(Box::new(TensorError::TableLookupError));
}
}

View File

@@ -52,6 +52,8 @@ pub const DEFAULT_VERIFIER_AGGREGATED_ABI: &str = "verifier_aggr_abi.json";
pub const DEFAULT_VERIFIER_DA_ABI: &str = "verifier_da_abi.json";
/// Default solidity code
pub const DEFAULT_SOL_CODE: &str = "evm_deploy.sol";
/// Default calldata path
pub const DEFAULT_CALLDATA: &str = "calldata.bytes";
/// Default solidity code for aggregated proofs
pub const DEFAULT_SOL_CODE_AGGREGATED: &str = "evm_deploy_aggr.sol";
/// Default solidity code for data attestation
@@ -78,7 +80,7 @@ pub const DEFAULT_CALIBRATION_FILE: &str = "calibration.json";
pub const DEFAULT_LOOKUP_SAFETY_MARGIN: &str = "2";
/// Default Compress selectors
pub const DEFAULT_DISABLE_SELECTOR_COMPRESSION: &str = "false";
/// Default render vk seperately
/// Default render vk separately
pub const DEFAULT_RENDER_VK_SEPERATELY: &str = "false";
/// Default VK sol path
pub const DEFAULT_VK_SOL: &str = "vk.sol";
@@ -595,6 +597,20 @@ pub enum Commands {
check_mode: Option<CheckMode>,
},
#[cfg(not(target_arch = "wasm32"))]
/// Encodes a proof into evm calldata
#[command(name = "encode-evm-calldata")]
EncodeEvmCalldata {
/// The path to the proof file (generated using the prove command)
#[arg(long, default_value = DEFAULT_PROOF)]
proof_path: Option<PathBuf>,
/// The path to the Solidity code
#[arg(long, default_value = DEFAULT_CALLDATA)]
calldata_path: Option<PathBuf>,
/// The path to the verification key address (only used if the vk is rendered as a separate contract)
#[arg(long)]
addr_vk: Option<H160Flag>,
},
#[cfg(not(target_arch = "wasm32"))]
/// Creates an Evm verifier for a single proof
#[command(name = "create-evm-verifier")]
CreateEvmVerifier {

View File

@@ -23,7 +23,6 @@ use alloy::providers::fillers::{
use alloy::providers::network::{Ethereum, EthereumSigner};
use alloy::providers::ProviderBuilder;
use alloy::providers::{Identity, Provider, RootProvider};
use alloy::rpc::types::eth::BlockId;
use alloy::rpc::types::eth::TransactionInput;
use alloy::rpc::types::eth::TransactionRequest;
use alloy::signers::wallet::LocalWallet;
@@ -591,7 +590,7 @@ pub async fn verify_proof_via_solidity(
return Err(Box::new(EvmVerificationError::InvalidProof));
}
let gas = client.estimate_gas(&tx, BlockId::default()).await?;
let gas = client.estimate_gas(&tx).await?;
info!("estimated verify gas cost: {:#?}", gas);
@@ -725,7 +724,7 @@ pub async fn verify_proof_with_data_attestation(
debug!("transaction {:#?}", tx);
info!(
"estimated verify gas cost: {:#?}",
client.estimate_gas(&tx, BlockId::default()).await?
client.estimate_gas(&tx).await?
);
let result = client.call(&tx).await;
@@ -923,13 +922,15 @@ pub async fn get_contract_artifacts(
return Err(format!("file not found: {:#?}", sol_code_path).into());
}
let mut settings = SolcSettings::default();
settings.optimizer = Optimizer {
enabled: Some(true),
runs: Some(runs),
details: None,
let settings = SolcSettings {
optimizer: Optimizer {
enabled: Some(true),
runs: Some(runs),
details: None,
},
output_selection: OutputSelection::default_output_selection(),
..Default::default()
};
settings.output_selection = OutputSelection::default_output_selection();
let input = SolcInput::build(
std::collections::BTreeMap::from([(

View File

@@ -204,6 +204,18 @@ pub async fn run(command: Commands) -> Result<String, Box<dyn Error>> {
)
.await
}
#[cfg(not(target_arch = "wasm32"))]
Commands::EncodeEvmCalldata {
proof_path,
calldata_path,
addr_vk,
} => encode_evm_calldata(
proof_path.unwrap_or(DEFAULT_PROOF.into()),
calldata_path.unwrap_or(DEFAULT_CALLDATA.into()),
addr_vk,
)
.map(|e| serde_json::to_string(&e).unwrap()),
Commands::CreateEvmVK {
vk_path,
srs_path,
@@ -1178,7 +1190,6 @@ pub(crate) async fn calibrate(
);
num_passed += 1;
} else {
error!("calibration failed {}", res.err().unwrap());
num_failed += 1;
}
@@ -1531,6 +1542,32 @@ pub(crate) async fn deploy_evm(
Ok(String::new())
}
/// Encodes the calldata for the EVM verifier (both aggregated and single proof)
pub(crate) fn encode_evm_calldata(
proof_path: PathBuf,
calldata_path: PathBuf,
addr_vk: Option<H160Flag>,
) -> Result<Vec<u8>, Box<dyn Error>> {
let snark = Snark::load::<IPACommitmentScheme<G1Affine>>(&proof_path)?;
let flattened_instances = snark.instances.into_iter().flatten();
let encoded = halo2_solidity_verifier::encode_calldata(
addr_vk
.as_ref()
.map(|x| alloy::primitives::Address::from(*x).0)
.map(|x| x.0),
&snark.proof,
&flattened_instances.collect::<Vec<_>>(),
);
log::debug!("Encoded calldata: {:?}", encoded);
File::create(calldata_path)?.write_all(encoded.as_slice())?;
Ok(encoded)
}
#[cfg(not(target_arch = "wasm32"))]
pub(crate) async fn verify_evm(
proof_path: PathBuf,

View File

@@ -15,7 +15,7 @@ use super::{VarVisibility, Visibility};
/// poseidon len to hash in tree
pub const POSEIDON_LEN_GRAPH: usize = 32;
/// Poseidon number of instancess
/// Poseidon number of instances
pub const POSEIDON_INSTANCES: usize = 1;
/// Poseidon module type

View File

@@ -550,7 +550,7 @@ impl Node {
.collect::<Result<Vec<_>, Box<dyn Error>>>()?;
let homogenous_inputs = opkind.requires_homogenous_input_scales();
// autoamtically increases a constant's scale if it is only used once and
// automatically increases a constant's scale if it is only used once and
for input in homogenous_inputs
.into_iter()
.filter(|i| !deleted_indices.contains(i))

View File

@@ -1,6 +1,7 @@
use log::{debug, error, info};
use std::fmt::Debug;
use std::net::IpAddr;
#[cfg(unix)]
use std::path::Path;
use std::str::FromStr;
use std::sync::Arc;

View File

@@ -72,7 +72,7 @@ impl ToFlags for Visibility {
impl<'a> From<&'a str> for Visibility {
fn from(s: &'a str) -> Self {
if s.contains("hashed/private") {
// split on last occurence of '/'
// split on last occurrence of '/'
let (_, outlets) = s.split_at(s.rfind('/').unwrap());
let outlets = outlets
.trim_start_matches('/')

View File

@@ -21,7 +21,7 @@ pub enum EvmVerificationError {
/// EVM verify errors
#[error("evm deployment failed")]
Deploy,
/// Invalid Visibilit
/// Invalid Visibility
#[error("Invalid visibility")]
InvalidVisibility,
}

View File

@@ -466,7 +466,7 @@ fn buffer_to_felts(buffer: Vec<u8>) -> PyResult<Vec<String>> {
/// Arguments
/// -------
/// message: list[str]
/// List of field elements represnted as strings
/// List of field elements represented as strings
///
/// Returns
/// -------
@@ -1430,6 +1430,47 @@ fn verify_aggr(
Ok(true)
}
/// Creates encoded evm calldata from a proof file
///
/// Arguments
/// ---------
/// proof: str
/// Path to the proof file
///
/// calldata: str
/// Path to the calldata file to save
///
/// addr_vk: str
/// The address of the verification key contract (if the verifier key is to be rendered as a separate contract)
///
/// Returns
/// -------
/// vec[u8]
/// The encoded calldata
///
#[pyfunction(signature = (
proof=PathBuf::from(DEFAULT_PROOF),
calldata=PathBuf::from(DEFAULT_CALLDATA),
addr_vk=None,
))]
fn encode_evm_calldata<'a>(
proof: PathBuf,
calldata: PathBuf,
addr_vk: Option<&'a str>,
) -> Result<Vec<u8>, PyErr> {
let addr_vk = if let Some(addr_vk) = addr_vk {
let addr_vk = H160Flag::from(addr_vk);
Some(addr_vk)
} else {
None
};
crate::execute::encode_evm_calldata(proof, calldata, addr_vk).map_err(|e| {
let err_str = format!("Failed to generate calldata: {}", e);
PyRuntimeError::new_err(err_str)
})
}
/// Creates an EVM compatible verifier, you will need solc installed in your environment to run this
///
/// Arguments
@@ -1888,6 +1929,6 @@ fn ezkl(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
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)?)?;
m.add_function(wrap_pyfunction!(encode_evm_calldata, m)?)?;
Ok(())
}

View File

@@ -1814,6 +1814,18 @@ mod native_tests {
let settings_arg = format!("{}/{}/settings.json", test_dir, example_name);
let private_key = format!("--private-key={}", *ANVIL_DEFAULT_PRIVATE_KEY);
// create encoded calldata
let status = Command::new(format!("{}/release/ezkl", *CARGO_TARGET_DIR))
.args([
"encode-evm-calldata",
"--proof-path",
&format!("{}/{}/aggr.pf", test_dir, example_name),
])
.status()
.expect("failed to execute process");
assert!(status.success());
let base_args = vec![
"create-evm-verifier-aggr",
"--vk-path",
@@ -2036,6 +2048,18 @@ mod native_tests {
let addr_path_arg = format!("--addr-path={}/{}/addr.txt", test_dir, example_name);
let settings_arg = format!("--settings-path={}", settings_path);
// create encoded calldata
let status = Command::new(format!("{}/release/ezkl", *CARGO_TARGET_DIR))
.args([
"encode-evm-calldata",
"--proof-path",
&format!("{}/{}/proof.pf", test_dir, example_name),
])
.status()
.expect("failed to execute process");
assert!(status.success());
// create the verifier
let mut args = vec!["create-evm-verifier", "--vk-path", &vk_arg, &settings_arg];
@@ -2205,6 +2229,19 @@ mod native_tests {
let deployed_addr_arg_vk = format!("--addr-vk={}", addr_vk);
// create encoded calldata
let status = Command::new(format!("{}/release/ezkl", *CARGO_TARGET_DIR))
.args([
"encode-evm-calldata",
"--proof-path",
&format!("{}/{}/proof.pf", test_dir, example_name),
&deployed_addr_arg_vk,
])
.status()
.expect("failed to execute process");
assert!(status.success());
// now verify the proof
let pf_arg = format!("{}/{}/proof.pf", test_dir, example_name);
let mut args = vec![
@@ -2376,6 +2413,18 @@ mod native_tests {
let settings_arg = format!("--settings-path={}", settings_path);
// create encoded calldata
let status = Command::new(format!("{}/release/ezkl", *CARGO_TARGET_DIR))
.args([
"encode-evm-calldata",
"--proof-path",
&format!("{}/{}/proof.pf", test_dir, example_name),
])
.status()
.expect("failed to execute process");
assert!(status.success());
// create the verifier
let mut args = vec!["create-evm-verifier", "--vk-path", &vk_arg, &settings_arg];

View File

@@ -402,6 +402,15 @@ async def test_create_evm_verifier():
settings_path = os.path.join(folder_path, 'settings.json')
sol_code_path = os.path.join(folder_path, 'test.sol')
abi_path = os.path.join(folder_path, 'test.abi')
proof_path = os.path.join(folder_path, 'test_evm.pf')
calldata_path = os.path.join(folder_path, 'calldata.bytes')
# res is now a vector of bytes
res = ezkl.encode_evm_calldata(proof_path, calldata_path)
assert os.path.isfile(calldata_path)
assert len(res) > 0
res = await ezkl.create_evm_verifier(
vk_path,