Skip to content

Commit

Permalink
chore: use powdr to get vk (#238)
Browse files Browse the repository at this point in the history
* fix: bump to main

* fix: bump to main

* chore: update dependencies

* feat: export circom verifier

* fix: remove existing path

---------

Co-authored-by: Ubuntu <devadmin@zkevm-prover-uat-vm1.qf0bt0i4yvdutbhtrpicnmptkg.ix.internal.cloudapp.net>
  • Loading branch information
eigmax and Ubuntu authored Mar 30, 2024
1 parent bbf17ce commit 6396e51
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 160 deletions.
1 change: 1 addition & 0 deletions dsl_compile/src/input_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::errors::{bail, DslError, Result};
use ansi_term::Colour;
use std::path::{Path, PathBuf};

#[allow(dead_code)]
pub struct Input {
pub input_program: PathBuf,
pub out_r1cs: PathBuf,
Expand Down
6 changes: 3 additions & 3 deletions recursion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ starky = { path = "../starky", default-features = false }
plonky = { path = "../plonky", default-features = false }
algebraic = { path = "../algebraic", default-features = false }

powdr-pil-analyzer = { git = "https://github.com/eigmax/powdr.git", branch = "main" }
powdr-number = { git = "https://github.com/eigmax/powdr.git", branch = "main" }
powdr-ast = { git = "https://github.com/eigmax/powdr.git", branch = "main" }
powdr = { git = "https://github.com/powdr-labs/powdr.git", rev = "450e3f1" }
powdr-ast = { git = "https://github.com/powdr-labs/powdr.git", rev = "450e3f1" }
powdr-pil-analyzer = { git = "https://github.com/powdr-labs/powdr.git", rev = "450e3f1" }

[dev-dependencies]
env_logger = "0.10"
Expand Down
13 changes: 7 additions & 6 deletions recursion/src/pilcom.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
//! Poring from https://github.com/powdr-labs/powdr.git.
use std::rc::Rc;
mod export;
mod expression_counter;

use powdr_number::GoldilocksField;
pub use export::export;

use powdr::number::GoldilocksField;
use starky::types::PIL;
use std::path::Path;

pub fn compile_pil_from_str(pil_str: &str) -> PIL {
let analyze = powdr_pil_analyzer::analyze_string::<GoldilocksField>(pil_str);

export::export(&analyze)
export(Rc::new(analyze))
}
pub fn compile_pil_from_path(pil_path: &str) -> PIL {
let analyze = powdr_pil_analyzer::analyze::<GoldilocksField>(Path::new(pil_path));

export::export(&analyze)
let analyze = powdr_pil_analyzer::analyze_file::<GoldilocksField>(Path::new(pil_path));
export(Rc::new(analyze))
}

#[cfg(test)]
Expand Down
27 changes: 19 additions & 8 deletions recursion/src/pilcom/export.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! porting it from powdr
use powdr_number::FieldElement;
use powdr::number::FieldElement;
use std::cmp;
use std::collections::HashMap;
use std::path::PathBuf;
Expand Down Expand Up @@ -36,8 +36,8 @@ struct Exporter<'a, T> {
number_q: u64,
}

pub fn export<T: FieldElement>(analyzed: &Analyzed<T>) -> PIL {
let mut exporter = Exporter::new(analyzed);
pub fn export<T: FieldElement>(analyzed: std::rc::Rc<Analyzed<T>>) -> PIL {
let mut exporter = Exporter::new(&analyzed);
let mut publics = Vec::new();
let mut pol_identities = Vec::new();
let mut plookup_identities = Vec::new();
Expand All @@ -48,11 +48,13 @@ pub fn export<T: FieldElement>(analyzed: &Analyzed<T>) -> PIL {
StatementIdentifier::Definition(name) => {
if let Some((poly, value)) = analyzed.intermediate_columns.get(name) {
assert_eq!(poly.kind, SymbolKind::Poly(PolynomialType::Intermediate));
let expression_id = exporter.extract_expression(value, 1);
assert_eq!(
expression_id,
exporter.intermediate_poly_expression_ids[&poly.id] as usize
);
for ((_, id), value) in poly.array_elements().zip(value) {
let expression_id = exporter.extract_expression(value, 1);
assert_eq!(
expression_id,
exporter.intermediate_poly_expression_ids[&id.id] as usize
);
}
}
}
StatementIdentifier::PublicDeclaration(name) => {
Expand Down Expand Up @@ -284,6 +286,15 @@ impl<'a, T: FieldElement> Exporter<'a, T> {
..DEFAULT_EXPR
},
),
Expression::Challenge(challenge) => (
0,
StarkyExpr {
op: "challenge".to_string(),
deg: 0,
id: Some(challenge.id as usize),
..DEFAULT_EXPR
},
),
Expression::Number(value) => (
0,
StarkyExpr {
Expand Down
10 changes: 8 additions & 2 deletions recursion/src/pilcom/expression_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ pub fn compute_intermediate_expression_ids<T>(analyzed: &Analyzed<T>) -> HashMap
poly.expression_count()
} else if let Some((poly, _)) = analyzed.intermediate_columns.get(name) {
assert!(poly.kind == SymbolKind::Poly(PolynomialType::Intermediate));
ids.insert(poly.id, expression_counter as u64);
for (index, (_, id)) in poly.array_elements().enumerate() {
ids.insert(id.id, (expression_counter + index) as u64);
}
poly.expression_count()
} else {
unreachable!()
Expand Down Expand Up @@ -49,7 +51,11 @@ impl<Expr> ExpressionCounter for Identity<Expr> {

impl ExpressionCounter for Symbol {
fn expression_count(&self) -> usize {
(self.kind == SymbolKind::Poly(PolynomialType::Intermediate)).into()
if self.kind == SymbolKind::Poly(PolynomialType::Intermediate) {
self.length.unwrap_or(1) as usize
} else {
0
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions starkjs/fibonacci/fibonacci.pil
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ namespace Fibonacci(%N);
pol constant L1, LLAST;
pol commit l1,l2;

pol l2c = l2;
//pol l2c = l2;

public in1 = l2c(0);
public in1 = l2(0);
public in2 = l1(0);
public out = l1(%N-1);

Expand Down
14 changes: 3 additions & 11 deletions zkvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,9 @@ itertools = "0.12.0"
# serialization
log = "0.4.0"

#powdr-backend = { git = "https://github.com/powdr-labs/powdr", rev = "97ea8d0" }
#powdr-pipeline = { git = "https://github.com/powdr-labs/powdr", rev = "97ea8d0" }
#powdr-riscv = { git = "https://github.com/powdr-labs/powdr", rev = "97ea8d0" }
#powdr-riscv-executor = { git = "https://github.com/powdr-labs/powdr", rev = "97ea8d0" }
#powdr-number = { git = "https://github.com/powdr-labs/powdr", rev = "97ea8d0" }

powdr-backend = { git = "https://github.com/eigmax/powdr", branch = "main" }
powdr-pipeline = { git = "https://github.com/eigmax/powdr", branch = "main" }
powdr-riscv = { git = "https://github.com/eigmax/powdr", branch = "main" }
powdr-riscv-executor = { git = "https://github.com/eigmax/powdr", branch = "main" }
powdr-number = { git = "https://github.com/eigmax/powdr", branch = "main" }
powdr = { git = "https://github.com/powdr-labs/powdr", rev = "450e3f1" }
starky = { path = "../starky" }
recursion = { path = "../recursion" }

hex = "0.4.3"
thiserror = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion zkvm/vm/evm/Cargo.toml → zkvm/program/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
revm = { git = "https://github.com/powdr-labs/revm", branch = "serde-no-std", default-features = false, features = [ "serde" ] }
powdr-riscv-runtime = { git = "https://github.com/eigmax/powdr", branch = "main" }
powdr-riscv-runtime = { git = "https://github.com/powdr-labs/powdr", rev = "450e3f1" }
models = { git = "https://github.com/eigmax/powdr-revme", branch = "continuations", package = "models" }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive", "rc"] }
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion zkvm/vm/evm/src/lib.rs → zkvm/program/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use alloc::string::String;
use alloc::string::ToString;

use k256::ecdsa::SigningKey;
const TEST_CHANNEL: u32 = 1;

/// Recover the address from a private key (SigningKey).
pub fn recover_address(private_key: &[u8]) -> Option<Address> {
Expand All @@ -28,7 +29,7 @@ pub fn recover_address(private_key: &[u8]) -> Option<Address> {

#[no_mangle]
fn main() {
let suite_json: String = get_data_serde(666);
let suite_json: String = get_data_serde(TEST_CHANNEL);
print!("suite_json: {suite_json}\n");
let suite = read_suite(&suite_json);

Expand Down
3 changes: 1 addition & 2 deletions zkvm/vm/lr/Cargo.toml → zkvm/program/lr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
powdr-riscv-runtime = { git = "https://github.com/eigmax/powdr", branch = "main" }

powdr-riscv-runtime = { git = "https://github.com/powdr-labs/powdr", rev = "450e3f1" }

[workspace]
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6396e51

Please sign in to comment.