Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ members = [
"extensions/ecc/tests",
"extensions/pairing/circuit",
"extensions/pairing/guest",
"extensions/memcpy/circuit",
"extensions/memcpy/transpiler",
"extensions/memcpy/tests",
"guest-libs/ff_derive/",
"guest-libs/k256/",
"guest-libs/p256/",
Expand Down Expand Up @@ -171,6 +174,8 @@ openvm-ecc-sw-macros = { path = "extensions/ecc/sw-macros", default-features = f
openvm-pairing-circuit = { path = "extensions/pairing/circuit", default-features = false }
openvm-pairing-transpiler = { path = "extensions/pairing/transpiler", default-features = false }
openvm-pairing-guest = { path = "extensions/pairing/guest", default-features = false }
openvm-memcpy-circuit = { path = "extensions/memcpy/circuit", default-features = false }
openvm-memcpy-transpiler = { path = "extensions/memcpy/transpiler", default-features = false }
openvm-verify-stark = { path = "guest-libs/verify_stark", default-features = false }

# Benchmarking
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/execute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ openvm-pairing-guest.workspace = true
openvm-pairing-transpiler.workspace = true
openvm-keccak256-circuit.workspace = true
openvm-keccak256-transpiler.workspace = true
openvm-memcpy-circuit.workspace = true
openvm-memcpy-transpiler.workspace = true
openvm-rv32im-circuit.workspace = true
openvm-rv32im-transpiler.workspace = true
openvm-sha256-circuit.workspace = true
Expand Down
11 changes: 11 additions & 0 deletions benchmarks/execute/benches/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ use openvm_ecc_circuit::{EccCpuProverExt, WeierstrassExtension, WeierstrassExten
use openvm_ecc_transpiler::EccTranspilerExtension;
use openvm_keccak256_circuit::{Keccak256, Keccak256CpuProverExt, Keccak256Executor};
use openvm_keccak256_transpiler::Keccak256TranspilerExtension;
use openvm_memcpy_circuit::{Memcpy, MemcpyCpuProverExt, MemcpyExecutor};
use openvm_memcpy_transpiler::MemcpyTranspilerExtension;
use openvm_native_circuit::{NativeCpuBuilder, NATIVE_MAX_TRACE_HEIGHTS};
use openvm_native_recursion::hints::Hintable;
use openvm_pairing_circuit::{
Expand Down Expand Up @@ -107,6 +109,8 @@ pub struct ExecuteConfig {
#[extension]
pub keccak: Keccak256,
#[extension]
pub memcpy: Memcpy,
#[extension]
pub sha256: Sha256,
#[extension]
pub modular: ModularExtension,
Expand All @@ -128,6 +132,7 @@ impl Default for ExecuteConfig {
io: Rv32Io,
bigint: Int256::default(),
keccak: Keccak256,
memcpy: Memcpy,
sha256: Sha256,
modular: ModularExtension::new(vec![
bn_config.modulus.clone(),
Expand Down Expand Up @@ -188,6 +193,11 @@ where
&config.keccak,
inventory,
)?;
VmProverExtension::<E, _, _>::extend_prover(
&MemcpyCpuProverExt,
&config.memcpy,
inventory,
)?;
VmProverExtension::<E, _, _>::extend_prover(&Sha2CpuProverExt, &config.sha256, inventory)?;
VmProverExtension::<E, _, _>::extend_prover(
&AlgebraCpuProverExt,
Expand Down Expand Up @@ -216,6 +226,7 @@ fn create_default_transpiler() -> Transpiler<BabyBear> {
.with_extension(Rv32MTranspilerExtension)
.with_extension(Int256TranspilerExtension)
.with_extension(Keccak256TranspilerExtension)
.with_extension(MemcpyTranspilerExtension)
.with_extension(Sha256TranspilerExtension)
.with_extension(ModularTranspilerExtension)
.with_extension(Fp2TranspilerExtension)
Expand Down
1 change: 1 addition & 0 deletions benchmarks/guest/fibonacci/openvm.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[app_vm_config.rv32i]
[app_vm_config.rv32m]
[app_vm_config.io]
[app_vm_config.memcpy]
52 changes: 41 additions & 11 deletions benchmarks/guest/fibonacci/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
use openvm::io::{read, reveal_u32};
use core::ptr;

pub fn main() {
let n: u64 = read();
let mut a: u64 = 0;
let mut b: u64 = 1;
for _ in 0..n {
let c: u64 = a.wrapping_add(b);
a = b;
b = c;
openvm::entry!(main);

/// Moves all the elements of `src` into `dst`, leaving `src` empty.
#[no_mangle]
pub fn append<T>(dst: &mut [T], src: &mut [T], shift: usize) {
let src_len = src.len();
let dst_len = dst.len();

unsafe {
// The call to add is always safe because `Vec` will never
// allocate more than `isize::MAX` bytes.
let dst_ptr = dst.as_mut_ptr().wrapping_add(shift);
let src_ptr = src.as_ptr();
println!("dst_ptr: {:?}", dst_ptr);
println!("src_ptr: {:?}", src_ptr);
println!("src_len: {:?}", src_len);

// The two regions cannot overlap because mutable references do
// not alias, and two different vectors cannot own the same
// memory.
ptr::copy_nonoverlapping(src_ptr, dst_ptr, src_len);
}
reveal_u32(a as u32, 0);
reveal_u32((a >> 32) as u32, 1);
}

pub fn main() {
let mut a: [u8; 1000] = [1; 1000];
let mut b: [u8; 500] = [2; 500];

let shift: usize = 0;
append(&mut a, &mut b, shift);

for i in 0..1000 {
if i < shift || i >= shift + b.len() {
assert_eq!(a[i], 1);
} else {
assert_eq!(a[i], 2);
}
}

println!("a: {:?}", a);
println!("b: {:?}", b);
}
10 changes: 9 additions & 1 deletion crates/circuits/primitives/src/assert_less_than/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use openvm_circuit_primitives_derive::AlignedBorrow;
use openvm_stark_backend::{
interaction::InteractionBuilder,
p3_air::AirBuilder,
p3_field::{Field, FieldAlgebra},
p3_field::{Field, FieldAlgebra, PrimeField32},
};

use crate::{
Expand Down Expand Up @@ -58,6 +58,14 @@ pub struct LessThanAuxCols<T, const AUX_LEN: usize> {
pub lower_decomp: [T; AUX_LEN],
}

impl<F: PrimeField32, const AUX_LEN: usize> Default for LessThanAuxCols<F, AUX_LEN> {
fn default() -> Self {
Self {
lower_decomp: [F::ZERO; AUX_LEN],
}
}
}

/// This is intended for use as a **SubAir**, not as a standalone Air.
///
/// This SubAir constrains that `x < y` when `count != 0`, assuming
Expand Down
2 changes: 2 additions & 0 deletions crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ openvm-ecc-circuit = { workspace = true }
openvm-ecc-transpiler = { workspace = true }
openvm-keccak256-circuit = { workspace = true }
openvm-keccak256-transpiler = { workspace = true }
openvm-memcpy-circuit = { workspace = true }
openvm-memcpy-transpiler = { workspace = true }
openvm-sha256-circuit = { workspace = true }
openvm-sha256-transpiler = { workspace = true }
openvm-pairing-circuit = { workspace = true }
Expand Down
Loading
Loading