Skip to content

Commit

Permalink
feat: axvm::read (#744)
Browse files Browse the repository at this point in the history
* Wip?

* cargo check please

* Hmmm

* Optimize hint executable size (not really relevant to the ticket)

* turn on bincode::serde

* chore: re-export bincode from platform

* fix: hint_input_rv32 extend by 0

* feat: add the first version of the non-zkVM hint runtime

* Add some test

* chore: switch to rust stable 1.82.0 in workspace, nightly for recursion

* chore: switch to rust nightly-2024-10-30 for rustfmt

* chore: cargo clippy --fix

* chore: manual fix some comments

* cargo fmt

* chore: make intrinsics::io for zkvm only

---------

Co-authored-by: Alexander Golovanov <[email protected]>
  • Loading branch information
jonathanpwang and Golovanov399 authored Nov 2, 2024
1 parent 1c36cc1 commit 9b82ff0
Show file tree
Hide file tree
Showing 76 changed files with 542 additions and 1,628 deletions.
113 changes: 32 additions & 81 deletions Cargo.lock

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

17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[workspace.package]
version = "0.1.0"
edition = "2021"
rust-version = "1.82"
license = "MIT"
authors = ["Intrinsic Technologies"]
homepage = "https://axiom.xyz"
repository = "https://github.com/axiom-crypto/"

[workspace]
members = [
"stark-backend",
Expand All @@ -24,14 +33,6 @@ members = [
]
resolver = "2"

[workspace.package]
version = "0.1.0"
authors = ["Intrinsic Technologies"]
edition = "2021"
homepage = "https://axiom.xyz"
repository = "https://github.com/axiom-crypto/"
license = "MIT"

# Fastest runtime configuration
[profile.release]
opt-level = 3
Expand Down
8 changes: 6 additions & 2 deletions circuits/ecc/src/field_expression/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,12 @@ impl<F: Field> BaseAir<F> for FieldExpr {

impl<AB: InteractionBuilder> SubAir<AB> for FieldExpr {
/// The sub-row slice owned by the expression builder.
type AirContext<'a> = &'a [AB::Var]
where AB: 'a, AB::Var: 'a, AB::Expr: 'a;
type AirContext<'a>
= &'a [AB::Var]
where
AB: 'a,
AB::Var: 'a,
AB::Expr: 'a;

fn eval<'a>(&'a self, builder: &'a mut AB, local: &'a [AB::Var])
where
Expand Down
14 changes: 12 additions & 2 deletions circuits/primitives/src/assert_less_than/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ impl AssertLtSubAir {
}

impl<AB: InteractionBuilder> SubAir<AB> for AssertLtSubAir {
type AirContext<'a> = (AssertLessThanIo<AB::Expr>, &'a [AB::Var]) where AB::Expr: 'a, AB::Var: 'a, AB: 'a;
type AirContext<'a>
= (AssertLessThanIo<AB::Expr>, &'a [AB::Var])
where
AB::Expr: 'a,
AB::Var: 'a,
AB: 'a;

// constrain that x < y
// warning: send for range check must be included for the constraints to be sound
Expand All @@ -187,7 +192,12 @@ impl<AB: InteractionBuilder> SubAir<AB> for AssertLtSubAir {
pub struct AssertLtWhenTransitionAir(pub AssertLtSubAir);

impl<AB: InteractionBuilder> SubAir<AB> for AssertLtWhenTransitionAir {
type AirContext<'a> = (AssertLessThanIo<AB::Expr>, &'a [AB::Var]) where AB::Expr: 'a, AB::Var: 'a, AB: 'a;
type AirContext<'a>
= (AssertLessThanIo<AB::Expr>, &'a [AB::Var])
where
AB::Expr: 'a,
AB::Var: 'a,
AB: 'a;

/// Imposes the non-interaction constraints on all except the last row. This is
/// intended for use when the comparators `x, y` are on adjacent rows.
Expand Down
10 changes: 8 additions & 2 deletions circuits/primitives/src/bigint/check_carry_mod_to_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ impl CheckCarryModToZeroSubAir {
impl<AB: InteractionBuilder> SubAir<AB> for CheckCarryModToZeroSubAir {
/// `(expr, cols, is_valid)`
type AirContext<'a>
= (OverflowInt<AB::Expr>, CheckCarryModToZeroCols<AB::Var>, AB::Var) where
AB::Var:'a, AB::Expr:'a,
= (
OverflowInt<AB::Expr>,
CheckCarryModToZeroCols<AB::Var>,
AB::Var,
)
where
AB::Var: 'a,
AB::Expr: 'a,
AB: 'a;

fn eval<'a>(
Expand Down
10 changes: 8 additions & 2 deletions circuits/primitives/src/bigint/check_carry_to_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ impl CheckCarryToZeroSubAir {
impl<AB: InteractionBuilder> SubAir<AB> for CheckCarryToZeroSubAir {
/// `(expr, cols, is_valid)`
type AirContext<'a>
= (OverflowInt<AB::Expr>, CheckCarryToZeroCols<AB::Var>, AB::Var) where
AB::Var:'a, AB::Expr:'a,
= (
OverflowInt<AB::Expr>,
CheckCarryToZeroCols<AB::Var>,
AB::Var,
)
where
AB::Var: 'a,
AB::Expr: 'a,
AB: 'a;

fn eval<'a>(
Expand Down
7 changes: 6 additions & 1 deletion circuits/primitives/src/is_equal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ pub struct IsEqSubAir;

impl<AB: AirBuilder> SubAir<AB> for IsEqSubAir {
/// (io, inv)
type AirContext<'a> = (IsEqualIo<AB::Expr>, AB::Var) where AB::Expr: 'a, AB::Var: 'a, AB: 'a;
type AirContext<'a>
= (IsEqualIo<AB::Expr>, AB::Var)
where
AB::Expr: 'a,
AB::Var: 'a,
AB: 'a;

fn eval<'a>(&'a self, builder: &'a mut AB, (io, inv): (IsEqualIo<AB::Expr>, AB::Var))
where
Expand Down
7 changes: 6 additions & 1 deletion circuits/primitives/src/is_equal_array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ pub struct IsEqArraySubAir<const NUM: usize>;

impl<AB: AirBuilder, const NUM: usize> SubAir<AB> for IsEqArraySubAir<NUM> {
/// `(io, diff_inv_marker)`
type AirContext<'a> = (IsEqArrayIo<AB::Expr, NUM>, [AB::Var; NUM]) where AB::Expr: 'a, AB::Var: 'a, AB: 'a;
type AirContext<'a>
= (IsEqArrayIo<AB::Expr, NUM>, [AB::Var; NUM])
where
AB::Expr: 'a,
AB::Var: 'a,
AB: 'a;

/// Constrain that out == (x == y) when condition != 0
fn eval<'a>(
Expand Down
14 changes: 12 additions & 2 deletions circuits/primitives/src/is_less_than/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ impl IsLtSubAir {
}

impl<AB: InteractionBuilder> SubAir<AB> for IsLtSubAir {
type AirContext<'a> = (IsLessThanIo<AB::Expr>, &'a [AB::Var]) where AB::Expr: 'a, AB::Var: 'a, AB: 'a;
type AirContext<'a>
= (IsLessThanIo<AB::Expr>, &'a [AB::Var])
where
AB::Expr: 'a,
AB::Var: 'a,
AB: 'a;

// constrain that out == (x < y) when count != 0
// warning: send for range check must be included for the constraints to be sound
Expand All @@ -186,7 +191,12 @@ impl<AB: InteractionBuilder> SubAir<AB> for IsLtSubAir {
pub struct IsLtWhenTransitionAir(pub IsLtSubAir);

impl<AB: InteractionBuilder> SubAir<AB> for IsLtWhenTransitionAir {
type AirContext<'a> = (IsLessThanIo<AB::Expr>, &'a [AB::Var]) where AB::Expr: 'a, AB::Var: 'a, AB: 'a;
type AirContext<'a>
= (IsLessThanIo<AB::Expr>, &'a [AB::Var])
where
AB::Expr: 'a,
AB::Var: 'a,
AB: 'a;

/// Imposes the non-interaction constraints on all except the last row. This is
/// intended for use when the comparators `x, y` are on adjacent rows.
Expand Down
Loading

0 comments on commit 9b82ff0

Please sign in to comment.