Skip to content
Closed
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
176 changes: 96 additions & 80 deletions Cargo.lock

Large diffs are not rendered by default.

70 changes: 35 additions & 35 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[workspace]
members = [
"cli",
"core",
"derive",
"eval",
"helper",
"primitives",
"prover",
"recursion/circuit",
"recursion/compiler",
"recursion/core",
"recursion/gnark-ffi",
"recursion/program",
"sdk",
"tutorials",
"zkvm/*",
"cli",
"core",
"derive",
"eval",
"helper",
"primitives",
"prover",
"recursion/circuit",
"recursion/compiler",
"recursion/core",
"recursion/gnark-ffi",
"recursion/program",
"sdk",
"tutorials",
"zkvm/*",
]
exclude = ["examples/target"]
resolver = "2"
Expand All @@ -32,26 +32,26 @@ debug-assertions = true

[workspace.dependencies]
# Plonky3 dependencies
p3-air = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-field = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-commit = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-matrix = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-baby-bear = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-util = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-challenger = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-dft = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-fri = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-goldilocks = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-keccak = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-keccak-air = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-blake3 = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-mds = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-merkle-tree = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-poseidon2 = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-symmetric = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-uni-stark = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-maybe-rayon = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-bn254-fr = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "sp1-new" }
p3-air = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-field = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-commit = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-matrix = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-baby-bear = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-util = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-challenger = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-dft = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-fri = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-goldilocks = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-keccak = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-keccak-air = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-blake3 = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-mds = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-merkle-tree = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-poseidon2 = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-symmetric = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-uni-stark = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-maybe-rayon = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
p3-bn254-fr = { git = "https://github.com/lurk-lab/Plonky3.git", branch = "ah/sphinx-compat" }
alloy = { git = "https://github.com/alloy-rs/alloy", rev = "bfd0fda" }
anstyle = "1.0.7"
anyhow = "1.0.86"
Expand Down
3 changes: 1 addition & 2 deletions core/src/stark/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<SC: StarkGenericConfig, A> StarkMachine<SC, A> {
}
}

