Skip to content

Commit

Permalink
masked singer-pro from workspace member
Browse files Browse the repository at this point in the history
  • Loading branch information
hero78119 committed Aug 20, 2024
1 parent 8fdfd0b commit 3843194
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 51 deletions.
21 changes: 0 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ members = [
"multilinear_extensions",
"simple-frontend",
"singer",
"singer-pro",
"singer-utils",
"sumcheck",
"transcript",
Expand Down
49 changes: 29 additions & 20 deletions singer-utils/src/uint/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ mod tests {
use gkr::structs::{Circuit, CircuitWitness};
use goldilocks::{Goldilocks, GoldilocksExt2};
use itertools::Itertools;
use multilinear_extensions::mle::{DenseMultilinearExtension, IntoMLE};
use simple_frontend::structs::CircuitBuilder;

#[test]
Expand Down Expand Up @@ -389,10 +390,10 @@ mod tests {
.map(|v| Goldilocks::from(v))
.collect_vec();

let mut wires_in = vec![vec![]; circuit.n_witness_in];
wires_in[addend_0_id as usize] = addend_0_witness;
wires_in[addend_1_id as usize] = addend_1_witness;
wires_in[carry_id as usize] = carry_witness;
let mut wires_in = vec![DenseMultilinearExtension::default(); circuit.n_witness_in];
wires_in[addend_0_id as usize] = addend_0_witness.into_mle();
wires_in[addend_1_id as usize] = addend_1_witness.into_mle();
wires_in[carry_id as usize] = carry_witness.into_mle();

let circuit_witness = {
let challenges = vec![GoldilocksExt2::from(2)];
Expand All @@ -404,7 +405,9 @@ mod tests {
circuit_witness.check_correctness(&circuit);

// check the result correctness
let result_values = circuit_witness.output_layer_witness_ref().instances[0].to_vec();
let result_values = circuit_witness
.output_layer_witness_ref()
.get_base_field_vec();
assert_eq!(
result_values,
[14, 17, 31, 14]
Expand Down Expand Up @@ -463,9 +466,9 @@ mod tests {
.map(|v| Goldilocks::from(v))
.collect_vec();

let mut wires_in = vec![vec![]; circuit.n_witness_in];
wires_in[addend_0_id as usize] = addend_0_witness;
wires_in[carry_id as usize] = carry_witness;
let mut wires_in = vec![DenseMultilinearExtension::default(); circuit.n_witness_in];
wires_in[addend_0_id as usize] = addend_0_witness.into_mle();
wires_in[carry_id as usize] = carry_witness.into_mle();

let circuit_witness = {
let challenges = vec![GoldilocksExt2::from(2)];
Expand All @@ -477,7 +480,9 @@ mod tests {
circuit_witness.check_correctness(&circuit);

// check the result correctness
let result_values = circuit_witness.output_layer_witness_ref().instances[0].to_vec();
let result_values = circuit_witness
.output_layer_witness_ref()
.get_base_field_vec();
assert_eq!(
result_values,
[22, 2, 0, 15]
Expand Down Expand Up @@ -541,10 +546,10 @@ mod tests {
.map(|v| Goldilocks::from(v))
.collect_vec();

let mut wires_in = vec![vec![]; circuit.n_witness_in];
wires_in[addend_0_id as usize] = addend_0_witness;
wires_in[small_value_id as usize] = small_value_witness;
wires_in[carry_id as usize] = carry_witness;
let mut wires_in = vec![DenseMultilinearExtension::default(); circuit.n_witness_in];
wires_in[addend_0_id as usize] = addend_0_witness.into_mle();
wires_in[small_value_id as usize] = small_value_witness.into_mle();
wires_in[carry_id as usize] = carry_witness.into_mle();

let circuit_witness = {
let challenges = vec![GoldilocksExt2::from(2)];
Expand All @@ -556,7 +561,9 @@ mod tests {
circuit_witness.check_correctness(&circuit);

// check the result correctness
let result_values = circuit_witness.output_layer_witness_ref().instances[0].to_vec();
let result_values = circuit_witness
.output_layer_witness_ref()
.get_base_field_vec();
assert_eq!(
result_values,
[22, 2, 0, 15]
Expand Down Expand Up @@ -609,17 +616,17 @@ mod tests {
.into_iter()
.rev()
.map(|v| Goldilocks::from(v))
.collect();
.collect_vec();
let borrow_witness = vec![0, 1, 1, 0]
.into_iter()
.rev()
.map(|v| Goldilocks::from(v))
.collect_vec();

let mut wires_in = vec![vec![]; circuit.n_witness_in];
wires_in[minuend_id as usize] = minuend_witness;
wires_in[subtrahend_id as usize] = subtrahend_witness;
wires_in[borrow_id as usize] = borrow_witness;
let mut wires_in = vec![DenseMultilinearExtension::default(); circuit.n_witness_in];
wires_in[minuend_id as usize] = minuend_witness.into_mle();
wires_in[subtrahend_id as usize] = subtrahend_witness.into_mle();
wires_in[borrow_id as usize] = borrow_witness.into_mle();

let circuit_witness = {
let challenges = vec![GoldilocksExt2::from(2)];
Expand All @@ -631,7 +638,9 @@ mod tests {
circuit_witness.check_correctness(&circuit);

// check the result correctness
let result_values = circuit_witness.output_layer_witness_ref().instances[0].to_vec();
let result_values = circuit_witness
.output_layer_witness_ref()
.get_base_field_vec();
assert_eq!(
result_values,
[20, 30, 21, 3]
Expand Down
7 changes: 5 additions & 2 deletions singer-utils/src/uint/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ mod tests {
use gkr::structs::{Circuit, CircuitWitness};
use goldilocks::{Goldilocks, GoldilocksExt2};
use itertools::Itertools;
use multilinear_extensions::mle::IntoMLE;
use simple_frontend::structs::CircuitBuilder;

#[test]
Expand Down Expand Up @@ -179,12 +180,14 @@ mod tests {
let circuit_witness = {
let challenges = vec![GoldilocksExt2::from(2)];
let mut circuit_witness = CircuitWitness::new(&circuit, challenges);
circuit_witness.add_instance(&circuit, vec![witness_values]);
circuit_witness.add_instance(&circuit, vec![witness_values.into_mle()]);
circuit_witness
};
circuit_witness.check_correctness(&circuit);

let output = circuit_witness.output_layer_witness_ref().instances[0].to_vec();
let output = circuit_witness
.output_layer_witness_ref()
.get_base_field_vec();
assert_eq!(
&output[..5],
vec![35, 39, 5, 0, 0]
Expand Down
13 changes: 6 additions & 7 deletions singer-utils/src/uint/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ pub fn pad_cells<E: ExtensionField>(
/// Compile time evaluated minimum function
/// returns min(a, b)
pub const fn const_min(a: usize, b: usize) -> usize {
if a <= b {
a
} else {
b
}
if a <= b { a } else { b }
}

/// Assumes each limb < max_value
Expand Down Expand Up @@ -110,6 +106,7 @@ mod tests {
use gkr::structs::{Circuit, CircuitWitness};
use goldilocks::{Goldilocks, GoldilocksExt2};
use itertools::Itertools;
use multilinear_extensions::mle::IntoMLE;
use simple_frontend::structs::CircuitBuilder;

#[test]
Expand Down Expand Up @@ -184,13 +181,15 @@ mod tests {
.collect::<Vec<_>>();
let circuit_witness = {
let mut circuit_witness = CircuitWitness::new(&circuit, vec![]);
circuit_witness.add_instance(&circuit, vec![witness_values]);
circuit_witness.add_instance(&circuit, vec![witness_values.into_mle()]);
circuit_witness
};

circuit_witness.check_correctness(&circuit);

let output = circuit_witness.output_layer_witness_ref().instances[0].to_vec();
let output = circuit_witness
.output_layer_witness_ref()
.get_base_field_vec();

assert_eq!(
&output[..3],
Expand Down

0 comments on commit 3843194

Please sign in to comment.