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

[bug fix] BaseFold: fix simple batch verify error when input one poly #247

Merged
merged 1 commit into from
Sep 19, 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
10 changes: 10 additions & 0 deletions mpcs/src/basefold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,9 @@ mod test {
#[test]
fn simple_batch_commit_open_verify_goldilocks_basecode_base() {
// Both challenge and poly are over base field
run_simple_batch_commit_open_verify::<GoldilocksExt2, PcsGoldilocksBaseCode>(
true, 10, 11, 1,
);
run_simple_batch_commit_open_verify::<GoldilocksExt2, PcsGoldilocksBaseCode>(
true, 10, 11, 4,
);
Expand All @@ -1036,12 +1039,16 @@ mod test {
#[test]
fn simple_batch_commit_open_verify_goldilocks_rscode_base() {
// Both challenge and poly are over base field
run_simple_batch_commit_open_verify::<GoldilocksExt2, PcsGoldilocksRSCode>(true, 10, 11, 1);
run_simple_batch_commit_open_verify::<GoldilocksExt2, PcsGoldilocksRSCode>(true, 10, 11, 4);
}

#[test]
fn simple_batch_commit_open_verify_goldilocks_basecode_2() {
// Both challenge and poly are over extension field
run_simple_batch_commit_open_verify::<GoldilocksExt2, PcsGoldilocksBaseCode>(
false, 10, 11, 1,
);
run_simple_batch_commit_open_verify::<GoldilocksExt2, PcsGoldilocksBaseCode>(
false, 10, 11, 4,
);
Expand All @@ -1050,6 +1057,9 @@ mod test {
#[test]
fn simple_batch_commit_open_verify_goldilocks_rscode_2() {
// Both challenge and poly are over extension field
run_simple_batch_commit_open_verify::<GoldilocksExt2, PcsGoldilocksRSCode>(
false, 10, 11, 1,
);
run_simple_batch_commit_open_verify::<GoldilocksExt2, PcsGoldilocksRSCode>(
false, 10, 11, 4,
);
Expand Down
24 changes: 18 additions & 6 deletions mpcs/src/util/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,26 @@ fn authenticate_merkle_path_root_batch<E: ExtensionField>(
hasher: &Hasher<E::BaseField>,
) {
let mut x_index = x_index;
let mut hash = match (left, right) {
(FieldType::Base(left), FieldType::Base(right)) => {
hash_two_leaves_batch_base::<E>(&left, &right, hasher)
let mut hash = if left.len() > 1 {
match (left, right) {
(FieldType::Base(left), FieldType::Base(right)) => {
hash_two_leaves_batch_base::<E>(&left, &right, hasher)
}
(FieldType::Ext(left), FieldType::Ext(right)) => {
hash_two_leaves_batch_ext::<E>(&left, &right, hasher)
}
_ => unreachable!(),
}
(FieldType::Ext(left), FieldType::Ext(right)) => {
hash_two_leaves_batch_ext::<E>(&left, &right, hasher)
} else {
match (left, right) {
(FieldType::Base(left), FieldType::Base(right)) => {
hash_two_leaves_base::<E>(&left[0], &right[0], hasher)
}
(FieldType::Ext(left), FieldType::Ext(right)) => {
hash_two_leaves_ext::<E>(&left[0], &right[0], hasher)
}
_ => unreachable!(),
}
_ => unreachable!(),
};

// The lowest bit in the index is ignored. It can point to either leaves
Expand Down
Loading