Skip to content

Commit

Permalink
so poseidon m31 works for gkr correctness, which is a relief
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfloatersu committed Dec 18, 2024
1 parent a8ff4f2 commit 573b7d4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 5 additions & 1 deletion config/config_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ fn parse_fiat_shamir_hash_type(

let binding = hash_enum.ident.to_string();
let hash_type_str = binding.as_str();
let circuit_f = format!("<{field_config} as GKRFieldConfig>::CircuitField");
let challenge_f = format!("<{field_config} as GKRFieldConfig>::ChallengeField");
match (hash_type_str, field_type) {
("SHA256", _) => (
Expand All @@ -70,7 +71,10 @@ fn parse_fiat_shamir_hash_type(
"Keccak256".to_owned(),
format!("BytesHashTranscript::<{challenge_f}, Keccak256hasher>").to_owned(),
),
// TODO(HS) Poseidon M31 setup
("Poseidon", "M31") => (
"Poseidon".to_owned(),
format!("FieldHashTranscript::<{circuit_f}, {challenge_f}, PoseidonM31x16Ext3, PoseidonM31TranscriptSponge>").to_owned(),
),
("MIMC5", "BN254") => (
"MIMC5".to_owned(),
format!("FieldHashTranscript::<{challenge_f}, {challenge_f}, {challenge_f}, MiMCFrTranscriptSponge>")
Expand Down
9 changes: 8 additions & 1 deletion config/config_macros/tests/macro_expansion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use gkr_field_config::FieldType;
use config::GKRConfig;
use config_macros::declare_gkr_config;
use gkr_field_config::{BN254Config, GF2ExtConfig, GKRFieldConfig, M31ExtConfig};
use hasher::MiMCFrTranscriptSponge;
use hasher::{MiMCFrTranscriptSponge, PoseidonM31TranscriptSponge, PoseidonM31x16Ext3};
use poly_commit::raw::RawExpanderGKR;
use transcript::{BytesHashTranscript, FieldHashTranscript, Keccak256hasher, SHA256hasher};

Expand Down Expand Up @@ -36,8 +36,15 @@ fn main() {
FiatShamirHashType::Keccak256,
PolynomialCommitmentType::Raw
);
declare_gkr_config!(
M31PoseidonConfig,
FieldType::M31,
FiatShamirHashType::Poseidon,
PolynomialCommitmentType::Raw
);

print_type_name::<M31Sha256Config>();
print_type_name::<BN254MIMCConfig>();
print_type_name::<GF2Keccak256Config>();
print_type_name::<M31PoseidonConfig>();
}
12 changes: 11 additions & 1 deletion gkr/src/tests/gkr_correctness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use circuit::Circuit;
use config::{Config, FiatShamirHashType, GKRConfig, GKRScheme, PolynomialCommitmentType};
use config_macros::declare_gkr_config;
use gkr_field_config::{BN254Config, FieldType, GF2ExtConfig, GKRFieldConfig, M31ExtConfig};
use hasher::MiMCFrTranscriptSponge;
use hasher::{MiMCFrTranscriptSponge, PoseidonM31TranscriptSponge, PoseidonM31x16Ext3};
use mpi_config::{root_println, MPIConfig};
use poly_commit::expander_pcs_init_testing_only;
use poly_commit::raw::RawExpanderGKR;
Expand Down Expand Up @@ -63,6 +63,12 @@ fn test_gkr_correctness() {
FiatShamirHashType::MIMC5,
PolynomialCommitmentType::Raw
);
declare_gkr_config!(
C7,
FieldType::M31,
FiatShamirHashType::Poseidon,
PolynomialCommitmentType::Raw
);

test_gkr_correctness_helper(
&Config::<C0>::new(GKRScheme::Vanilla, mpi_config.clone()),
Expand Down Expand Up @@ -92,6 +98,10 @@ fn test_gkr_correctness() {
&Config::<C6>::new(GKRScheme::Vanilla, mpi_config.clone()),
Some("../data/gkr_proof.txt"),
);
test_gkr_correctness_helper(
&Config::<C7>::new(GKRScheme::Vanilla, mpi_config.clone()),
None,
);

MPIConfig::finalize();
}
Expand Down

0 comments on commit 573b7d4

Please sign in to comment.