Skip to content

Commit

Permalink
add update function for commitment type
Browse files Browse the repository at this point in the history
  • Loading branch information
martyall committed Feb 10, 2025
1 parent b83f4e2 commit 40851bd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions saffron/src/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use poly_commitment::{
use rayon::prelude::*;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use std::ops::Add;
use tracing::instrument;

#[serde_as]
Expand All @@ -36,6 +37,14 @@ impl<G: KimchiCurve> Commitment<G> {
folded,
}
}

pub fn update<EFqSponge>(&self, diff: Vec<PolyComm<G>>, sponge: &mut EFqSponge) -> Self
where
EFqSponge: FqSponge<G::BaseField, G, G::ScalarField>,
{
let new_chunks = self.chunks.iter().zip(diff).map(|(g, d)| g.add(&d));
Self::from_chunks(new_chunks.collect(), sponge)
}
}

#[instrument(skip_all, level = "debug")]
Expand Down

0 comments on commit 40851bd

Please sign in to comment.