Skip to content

Commit

Permalink
perf: use faster polynomial coset evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Apr 16, 2024
1 parent 8799c67 commit 29849ab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ default-features = false
features = ["precommit-hook", "run-cargo-clippy", "run-cargo-fmt"]

[patch.crates-io]
twenty-first = { git = "https://github.com/Neptune-Crypto/twenty-first.git", rev = "1e065d68" }
twenty-first = { git = "https://github.com/Neptune-Crypto/twenty-first.git", rev = "b57ed599" }
14 changes: 11 additions & 3 deletions triton-vm/src/arithmetic_domain.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ops::Mul;
use std::ops::MulAssign;

use num_traits::One;
Expand Down Expand Up @@ -74,14 +75,21 @@ impl ArithmeticDomain {

pub fn interpolate<FF>(&self, values: &[FF]) -> Polynomial<FF>
where
FF: FiniteField + MulAssign<BFieldElement> + From<BFieldElement>,
FF: FiniteField
+ MulAssign<BFieldElement>
+ Mul<BFieldElement, Output = FF>
+ From<BFieldElement>,
{
Polynomial::fast_coset_interpolate(self.offset.into(), self.generator, values)
// generic type made explicit to avoid performance regressions due to auto-conversion
Polynomial::fast_coset_interpolate::<BFieldElement>(self.offset, self.generator, values)
}

pub fn low_degree_extension<FF>(&self, codeword: &[FF], target_domain: Self) -> Vec<FF>
where
FF: FiniteField + MulAssign<BFieldElement> + From<BFieldElement>,
FF: FiniteField
+ MulAssign<BFieldElement>
+ Mul<BFieldElement, Output = FF>
+ From<BFieldElement>,
{
target_domain.evaluate(&self.interpolate(codeword))
}
Expand Down
6 changes: 5 additions & 1 deletion triton-vm/src/table/master_table.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ops::Mul;
use std::ops::MulAssign;
use std::ops::Range;

Expand Down Expand Up @@ -207,7 +208,10 @@ pub enum TableId {
/// [master_quot_table]: all_quotients
pub trait MasterTable<FF>: Sync
where
FF: FiniteField + MulAssign<BFieldElement> + From<BFieldElement>,
FF: FiniteField
+ MulAssign<BFieldElement>
+ Mul<BFieldElement, Output = FF>
+ From<BFieldElement>,
Standard: Distribution<FF>,
{
fn trace_domain(&self) -> ArithmeticDomain;
Expand Down

0 comments on commit 29849ab

Please sign in to comment.