mirror of
https://github.com/tlsnotary/tlsn.git
synced 2026-01-08 21:08:04 -05:00
replaced transpose with naive implementation for now
This commit is contained in:
@@ -250,7 +250,7 @@ mod tests {
|
||||
rng.fill_bytes(&mut choice);
|
||||
let choice = u8vec_to_boolvec(&choice);
|
||||
let inputs: Vec<[Block; 2]> = (0..16)
|
||||
.map(|i| [Block::from(2 * i), Block::from(2 * i + 1)])
|
||||
.map(|i| [Block::random(&mut rng), Block::random(&mut rng)])
|
||||
.collect();
|
||||
|
||||
let receiver_setup = receiver.extension_setup(&choice);
|
||||
|
||||
@@ -20,27 +20,48 @@ pub fn u8vec_to_boolvec(v: &[u8]) -> Vec<bool> {
|
||||
}
|
||||
|
||||
pub fn transpose(m: &Vec<Vec<u8>>) -> Vec<Vec<u8>> {
|
||||
let col_count = m[0].len() * 8;
|
||||
let row_count = m.len();
|
||||
let bits: Vec<Vec<bool>> = m.iter().map(|row| u8vec_to_boolvec(row)).collect();
|
||||
let col_count = bits[0].len();
|
||||
let row_count = bits.len();
|
||||
|
||||
let mut bits_: Vec<Vec<bool>> = vec![vec![false; row_count]; col_count];
|
||||
let mut m_: Vec<Vec<u8>> = Vec::with_capacity(col_count);
|
||||
|
||||
for j in 0..col_count {
|
||||
let byte_n = j >> 3;
|
||||
let bit_idx = j % 8;
|
||||
for j in 0..row_count {
|
||||
for i in 0..col_count {
|
||||
bits_[i][j] = bits[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
let mut row_bits: Vec<bool> = (0..row_count)
|
||||
.map(|i| ((m[i][byte_n] >> (7 - bit_idx)) & 1) == 1)
|
||||
.collect();
|
||||
row_bits.reverse();
|
||||
let mut row = boolvec_to_u8vec(&row_bits);
|
||||
row.reverse();
|
||||
m_.push(row);
|
||||
for row in bits_.iter() {
|
||||
m_.push(boolvec_to_u8vec(row));
|
||||
}
|
||||
|
||||
m_
|
||||
}
|
||||
|
||||
// pub fn transpose(m: &Vec<Vec<u8>>) -> Vec<Vec<u8>> {
|
||||
// let col_count = m[0].len() * 8;
|
||||
// let row_count = m.len();
|
||||
|
||||
// let mut m_: Vec<Vec<u8>> = Vec::with_capacity(col_count);
|
||||
|
||||
// for j in 0..col_count {
|
||||
// let byte_n = j >> 3;
|
||||
// let bit_idx = j % 8;
|
||||
|
||||
// let mut row_bits: Vec<bool> = (0..row_count)
|
||||
// .map(|i| ((m[i][byte_n] >> (7 - bit_idx)) & 1) == 1)
|
||||
// .collect();
|
||||
// row_bits.reverse();
|
||||
// let mut row = boolvec_to_u8vec(&row_bits);
|
||||
// row.reverse();
|
||||
// m_.push(row);
|
||||
// }
|
||||
|
||||
// m_
|
||||
// }
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user