Skip to content
Snippets Groups Projects

Added Latex support for doc

Merged HEME Clement requested to merge c.heme/komodo:main into main
All threads resolved!
+ 20
12
@@ -31,14 +31,6 @@ pub struct Shard<F: PrimeField> {
}
impl<F: PrimeField> Shard<F> {
fn dual_combination(this: &Vec<F>, alpha: F, other: &Vec<F>, beta: F) -> Vec<F> {
this
.iter()
.zip(other.iter())
.map(|(s, o)| s.mul(alpha) + o.mul(beta))
.collect()
}
/// compute the linear combination between two [`Shard`]s
///
/// if we denote the [`Shard`] itself and the other [`Shard`] by $s$ and $o$ respectively, the
@@ -53,9 +45,19 @@ impl<F: PrimeField> Shard<F> {
Shard {
k: self.k,
linear_combination: Self::dual_combination(&self.linear_combination, alpha, &other.linear_combination, beta),
linear_combination: self
.linear_combination
.iter()
.zip(other.linear_combination.iter())
.map(|(l, r)| l.mul(alpha) + r.mul(beta))
.collect(),
hash: self.hash.clone(),
data: Self::dual_combination(&self.data, alpha, &other.data, beta),
data: self
.data
.iter()
.zip(other.data.iter())
.map(|(es, eo)| es.mul(alpha) + eo.mul(beta))
.collect(),
size: self.size,
}
}
@@ -102,7 +104,10 @@ pub fn recode_with_coeffs<F: PrimeField>(shards: &[Shard<F>], coeffs: &[F]) -> O
/// > **Note**
/// >
/// > this is a wrapper around [`recode_with_coeffs`].
pub fn recode_random<F: PrimeField>(shards: &[Shard<F>], rng: &mut impl RngCore) -> Result<Option<Shard<F>>, KomodoError> {
pub fn recode_random<F: PrimeField>(
shards: &[Shard<F>],
rng: &mut impl RngCore,
) -> Result<Option<Shard<F>>, KomodoError> {
for (i, (s1, s2)) in shards.iter().zip(shards.iter().skip(1)).enumerate() {
if s1.k != s2.k {
return Err(KomodoError::IncompatibleShards(format!(
@@ -139,7 +144,10 @@ pub fn recode_random<F: PrimeField>(shards: &[Shard<F>], rng: &mut impl RngCore)
/// matrix. (see [`algebra::split_data_into_field_elements`])
///
/// This is the inverse of [`decode`].
pub fn encode<F: PrimeField>(data: &[u8], encoding_mat: &Matrix<F>) -> Result<Vec<Shard<F>>, KomodoError> {
pub fn encode<F: PrimeField>(
data: &[u8],
encoding_mat: &Matrix<F>,
) -> Result<Vec<Shard<F>>, KomodoError> {
let hash = Sha256::hash(data).to_vec();
let k = encoding_mat.height;
Loading