1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#![feature(test)]
#[cfg(test)]
extern crate test;
#[macro_use]
mod util;
#[cfg(test)]
mod tests;
pub mod algebra;
pub mod fieldswitching;
pub mod preprocessing;
pub mod online;
mod oracle;
mod crypto;
mod consts;
mod fieldswitching_proof;
mod proof;
pub use proof::{ProofGf2P64, ProofGf2P64_64, ProofGf2P64_85, ProofGf2P8};
use crate::algebra::RingElement;
use crate::algebra::gf2::BitScalar;
use crate::algebra::z64::Scalar;
pub use util::eval::{evaluate_fieldswitching_btoa_program, evaluate_program};
#[macro_use]
extern crate serde_big_array;
big_array! { BigArray; }
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
pub enum Instruction<E: RingElement> {
NrOfWires(usize),
AddConst(usize, usize, E),
MulConst(usize, usize, E),
LocalOp(usize, usize),
Mul(usize, usize, usize),
Add(usize, usize, usize),
Sub(usize, usize, usize),
Branch(usize),
Input(usize),
Output(usize),
Const(usize, E),
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
pub enum ConnectionInstruction {
BToA(usize, #[serde(with = "BigArray")] [usize; 64]),
AToB(#[serde(with = "BigArray")] [usize; 64], usize),
Challenge(usize),
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ProgramTriple {
pub boolean: Vec<Instruction<BitScalar>>,
pub arithmetic: Vec<Instruction<Scalar>>,
pub connection: Vec<ConnectionInstruction>,
}
type Instructions<D> = Vec<Instruction<<D as algebra::Domain>::Scalar>>;