Skip to content

Commit

Permalink
more base field backed objects
Browse files Browse the repository at this point in the history
  • Loading branch information
kunxian-xia committed Dec 11, 2024
1 parent daa75d4 commit dad8e14
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions spartan_parallel/src/sparse_mlpoly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ use super::random::RandomTape;
use super::timer::Timer;
use super::transcript::{AppendToTranscript, ProofTranscript};
use core::cmp::Ordering;
use ff::Field;
use merlin::Transcript;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SparseMatEntry<S: SpartanExtensionField> {
row: usize,
col: usize,
val: S,
val: S::BaseField,
}

impl<S: SpartanExtensionField> SparseMatEntry<S> {
pub fn new(row: usize, col: usize, val: S) -> Self {
pub fn new(row: usize, col: usize, val: S::BaseField) -> Self {
SparseMatEntry { row, col, val }
}
}
Expand Down Expand Up @@ -264,6 +265,7 @@ pub struct SparseMatPolyCommitment<S: SpartanExtensionField> {
batch_size: usize,
num_ops: usize,
num_mem_cells: usize,
// TODO: add mpcs commitment
_phantom: S,
}

Expand All @@ -288,11 +290,11 @@ impl<S: SpartanExtensionField> SparseMatPolynomial<S> {
self.M.len().next_power_of_two()
}

fn sparse_to_dense_vecs(&self, N: usize) -> (Vec<usize>, Vec<usize>, Vec<S>) {
fn sparse_to_dense_vecs(&self, N: usize) -> (Vec<usize>, Vec<usize>, Vec<S::BaseField>) {
assert!(N >= self.get_num_nz_entries());
let mut ops_row: Vec<usize> = vec![0; N];
let mut ops_col: Vec<usize> = vec![0; N];
let mut val: Vec<S> = vec![S::field_zero(); N];
let mut val: Vec<S::BaseField> = vec![S::BaseField::ZERO; N];

for i in 0..self.M.len() {
ops_row[i] = self.M[i].row;
Expand Down

0 comments on commit dad8e14

Please sign in to comment.