mirror of
https://github.com/tlsnotary/tlsn.git
synced 2026-01-09 14:48:13 -05:00
added some comments
This commit is contained in:
@@ -49,6 +49,7 @@ impl Circuit {
|
||||
}
|
||||
}
|
||||
|
||||
/// Evaluates the circuit in plaintext with the provided inputs
|
||||
pub fn eval<E: GateOps>(&self, inputs: Vec<Vec<E>>) -> Result<Vec<E>, CircuitEvalError> {
|
||||
let mut wires: Vec<Option<E>> = vec![None; self.nwires];
|
||||
let inputs = inputs.concat();
|
||||
|
||||
@@ -22,7 +22,7 @@ fn line2vec<'a>(re: &Regex, line: &'a str) -> Result<Vec<&'a str>, CircuitParser
|
||||
|
||||
impl Circuit {
|
||||
/// Parses circuit files in Bristol Fashion format as specified here:
|
||||
/// https://homes.esat.kuleuven.be/~nsmart/MPC/
|
||||
/// `https://homes.esat.kuleuven.be/~nsmart/MPC/`
|
||||
pub fn parse(filename: &str) -> Result<Self, CircuitParserError> {
|
||||
let f = File::open(filename)?;
|
||||
let mut reader = BufReader::new(f);
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::gate::GateOps;
|
||||
|
||||
pub type Bool = u8;
|
||||
|
||||
/// Implements circuit operations for boolean elements
|
||||
impl GateOps for Bool {
|
||||
/// XOR `self` and `x`
|
||||
fn xor(&self, x: &Bool) -> Result<Bool, GateOpsError> {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
mod boolean;
|
||||
pub mod boolean;
|
||||
|
||||
pub use boolean::Bool;
|
||||
|
||||
@@ -9,6 +9,7 @@ use cipher::{consts::U16, generic_array::GenericArray, BlockCipher, BlockEncrypt
|
||||
pub struct HalfGateEvaluator;
|
||||
|
||||
impl HalfGateEvaluator {
|
||||
/// Evaluates AND gate
|
||||
#[inline]
|
||||
pub fn and_gate<C: BlockCipher<BlockSize = U16> + BlockEncrypt>(
|
||||
&self,
|
||||
@@ -33,11 +34,13 @@ impl HalfGateEvaluator {
|
||||
w_g ^ w_e
|
||||
}
|
||||
|
||||
/// Evaluates XOR gate
|
||||
#[inline]
|
||||
pub fn xor_gate(&self, x: Block, y: Block) -> Block {
|
||||
x ^ y
|
||||
}
|
||||
|
||||
/// Evaluates INV gate
|
||||
#[inline]
|
||||
pub fn inv_gate(&self, x: Block, public_label: Block) -> Block {
|
||||
x ^ public_label
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::garble::circuit::GarbledCircuit;
|
||||
use cipher::{consts::U16, generic_array::GenericArray, BlockCipher, BlockEncrypt};
|
||||
|
||||
pub trait GarbledCircuitEvaluator {
|
||||
/// Evaluates a garbled circuit with the provided input labels
|
||||
fn eval<C: BlockCipher<BlockSize = U16> + BlockEncrypt>(
|
||||
&self,
|
||||
c: &mut C,
|
||||
|
||||
@@ -9,6 +9,7 @@ use cipher::{consts::U16, generic_array::GenericArray, BlockCipher, BlockEncrypt
|
||||
use rand::{CryptoRng, Rng};
|
||||
|
||||
pub trait GarbledCircuitGenerator {
|
||||
/// Generates a garbled circuit
|
||||
fn garble<R: Rng + CryptoRng, C: BlockCipher<BlockSize = U16> + BlockEncrypt>(
|
||||
&self,
|
||||
c: &mut C,
|
||||
|
||||
Reference in New Issue
Block a user