Skip to content

Commit a53d834

Browse files
authored
debug utilities (#9)
1 parent 3a9e040 commit a53d834

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

Cargo.lock

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/multilinear_extensions/src/mle.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,25 @@ impl<'a, E: ExtensionField> MultilinearExtension<'a, E> {
958958
pub fn index(&self, index: usize) -> Either<E::BaseField, E> {
959959
self.evaluations.index(index)
960960
}
961+
962+
/// encode evaluations vector into a position-sensitive extension field scalar
963+
pub fn bh_signature(&self) -> E {
964+
match &self.evaluations() {
965+
FieldType::Base(slice) => E::from(
966+
slice
967+
.iter()
968+
.enumerate()
969+
.map(|(i, v)| E::BaseField::from_canonical_u32(i as u32 + 1) + *v)
970+
.product::<E::BaseField>(),
971+
),
972+
FieldType::Ext(slice) => slice
973+
.iter()
974+
.enumerate()
975+
.map(|(i, v)| E::from_canonical_u32(i as u32 + 1) + *v)
976+
.product::<E>(),
977+
_ => unreachable!(),
978+
}
979+
}
961980
}
962981

963982
#[allow(clippy::wrong_self_convention)]

0 commit comments

Comments
 (0)