Skip to content

Commit

Permalink
Minor: Orion related additional test (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfloatersu authored Jan 21, 2025
1 parent 4f05d70 commit 25d4461
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
matrix:
include:
- os: macos-latest
- os: ubuntu-latest
# - os: ubuntu-latest

steps:
- name: Checkout code
Expand Down
36 changes: 36 additions & 0 deletions poly_commit/src/orion/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,39 @@ where
alphabet == codeword[index]
})
}

#[cfg(test)]
mod tests {
use arith::{Field, SimdField};
use ark_std::test_rng;
use gf2::{GF2x8, GF2};
use gf2_128::{GF2_128x8, GF2_128};
use itertools::izip;

use super::SubsetSumLUTs;

#[test]
fn test_lut_simd_inner_prod_consistency() {
let mut rng = test_rng();

let weights: Vec<_> = (0..8).map(|_| GF2_128::random_unsafe(&mut rng)).collect();
let bases: Vec<_> = (0..8).map(|_| GF2::random_unsafe(&mut rng)).collect();

let simd_weights = GF2_128x8::pack(&weights);
let simd_bases = GF2x8::pack(&bases);

let expected_simd_inner_prod: GF2_128 = (simd_weights * simd_bases).unpack().iter().sum();

let expected_vanilla_inner_prod: GF2_128 =
izip!(&weights, &bases).map(|(w, b)| *w * *b).sum();

assert_eq!(expected_simd_inner_prod, expected_vanilla_inner_prod);

let mut table = SubsetSumLUTs::new(8, 1);
table.build(&weights);

let actual_lut_inner_prod = table.lookup_and_sum(&vec![simd_bases]);

assert_eq!(expected_simd_inner_prod, actual_lut_inner_prod)
}
}

0 comments on commit 25d4461

Please sign in to comment.