Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

o1vm: only legacy version should be using bn254 #2592

Merged
merged 1 commit into from
Sep 23, 2024
Merged
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
4 changes: 3 additions & 1 deletion o1vm/src/interpreters/keccak/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::{
Error, KeccakColumn,
},
lookups::{FixedLookupTables, LookupTable, LookupTableIDs::*},
Fp,
};

use ark_ff::{One, Zero};
Expand All @@ -19,6 +18,9 @@ use rand::Rng;
use sha3::{Digest, Keccak256};
use std::collections::HashMap;

// FIXME: we should check with other fields too
use ark_bn254::Fr as Fp;

#[test]
fn test_pad_blocks() {
let blocks_1 = crate::interpreters::keccak::pad_blocks::<Fp>(1);
Expand Down
4 changes: 3 additions & 1 deletion o1vm/src/interpreters/mips/tests_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ use crate::{
witness::{Env as WEnv, SyscallEnv, SCRATCH_SIZE},
},
preimage_oracle::PreImageOracleT,
Fp,
};
use rand::{CryptoRng, Rng, RngCore};
use std::{fs, path::PathBuf};

// FIXME: we should parametrize the tests with different fields.
use ark_bn254::Fr as Fp;

const PAGE_INDEX_EXECUTABLE_MEMORY: u32 = 1;

pub(crate) struct OnDiskPreImageOracle;
Expand Down
8 changes: 4 additions & 4 deletions o1vm/src/legacy/folding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ pub mod keccak {
},
Steps,
},
Curve, Fp,
legacy::{Curve, Fp},
};

use super::{Challenge, DecomposedFoldingEnvironment, FoldingInstance, FoldingWitness};
Expand Down Expand Up @@ -403,7 +403,7 @@ pub mod mips {
column::{ColumnAlias as MIPSColumn, N_MIPS_COLS, N_MIPS_REL_COLS, N_MIPS_SEL_COLS},
Instruction,
},
Curve, Fp,
legacy::{Curve, Fp},
};

use super::{Challenge, DecomposedFoldingEnvironment, FoldingInstance, FoldingWitness};
Expand Down Expand Up @@ -494,8 +494,8 @@ pub mod mips {

#[cfg(test)]
mod tests {
use crate::{
legacy::folding::{FoldingInstance, FoldingWitness, *},
use crate::legacy::{
folding::{FoldingInstance, FoldingWitness, *},
Curve, Fp,
};
use ark_poly::{Evaluations, Radix2EvaluationDomain};
Expand Down
2 changes: 1 addition & 1 deletion o1vm/src/legacy/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ use o1vm::{
keccak::DecomposedKeccakTrace, mips::DecomposedMIPSTrace, DecomposableTracer, Foldable,
Tracer,
},
BaseSponge, Fp, OpeningProof, ScalarSponge,
},
lookups::LookupTableIDs,
preimage_oracle::PreImageOracle,
BaseSponge, Fp, OpeningProof, ScalarSponge,
};
use std::{cmp::Ordering, collections::HashMap, fs::File, io::BufReader, process::ExitCode};
use strum::IntoEnumIterator;
Expand Down
16 changes: 16 additions & 0 deletions o1vm/src/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@
//! O1VM_FLAVOR=legacy bash run-code.sh
//! ```

use ark_ec::bn::Bn;
use mina_poseidon::{
constants::PlonkSpongeConstantsKimchi,
sponge::{DefaultFqSponge, DefaultFrSponge},
};
use poly_commitment::kzg::KZGProof;

/// Scalar field of BN254
pub type Fp = ark_bn254::Fr;
/// Elliptic curve group of BN254
pub type Curve = ark_bn254::G1Affine;
pub type BaseSponge = DefaultFqSponge<ark_bn254::g1::Parameters, SpongeParams>;
pub type ScalarSponge = DefaultFrSponge<Fp, SpongeParams>;
pub type SpongeParams = PlonkSpongeConstantsKimchi;
pub type OpeningProof = KZGProof<Bn<ark_bn254::Parameters>>;

pub mod folding;
pub mod proof;
pub mod trace;
19 changes: 0 additions & 19 deletions o1vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@ pub mod preimage_oracle;
/// The RAM lookup argument.
pub mod ramlookup;

use ark_ec::bn::Bn;
use kimchi::circuits::expr::{BerkeleyChallengeTerm, ConstantExpr, Expr};
use kimchi_msm::columns::Column;

use mina_poseidon::{
constants::PlonkSpongeConstantsKimchi,
sponge::{DefaultFqSponge, DefaultFrSponge},
};
use poly_commitment::kzg::KZGProof;
pub use ramlookup::{LookupMode as RAMLookupMode, RAMLookup};

/// Type to represent a constraint on the individual columns of the execution
Expand All @@ -47,15 +40,3 @@ pub use ramlookup::{LookupMode as RAMLookupMode, RAMLookup};
/// To represent this multi-variate polynomial using the expression framework,
/// we would use 3 different columns.
pub(crate) type E<F> = Expr<ConstantExpr<F, BerkeleyChallengeTerm>, Column>;

// Instantiate it with the desired group and field
// FIXME: move this into legacy::main.rs

/// Scalar field of BN254
pub type Fp = ark_bn254::Fr;
/// Elliptic curve group of BN254
pub type Curve = ark_bn254::G1Affine;
pub type BaseSponge = DefaultFqSponge<ark_bn254::g1::Parameters, SpongeParams>;
pub type ScalarSponge = DefaultFrSponge<Fp, SpongeParams>;
pub type SpongeParams = PlonkSpongeConstantsKimchi;
pub type OpeningProof = KZGProof<Bn<ark_bn254::Parameters>>;