#[derive(Clone, Serialize, Deserialize)]
#[derive(Serialize, Deserialize)]
#[serde(bound(serialize = "PcsProverData<SC>: Serialize"))]
#[serde(bound(deserialize = "PcsProverData<SC>: DeserializeOwned"))]
pub struct StarkProvingKey<SC: StarkGenericConfig> {
Expand Down Expand Up @@ -516,7 +516,6 @@ impl<SC: StarkGenericConfig> std::error::Error for MachineVerificationError<SC>

#[cfg(test)]
pub mod tests {

use serial_test::serial;

use crate::io::SphinxStdin;
Expand Down
18 changes: 10 additions & 8 deletions core/src/utils/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use p3_field::{extension::BinomialExtensionField, Field};
use p3_fri::BatchOpening;
use p3_fri::CommitPhaseProofStep;
use p3_fri::QueryProof;
use p3_fri::{FriConfig, FriProof, TwoAdicFriPcs, TwoAdicFriPcsProof};
use p3_fri::{FriConfig, FriProof, TwoAdicFriPcs};
use p3_merkle_tree::FieldMerkleTreeMmcs;
use p3_poseidon2::Poseidon2;
use p3_poseidon2::Poseidon2ExternalMatrixGeneral;
Expand All @@ -18,6 +18,8 @@ use serde::Serialize;
use sphinx_primitives::poseidon2_init;

pub const DIGEST_SIZE: usize = 8;
// TODO: Check RATE
pub const RATE: usize = 8;

/// A configuration for inner recursion.
pub type InnerVal = BabyBear;
Expand All @@ -36,15 +38,15 @@ pub type InnerValMmcs = FieldMerkleTreeMmcs<
8,
>;
pub type InnerChallengeMmcs = ExtensionMmcs<InnerVal, InnerChallenge, InnerValMmcs>;
pub type InnerChallenger = DuplexChallenger<InnerVal, InnerPerm, 16>;
pub type InnerChallenger = DuplexChallenger<InnerVal, InnerPerm, 16, RATE>;
pub type InnerDft = Radix2DitParallel;
pub type InnerPcs = TwoAdicFriPcs<InnerVal, InnerDft, InnerValMmcs, InnerChallengeMmcs>;
pub type InnerQueryProof = QueryProof<InnerChallenge, InnerChallengeMmcs>;
pub type InnerCommitPhaseStep = CommitPhaseProofStep<InnerChallenge, InnerChallengeMmcs>;
pub type InnerFriProof = FriProof<InnerChallenge, InnerChallengeMmcs, InnerVal>;
pub type InnerBatchOpening = BatchOpening<InnerVal, InnerValMmcs>;
pub type InnerPcsProof =
TwoAdicFriPcsProof<InnerVal, InnerChallenge, InnerValMmcs, InnerChallengeMmcs>;
pub type InnerInputProof = Vec<InnerBatchOpening>;
pub type InnerQueryProof = QueryProof<InnerChallenge, InnerChallengeMmcs, InnerInputProof>;
pub type InnerCommitPhaseStep = CommitPhaseProofStep<InnerChallenge, InnerChallengeMmcs>;
pub type InnerCommitPhaseProofStep = CommitPhaseProofStep<InnerChallenge, InnerChallengeMmcs>;
pub type InnerPcsProof = FriProof<InnerChallenge, InnerChallengeMmcs, InnerVal, InnerInputProof>;

/// The permutation for inner recursion.
pub fn inner_perm() -> InnerPerm {
Expand Down Expand Up @@ -124,7 +126,7 @@ impl BabyBearPoseidon2Inner {
let val_mmcs = InnerValMmcs::new(hash, compress);
let dft = InnerDft {};
let fri_config = inner_fri_config();
let pcs = InnerPcs::new(27, dft, val_mmcs, fri_config);
let pcs = InnerPcs::new(dft, val_mmcs, fri_config);
Self { pcs, perm }
}
}
Expand Down
19 changes: 7 additions & 12 deletions core/src/utils/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ use crate::{
stark::{LocalProver, OpeningProof, ShardMainData, StarkGenericConfig},
};

const LOG_DEGREE_BOUND: usize = 31;

#[derive(Error, Debug)]
pub enum SphinxCoreProverError {
#[error("failed to execute program: {0}")]
Expand Down Expand Up @@ -423,7 +421,6 @@ use p3_matrix::dense::RowMajorMatrix;
use p3_uni_stark::Proof;

pub mod baby_bear_poseidon2 {

use p3_baby_bear::{BabyBear, DiffusionMatrixBabyBear};
use p3_challenger::DuplexChallenger;
use p3_commit::ExtensionMmcs;
Expand Down Expand Up @@ -453,7 +450,8 @@ pub mod baby_bear_poseidon2 {
>;
pub type ChallengeMmcs = ExtensionMmcs<Val, Challenge, ValMmcs>;
pub type Dft = Radix2DitParallel;
pub type Challenger = DuplexChallenger<Val, Perm, 16>;
// TODO: Check RATE
pub type Challenger = DuplexChallenger<Val, Perm, 16, 8>;
type Pcs = TwoAdicFriPcs<Val, Dft, ValMmcs, ChallengeMmcs>;

pub fn my_perm() -> Perm {
Expand Down Expand Up @@ -532,7 +530,7 @@ pub mod baby_bear_poseidon2 {
let val_mmcs = ValMmcs::new(hash, compress);
let dft = Dft {};
let fri_config = default_fri_config();
let pcs = Pcs::new(27, dft, val_mmcs, fri_config);
let pcs = Pcs::new(dft, val_mmcs, fri_config);
Self {
pcs,
perm,
Expand All @@ -547,7 +545,7 @@ pub mod baby_bear_poseidon2 {
let val_mmcs = ValMmcs::new(hash, compress);
let dft = Dft {};
let fri_config = compressed_fri_config();
let pcs = Pcs::new(27, dft, val_mmcs, fri_config);
let pcs = Pcs::new(dft, val_mmcs, fri_config);
Self {
pcs,
perm,
Expand Down Expand Up @@ -605,7 +603,6 @@ pub mod baby_bear_poseidon2 {
}

pub(super) mod baby_bear_keccak {

use p3_baby_bear::BabyBear;
use p3_challenger::{HashChallenger, SerializingChallenger32};
use p3_commit::ExtensionMmcs;
Expand All @@ -617,7 +614,6 @@ pub(super) mod baby_bear_keccak {
use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32};
use serde::{Deserialize, Serialize};

use super::LOG_DEGREE_BOUND;
use crate::stark::StarkGenericConfig;

pub(crate) type Val = BabyBear;
Expand All @@ -643,6 +639,7 @@ pub(super) mod baby_bear_keccak {
pub struct BabyBearKeccak {
pcs: Pcs,
}

// Implement serialization manually instead of using serde(into) to avoid cloing the config
impl Serialize for BabyBearKeccak {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand Down Expand Up @@ -678,7 +675,7 @@ pub(super) mod baby_bear_keccak {
proof_of_work_bits: 16,
mmcs: challenge_mmcs,
};
let pcs = Pcs::new(LOG_DEGREE_BOUND, dft, val_mmcs, fri_config);
let pcs = Pcs::new(dft, val_mmcs, fri_config);

Self { pcs }
}
Expand Down Expand Up @@ -717,7 +714,6 @@ pub(super) mod baby_bear_keccak {
}

pub(super) mod baby_bear_blake3 {

use p3_baby_bear::BabyBear;
use p3_blake3::Blake3;
use p3_challenger::{HashChallenger, SerializingChallenger32};
Expand All @@ -729,7 +725,6 @@ pub(super) mod baby_bear_blake3 {
use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32};
use serde::{Deserialize, Serialize};

use super::LOG_DEGREE_BOUND;
use crate::stark::StarkGenericConfig;

pub(crate) type Val = BabyBear;
Expand Down Expand Up @@ -801,7 +796,7 @@ pub(super) mod baby_bear_blake3 {
proof_of_work_bits: 16,
mmcs: challenge_mmcs,
};
let pcs = Pcs::new(LOG_DEGREE_BOUND, dft, val_mmcs, fri_config);
let pcs = Pcs::new(dft, val_mmcs, fri_config);

Self { pcs }
}
Expand Down
2 changes: 1 addition & 1 deletion prover/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{utils::babybear_bytes_to_bn254, words_to_bytes};
use crate::{utils::babybears_to_bn254, CoreSC, InnerSC};

/// The information necessary to generate a proof for a given RISC-V program.
#[derive(Clone, Serialize, Deserialize)]
#[derive(Serialize, Deserialize)]
pub struct SphinxProvingKey {
pub pk: StarkProvingKey<CoreSC>,
pub elf: Vec<u8>,
Expand Down
Loading