Skip to content

Commit

Permalink
more tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
sinuio committed Apr 12, 2022
1 parent e65af7a commit 69b65c4
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions mpc-core/examples/garble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
let gc = complete_gc.to_public(&generator_inputs);

// Here we'll manually put together the evaluators input labels, this is usually retrieved using oblivious transfer
let evaluator_input_labels = key
let evaluator_input_labels: Vec<InputLabel> = key
.into_iter()
.zip(complete_gc.input_labels[128..256].iter())
.enumerate()
Expand All @@ -61,7 +61,7 @@ fn main() {
.collect();

let outputs = ev
.eval(&mut cipher, &circ, &gc, evaluator_input_labels)
.eval(&mut cipher, &circ, &gc, &evaluator_input_labels)
.unwrap();

let mut ciphertext = boolvec_to_u8vec(&outputs);
Expand Down
2 changes: 1 addition & 1 deletion mpc-core/src/circuit/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ impl Circuit {
pub fn load(filename: &str) -> Result<Self, CircuitLoadError> {
let file = read(filename)?;
let circ = ProtoCircuit::decode(file.as_slice())?;
Circuit::try_from(circ).map_err(|e| CircuitLoadError::MappingError)
Circuit::try_from(circ).map_err(|_| CircuitLoadError::MappingError)
}
}
2 changes: 1 addition & 1 deletion mpc-core/src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Circuit {
wires[input.id] = Some(input.value);
}

for (i, gate) in self.gates.iter().enumerate() {
for gate in self.gates.iter() {
let (zref, val) = match *gate {
Gate::Xor {
xref, yref, zref, ..
Expand Down
2 changes: 1 addition & 1 deletion mpc-core/src/garble/generator/half_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,6 @@ mod tests {
let circ = Circuit::load("circuits/protobuf/aes_128_reverse.bin").unwrap();
let half_gate = HalfGateGenerator::new();

let gc = half_gate.garble(&mut cipher, &mut rng, &circ);
let _ = half_gate.garble(&mut cipher, &mut rng, &circ);
}
}
4 changes: 2 additions & 2 deletions mpc-core/src/ot/base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub mod tests {
pub fn values() -> Vec<[Block; 2]> {
let mut rng = thread_rng();
(0..128)
.map(|i| [Block::random(&mut rng), Block::random(&mut rng)])
.map(|_| [Block::random(&mut rng), Block::random(&mut rng)])
.collect()
}

Expand Down Expand Up @@ -91,7 +91,7 @@ pub mod tests {
fn test_ot() {
let mut rng = thread_rng();
let s_inputs: Vec<[Block; 2]> = (0..128)
.map(|i| [Block::random(&mut rng), Block::random(&mut rng)])
.map(|_| [Block::random(&mut rng), Block::random(&mut rng)])
.collect();
let mut choice = vec![0u8; 16];
rng.fill_bytes(&mut choice);
Expand Down
2 changes: 1 addition & 1 deletion mpc-core/src/ot/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod tests {
rng.fill_bytes(&mut choice);
let choice = u8vec_to_boolvec(&choice);
let inputs: Vec<[Block; 2]> = (0..16)
.map(|i| [Block::random(&mut rng), Block::random(&mut rng)])
.map(|_| [Block::random(&mut rng), Block::random(&mut rng)])
.collect();

let receiver_setup = receiver.extension_setup(&choice).unwrap();
Expand Down
3 changes: 1 addition & 2 deletions mpc-core/src/ot/extension/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<
base_receiver_setup: BaseReceiverSetup,
) -> Result<BaseSenderPayload, ExtReceiverCoreError> {
let mut seeds: Vec<[Block; 2]> = Vec::with_capacity(128);
for i in 0..128 {
for _ in 0..128 {
seeds.push([Block::random(&mut self.rng), Block::random(&mut self.rng)]);
}

Expand Down Expand Up @@ -156,7 +156,6 @@ impl<
return Err(ExtReceiverCoreError::NotSetup);
}
let mut values: Vec<Block> = Vec::with_capacity(choice.len());
let r = utils::boolvec_to_u8vec(choice);
let ts = self.table.as_ref().ok_or(ExtReceiverCoreError::NotSetup)?;

for (j, b) in choice.iter().enumerate() {
Expand Down
2 changes: 1 addition & 1 deletion mpc-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ mod tests {
fn test_transpose() {
let mut rng = ChaCha12Rng::from_entropy();
let a: Vec<Vec<u8>> = (0..256)
.map(|i| Vec::from(Block::random(&mut rng).to_be_bytes()))
.map(|_| Vec::from(Block::random(&mut rng).to_be_bytes()))
.collect();
let b = transpose(&a);
assert_eq!(a, transpose(&b));
Expand Down
2 changes: 1 addition & 1 deletion mpc-core/tests/half_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn test_aes_128() {

let gc = gc.to_public(&generator_inputs);
let outputs = ev
.eval(&mut cipher, &circ, &gc, evaluator_input_labels)
.eval(&mut cipher, &circ, &gc, &evaluator_input_labels)
.unwrap();

let expected = circ
Expand Down

0 comments on commit 69b65c4

Please sign in to comment.