Benchmarks and tests

February 13, 2026 · View on GitHub

Running benchmark: 32-bit RSA encryption (64-bit modp)

Circuit: #gates=7366376 (XOR=3146111 AND=3133757 OR=1032350 INV=54158)
┏━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃          Time ┃      % ┃  Xfer ┃
┣━━━━━━━━╋━━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━┫
┃ Wait   ┃  10.72622192s ┃ 75.33% ┃       ┃
┃ Recv   ┃  2.501608027s ┃ 17.57% ┃ 364MB ┃
┃ Inputs ┃  232.257386ms ┃  1.63% ┃  41kB ┃
┃ Eval   ┃  778.170361ms ┃  5.47% ┃       ┃
┃ Result ┃     158.838µs ┃  0.00% ┃   1kB ┃
┃ Total  ┃ 14.238416532s ┃        ┃       ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┛

Optimized full-adder:

Circuit: #gates=7366376 (XOR=5210811 AND=2101407 OR=0 INV=54158)
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃         Time ┃      % ┃  Xfer ┃
┣━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━┫
┃ Wait   ┃   7.9561241s ┃ 76.09% ┃       ┃
┃ Recv   ┃ 1.660386022s ┃ 15.88% ┃ 199MB ┃
┃ Inputs ┃ 232.583145ms ┃  2.22% ┃  41kB ┃
┃ Eval   ┃ 606.479521ms ┃  5.80% ┃       ┃
┃ Result ┃    304.202µs ┃  0.00% ┃   1kB ┃
┃ Total  ┃ 10.45587699s ┃        ┃       ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┛

Karatsuba multiplication algorithm:

Circuit: #gates=6822632 (XOR=4828475 XNOR=58368 AND=1874719 OR=0 INV=61070)
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃         Time ┃      % ┃  Xfer ┃
┣━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━┫
┃ Wait   ┃ 6.672590283s ┃ 75.99% ┃       ┃
┃ Recv   ┃ 1.320621876s ┃ 15.04% ┃ 179MB ┃
┃ Inputs ┃ 231.659961ms ┃  2.64% ┃  41kB ┃
┃ Eval   ┃ 555.192105ms ┃  6.32% ┃       ┃
┃ Result ┃    298.855µs ┃  0.00% ┃   1kB ┃
┃ Total  ┃  8.78036308s ┃        ┃       ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┛

Optimized INV-gates:

Circuit: #gates=6769820 (XOR=4836732 XNOR=58368 AND=1874719 OR=0 INV=1)
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃         Time ┃      % ┃  Xfer ┃
┣━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━┫
┃ Wait   ┃ 6.338729612s ┃ 75.20% ┃       ┃
┃ Recv   ┃ 1.352880139s ┃ 16.05% ┃ 177MB ┃
┃ Inputs ┃  227.12815ms ┃  2.69% ┃  41kB ┃
┃ Eval   ┃ 509.574258ms ┃  6.05% ┃       ┃
┃ Result ┃    344.425µs ┃  0.00% ┃   1kB ┃
┃ Total  ┃ 8.428656584s ┃        ┃       ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┛

Labels by value:

Circuit: #gates=6717340 (XOR=4787324 XNOR=108545 AND=1821471 OR=0 INV=0)
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃         Time ┃      % ┃  Xfer ┃
┣━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━┫
┃ Wait   ┃ 6.117743762s ┃ 77.25% ┃       ┃
┃ Recv   ┃ 1.196140342s ┃ 15.10% ┃ 172MB ┃
┃ Inputs ┃ 236.647371ms ┃  2.99% ┃  41kB ┃
┃ Eval   ┃ 368.944904ms ┃  4.66% ┃       ┃
┃ Result ┃    347.483µs ┃  0.00% ┃   1kB ┃
┃ Total  ┃ 7.919823862s ┃        ┃       ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┛

Labels by value in protocol, garbler, and evaluator:

Circuit: #gates=6717340 (XOR=4787324 XNOR=108545 AND=1821471 OR=0 INV=0)
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃         Time ┃      % ┃  Xfer ┃
┣━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━┫
┃ Wait   ┃ 5.076677475s ┃ 78.67% ┃       ┃
┃ Recv   ┃ 940.758975ms ┃ 14.58% ┃ 143MB ┃
┃ Inputs ┃ 229.741398ms ┃  3.56% ┃  41kB ┃
┃ Eval   ┃ 205.513944ms ┃  3.18% ┃       ┃
┃ Result ┃    185.197µs ┃  0.00% ┃   1kB ┃
┃ Total  ┃ 6.452876989s ┃        ┃       ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┛

Gate wires by value in garbler:

Circuit: #gates=6717340 (XOR=4787324 XNOR=108545 AND=1821471 OR=0 INV=0)
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃         Time ┃      % ┃  Xfer ┃
┣━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━┫
┃ Wait   ┃  4.37061338s ┃ 76.48% ┃       ┃
┃ Recv   ┃  962.20669ms ┃ 16.84% ┃ 143MB ┃
┃ Inputs ┃ 229.360283ms ┃  4.01% ┃  41kB ┃
┃ Eval   ┃ 152.258636ms ┃  2.66% ┃       ┃
┃ Result ┃    162.316µs ┃  0.00% ┃   1kB ┃
┃ Total  ┃ 5.714601305s ┃        ┃       ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┛

Garbler keeping wires in an array instead of map:

Circuit: #gates=6717340 (XOR=4787324 XNOR=108545 AND=1821471 OR=0 INV=0)
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃         Time ┃      % ┃  Xfer ┃
┣━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━┫
┃ Wait   ┃ 1.710655914s ┃ 53.63% ┃       ┃
┃ Recv   ┃ 1.088403425s ┃ 34.12% ┃ 143MB ┃
┃ Inputs ┃ 243.393526ms ┃  7.63% ┃  41kB ┃
┃ Eval   ┃ 146.879726ms ┃  4.61% ┃       ┃
┃ Result ┃      222.8µs ┃  0.01% ┃   1kB ┃
┃ Total  ┃ 3.189555391s ┃        ┃       ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┛

Pruning dead gates:

Circuit: #gates=5972956 (XOR=4315452 XNOR=53761 AND=1603743 OR=0 INV=0)
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃         Time ┃      % ┃  Xfer ┃
┣━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━┫
┃ Wait   ┃  1.28140619s ┃ 55.30% ┃       ┃
┃ Recv   ┃ 676.432166ms ┃ 29.19% ┃ 126MB ┃
┃ Inputs ┃ 229.527559ms ┃  9.91% ┃  41kB ┃
┃ Eval   ┃ 129.623668ms ┃  5.59% ┃       ┃
┃ Result ┃    203.248µs ┃  0.01% ┃   1kB ┃
┃ Total  ┃ 2.317192831s ┃        ┃       ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┛

Optimized garbling:

Circuit: #gates=5972956 (XOR=4315452 XNOR=53761 AND=1603743 OR=0 INV=0)
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃         Time ┃      % ┃  Xfer ┃
┣━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━┫
┃ Wait   ┃ 700.031233ms ┃ 38.57% ┃       ┃
┃ Recv   ┃ 706.339086ms ┃ 38.92% ┃ 126MB ┃
┃ Inputs ┃ 233.615365ms ┃ 12.87% ┃  41kB ┃
┃ Eval   ┃  174.84741ms ┃  9.63% ┃       ┃
┃ Result ┃    215.733µs ┃  0.01% ┃   1kB ┃
┃ Total  ┃ 1.815048827s ┃        ┃       ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┛

Optimized dynamic memory allocations from garbling:

Circuit: #gates=5972956 (XOR=4315452 XNOR=53761 AND=1603743 OR=0 INV=0) #w=5973116
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op     ┃         Time ┃      % ┃  Xfer ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━┩
│ Wait   │ 574.859679ms │ 35.11% │       │
│ Recv   │ 678.520719ms │ 41.44% │ 126MB │
│ Inputs │  274.49709ms │ 16.77% │  41kB │
│ Eval   │   109.1673ms │  6.67% │       │
│ Result │    158.416µs │  0.01% │   1kB │
│ Total  │ 1.637203204s │        │ 126MB │
└────────┴──────────────┴────────┴───────┘

Half And optimization:

Circuit: #gates=5972956 (XOR=4315452 XNOR=53761 AND=1603743 OR=0 INV=0) #w=5973116
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━┓
┃ Op     ┃         Time ┃      % ┃ Xfer ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━┩
│ Wait   │ 653.959737ms │ 50.33% │      │
│ Recv   │ 218.966485ms │ 16.85% │ 75MB │
│ Inputs │  255.00393ms │ 19.63% │ 41kB │
│ Eval   │ 171.306681ms │ 13.18% │      │
│ Result │    131.077µs │  0.01% │  1kB │
│ Total  │  1.29936791s │        │ 75MB │
└────────┴──────────────┴────────┴──────┘

Circuit constant propagation:

Circuit: #gates=5539148 (XOR=3996414 XNOR=48825 AND=1493909 OR=0 INV=0) #w=5539308
┏━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━┓
┃ Op     ┃         Time ┃      % ┃ Xfer ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━┩
│ Wait   │ 672.421083ms │ 52.54% │      │
│ Recv   │ 218.976021ms │ 17.11% │ 69MB │
│ Inputs │ 258.380313ms │ 20.19% │ 41kB │
│ Eval   │ 129.760304ms │ 10.14% │      │
│ Result │    182.268µs │  0.01% │  1kB │
│ Total  │ 1.279719989s │        │ 70MB │
└────────┴──────────────┴────────┴──────┘

CO OT:

Circuit: #gates=5539117 (XOR=3996381 XNOR=48824 AND=1493910 OR=1 INV=1 xor=4045205 !xor=1493912 levels=1604812 width=8259) #w=5539277
┌────────┬──────────────┬────────┬──────┐
│ Op     │         Time │      % │ Xfer │
├────────┼──────────────┼────────┼──────┤
│ Wait   │ 544.037201ms │ 69.10% │      │
│ Recv   │ 119.178002ms │ 15.14% │ 69MB │
│ Inputs │   5.523428ms │  0.70% │  3kB │
│ Eval   │  118.35074ms │ 15.03% │      │
│ Result │    241.858µs │  0.03% │  1kB │
│ Total  │ 787.331229ms │        │ 69MB │
└────────┴──────────────┴────────┴──────┘

Ed25519 signature computation

The first signature computation without SHA-512:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━┓
┃ Op          ┃            Time ┃      % ┃ Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━┩
│ Init        │       141.651µs │  0.00% │ 276B │
│ OT Init     │    243.714662ms │  0.06% │ 264B │
│ Peer Inputs │     69.857046ms │  0.02% │ 10kB │
│ Eval        │ 6m55.975310366s │ 99.92% │ 25GB │
│ Total       │ 6m56.289023725s │        │ 25GB │
└─────────────┴─────────────────┴────────┴──────┘
Max permanent wires: 43786395, cached circuits: 26
#gates=935552365, #non-XOR=291882258

Optimized p2p.Conn.SendUint{16,32}() not to allocate memory:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━┓
┃ Op          ┃            Time ┃      % ┃ Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━┩
│ Init        │        41.043µs │  0.00% │ 276B │
│ OT Init     │     166.70528ms │  0.07% │ 264B │
│ Peer Inputs │     66.153689ms │  0.03% │ 10kB │
│ Eval        │ 3m48.820978578s │ 99.90% │ 25GB │
│ Total       │  3m49.05387859s │        │ 25GB │
└─────────────┴─────────────────┴────────┴──────┘
Max permanent wires: 43786395, cached circuits: 26
#gates=935552365, #non-XOR=291882258

Added one missing ed25519.ScReduce() (+1220540 gates, +381217 non-XOR gates):

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━┓
┃ Op          ┃            Time ┃      % ┃ Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━┩
│ Init        │        64.159µs │  0.00% │ 276B │
│ OT Init     │    317.026065ms │  0.14% │ 264B │
│ Peer Inputs │     66.088379ms │  0.03% │ 10kB │
│ Eval        │ 3m46.188650399s │ 99.83% │ 25GB │
│ Total       │ 3m46.571829002s │        │ 25GB │
└─────────────┴─────────────────┴────────┴──────┘
Max permanent wires: 43892147, cached circuits: 26
#gates=936772905, #non-XOR=292263475

Optimizing p2p.Conn.SendLabel() not to allocate memory:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━┓
┃ Op          ┃            Time ┃      % ┃ Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━┩
│ Init        │        73.349µs │  0.00% │ 276B │
│ OT Init     │    231.818904ms │  0.13% │ 264B │
│ Peer Inputs │     67.641816ms │  0.04% │ 10kB │
│ Eval        │ 2m57.583645976s │ 99.83% │ 25GB │
│ Total       │ 2m57.883180045s │        │ 25GB │
└─────────────┴─────────────────┴────────┴──────┘
Max permanent wires: 43892147, cached circuits: 26
#gates=936772905, #non-XOR=292263475

Optimizing circuit.decrypt() not to allocate memory:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━┓
┃ Op          ┃            Time ┃      % ┃ Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━┩
│ Init        │        72.412µs │  0.00% │ 276B │
│ OT Init     │     201.50279ms │  0.12% │ 264B │
│ Peer Inputs │     66.133977ms │  0.04% │ 10kB │
│ Eval        │ 2m43.437916872s │ 99.84% │ 25GB │
│ Total       │ 2m43.705626051s │        │ 25GB │
└─────────────┴─────────────────┴────────┴──────┘
Max permanent wires: 43893683, cached circuits: 26
#gates=936737641, #non-XOR=292263475

Added SHA-512 computation:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op          ┃            Time ┃      % ┃  Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━┩
│ Init        │       209.487µs │  0.00% │  16kB │
│ OT Init     │     97.139359ms │  0.06% │  264B │
│ Peer Inputs │    4.195529436s │  2.56% │ 667kB │
│ Eval        │ 2m39.404971518s │ 97.38% │  26GB │
│ Total       │   2m43.6978498s │        │  26GB │
└─────────────┴─────────────────┴────────┴───────┘
Max permanent wires: 45442203, cached circuits: 29
#gates=938232660 (XOR=616081537 XNOR=29253505 AND=292519636 OR=363144 INV=14838) #w=968139480

The first correct Ed25519 signature:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op          ┃            Time ┃      % ┃  Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━┩
│ Init        │      1.204858ms │  0.00% │  20kB │
│ OT Init     │    171.049292ms │  0.10% │  264B │
│ Peer Inputs │    4.186015741s │  2.37% │ 667kB │
│ Eval        │ 2m52.585569971s │ 97.54% │  26GB │
│ Total       │ 2m56.943839862s │        │  26GB │
└─────────────┴─────────────────┴────────┴───────┘
Max permanent wires: 53771683, cached circuits: 29
#gates=938713349 (XOR=616368261 XNOR=29253505 AND=292577583 OR=494216 INV=19784) #w=968883849

Optimized smov and srshift instructions:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op          ┃            Time ┃      % ┃  Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━┩
│ Init        │       213.214µs │  0.00% │  16kB │
│ OT Init     │    188.070588ms │  0.12% │  264B │
│ Peer Inputs │    4.129665419s │  2.60% │ 667kB │
│ Eval        │ 2m34.291433121s │ 97.28% │  25GB │
│ Total       │ 2m38.609382342s │        │  25GB │
└─────────────┴─────────────────┴────────┴───────┘
Max permanent wires: 53770978, cached circuits: 26
#gates=932823577 (XOR=612421393 XNOR=29253505 AND=290634679 OR=494216 INV=19784) #w=956830643

Increased p2p bufio buffer size to 1024 * 1024 and optimized wire slice allocations in compiler/ssa/streamer.go:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op          ┃           Time ┃      % ┃  Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━┩
│ Init        │      175.567µs │  0.00% │  16kB │
│ OT Init     │    82.231558ms │  0.06% │  264B │
│ Peer Inputs │   4.117307505s │  3.23% │ 667kB │
│ Eval        │ 2m3.276233546s │ 96.71% │  25GB │
│ Total       │ 2m7.475948176s │        │  25GB │
└─────────────┴────────────────┴────────┴───────┘
Max permanent wires: 53770978, cached circuits: 26
#gates=932823577 (XOR=612421393 XNOR=29253505 AND=290634679 OR=494216 INV=19784) #w=956830643

Optimized p2p writer and reader:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op          ┃            Time ┃      % ┃  Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━┩
│ Init        │        166.41µs │  0.00% │    0B │
│ OT Init     │    409.906284ms │  0.39% │  16kB │
│ Peer Inputs │    4.137928557s │  3.91% │ 667kB │
│ Eval        │ 1m41.187033817s │ 95.70% │  25GB │
│ Total       │ 1m45.735035068s │        │  25GB │
└─────────────┴─────────────────┴────────┴───────┘
Max permanent wires: 53770978, cached circuits: 26
#gates=932823577 (XOR=612421393 XNOR=29253505 AND=290634679 OR=494216 INV=19784) #w=956830643

Half AND:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op          ┃            Time ┃      % ┃  Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━┩
│ Init        │       165.871µs │  0.00% │    0B │
│ OT Init     │    219.979136ms │  0.21% │  16kB │
│ Peer Inputs │    4.091995195s │  3.94% │ 667kB │
│ Eval        │ 1m39.488931885s │ 95.85% │  16GB │
│ Total       │ 1m43.801072087s │        │  16GB │
└─────────────┴─────────────────┴────────┴───────┘
Max permanent wires: 53770978, cached circuits: 26
#gates=932823577 (XOR=612421393 XNOR=29253505 AND=290634679 OR=494216 INV=19784) #w=956830643

Fastpath:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op          ┃            Time ┃      % ┃  Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━┩
│ Init        │       173.549µs │  0.00% │    0B │
│ OT Init     │    104.099457ms │  0.11% │  16kB │
│ Peer Inputs │    4.086109869s │  4.38% │ 667kB │
│ Eval        │ 1m29.111191227s │ 95.51% │  16GB │
│ Total       │ 1m33.301574102s │        │  16GB │
└─────────────┴─────────────────┴────────┴───────┘
Max permanent wires: 53770978, cached circuits: 26
#gates=932823577 (XOR=612421393 XNOR=29253505 AND=290634679 OR=494216 INV=19784) #w=956830643

Circuit constant propagation:

┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┓
┃ Op          ┃            Time ┃      % ┃  Xfer ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━┩
│ Init        │      1.272423ms │  0.00% │    0B │
│ OT Init     │    176.148754ms │  0.20% │  16kB │
│ Peer Inputs │     4.10966228s │  4.57% │ 667kB │
│ Eval        │ 1m25.673832556s │ 95.23% │  15GB │
│ Total       │ 1m29.960916013s │        │  15GB │
└─────────────┴─────────────────┴────────┴───────┘
Max permanent wires: 53768930, cached circuits: 26
#gates=844095703 (XOR=542214087 XNOR=29105707 AND=272261909 OR=494216 INV=19784) #w=868102769

Compiler optimizations:

┌─────────────┬─────────────────┬────────┬───────┐
│ Op          │            Time │      % │  Xfer │
├─────────────┼─────────────────┼────────┼───────┤
│ Compile     │    2.257813981s │  2.57% │       │
│ Init        │      1.681455ms │  0.00% │    0B │
│ OT Init     │    281.670059ms │  0.32% │  16kB │
│ Peer Inputs │    4.026191293s │  4.58% │ 667kB │
│ Garble      │ 1m21.278656046s │ 92.52% │  15GB │
│ Result      │      1.402231ms │  0.00% │   8kB │
│ Total       │ 1m27.847415065s │        │  15GB │
└─────────────┴─────────────────┴────────┴───────┘
Max permanent wires: 53913890, cached circuits: 25
#gates=830082709 (XOR=533261481 XNOR=28815787 AND=267491441 OR=494216 INV=19784 xor=562077268 !xor=268005441 levels=10548 width=1796) #w=853799279

Parallel garbling/write:

┌─────────────┬─────────────────┬────────┬───────┐
│ Op          │            Time │      % │  Xfer │
├─────────────┼─────────────────┼────────┼───────┤
│ Compile     │     2.30262394s │  2.83% │       │
│ Init        │      1.752775ms │  0.00% │    0B │
│ OT Init     │     64.949902ms │  0.08% │    0B │
│ Peer Inputs │    4.064791311s │  4.99% │ 684kB │
│ Garble      │ 1m15.021796109s │ 92.10% │  15GB │
│ Result      │      3.844879ms │  0.00% │  17kB │
│ Total       │ 1m21.459758916s │        │  15GB │
└─────────────┴─────────────────┴────────┴───────┘

CO OT:

┌─────────────┬─────────────────┬────────┬──────┐
│ Op          │            Time │      % │ Xfer │
├─────────────┼─────────────────┼────────┼──────┤
│ Compile     │    2.192778168s │  2.82% │      │
│ Init        │      2.127053ms │  0.00% │   0B │
│ OT Init     │        10.404µs │  0.00% │   0B │
│ Peer Inputs │     86.187868ms │  0.11% │ 74kB │
│ Garble      │ 1m15.571077934s │ 97.07% │ 15GB │
│ Result      │       338.085µs │  0.00% │ 55kB │
│ Total       │ 1m17.852519512s │        │ 15GB │
└─────────────┴─────────────────┴────────┴──────┘
Max permanent wires: 53913890, cached circuits: 25
#gates=830166294 (XOR=533177896 XNOR=28813441 AND=267575026 OR=496562 INV=103369 xor=561991337 !xor=268174957 levels=10548 width=1796)
#w=853882864

Optimized compiler/circuits/Wire data structure:

┌─────────────┬─────────────────┬─────────┬────────┐
│ Op          │            Time │       % │   Xfer │
├─────────────┼─────────────────┼─────────┼────────┤
│ Compile     │    2.179716097s │   2.90% │        │
│ Init        │      2.321499ms │   0.00% │     0B │
│ OT Init     │         8.833µs │   0.00% │   16kB │
│ Peer Inputs │     43.987663ms │   0.06% │   57kB │
│ Garble      │ 1m12.830374104s │  97.03% │   15GB │
│ Result      │       431.631µs │   0.00% │    8kB │
│ Total       │ 1m15.056839827s │         │   15GB │
│ ├╴Sent      │                 │ 100.00% │   15GB │
│ ├╴Rcvd      │                 │   0.00% │   45kB │
│ ╰╴Flcd      │                 │         │ 231284 │
└─────────────┴─────────────────┴─────────┴────────┘
Max permanent wires: 53913890, cached circuits: 25
#gates=830166294 (XOR=533177896 XNOR=28813441 AND=267575026 OR=496562 INV=103369 xor=561991337 !xor=268174957 levels=10548 width=1796) #w=853882864

Changes:

  • changed compiler/circuits/MakeWires to allocate wires as one continuous array
  • Go 1.21.0
  • Added apps/garbled/default.pgo
┌──────────────┬─────────────────┬─────────┬────────┐
│ Op           │            Time │       % │   Xfer │
├──────────────┼─────────────────┼─────────┼────────┤
│ Compile      │    2.201645057s │   3.09% │        │
│ Init         │      2.355373ms │   0.00% │     0B │
│ OT Init      │          7.79µs │   0.00% │   16kB │
│ Peer Inputs  │     43.485891ms │   0.06% │   57kB │
│ Stream       │   1m8.95812062s │  96.84% │   15GB │
│ ├╴InstrInit  │    4.142664938s │   6.01% │        │
│ ├╴CircComp   │     33.135987ms │   0.05% │        │
│ ├╴StreamInit │    2.519242464s │   3.65% │        │
│ ╰╴Garble     │  1m1.343566909s │  88.96% │        │
│ Result       │       290.111µs │   0.00% │    8kB │
│ Total        │ 1m11.205904842s │         │   15GB │
│ ├╴Sent       │                 │ 100.00% │   15GB │
│ ├╴Rcvd       │                 │   0.00% │   45kB │
│ ╰╴Flcd       │                 │         │ 231284 │
└──────────────┴─────────────────┴─────────┴────────┘
Max permanent wires: 53913890, cached circuits: 25
#gates=830166294 (XOR=533177896 XNOR=28813441 AND=267575026 OR=496562 INV=103369 xor=561991337 !xor=268174957 levels=10548 width=1796) #w=853882864

Value.HashValue based WireAllocator:

┌──────────────┬────────────────┬─────────┬────────┐
│ Op           │           Time │       % │   Xfer │
├──────────────┼────────────────┼─────────┼────────┤
│ Compile      │    1.89192514s │   2.70% │        │
│ Init         │     2.706353ms │   0.00% │     0B │
│ OT Init      │       11.731µs │   0.00% │   16kB │
│ Peer Inputs  │    45.549977ms │   0.07% │   57kB │
│ Stream       │ 1m8.029901416s │  97.23% │   15GB │
│ ├╴InstrInit  │   2.933100244s │   4.31% │        │
│ ├╴CircComp   │    30.339124ms │   0.04% │        │
│ ├╴StreamInit │   2.608974096s │   3.84% │        │
│ ╰╴Garble     │ 1m1.560371684s │  90.49% │        │
│ Result       │      324.555µs │   0.00% │    8kB │
│ Total        │ 1m9.970419172s │         │   15GB │
│ ├╴Sent       │                │ 100.00% │   15GB │
│ ├╴Rcvd       │                │   0.00% │   45kB │
│ ╰╴Flcd       │                │         │ 231284 │
└──────────────┴────────────────┴─────────┴────────┘
Max permanent wires: 53913890, cached circuits: 25
#gates=830166294 (XOR=533177896 XNOR=28813441 AND=267575026 OR=496562 INV=103369 xor=561991337 !xor=268174957 levels=10548 width=1796) #w=853882864

Optimized compiler/circuits/Wire:

┌──────────────┬────────────────┬─────────┬────────┐
│ Op           │           Time │       % │   Xfer │
├──────────────┼────────────────┼─────────┼────────┤
│ Compile      │   1.870993069s │   2.71% │        │
│ Init         │     2.331431ms │   0.00% │     0B │
│ OT Init      │       10.949µs │   0.00% │   16kB │
│ Peer Inputs  │    44.089085ms │   0.06% │   57kB │
│ Stream       │   1m7.0813688s │  97.22% │   15GB │
│ ├╴InstrInit  │   2.421297578s │   3.61% │        │
│ ├╴CircComp   │     17.09415ms │   0.03% │        │
│ ├╴StreamInit │   2.155089182s │   3.21% │        │
│ ╰╴Garble     │ 1m1.550598148s │  91.76% │        │
│ Result       │       432.27µs │   0.00% │    8kB │
│ Total        │ 1m8.999225604s │         │   15GB │
│ ├╴Sent       │                │ 100.00% │   15GB │
│ ├╴Rcvd       │                │   0.00% │   45kB │
│ ╰╴Flcd       │                │         │ 231284 │
└──────────────┴────────────────┴─────────┴────────┘
Max permanent wires: 53913890, cached circuits: 25
#gates=830166294 (XOR=533177896 XNOR=28813441 AND=267575026 OR=496562 INV=103369 xor=561991337 !xor=268174957 levels=10548 width=1796) #w=853882864

Optimized streamer to use circuit.Wire instead of compiler/circuits/Wire in wire cache:

┌──────────────┬────────────────┬─────────┬────────┐
│ Op           │           Time │       % │   Xfer │
├──────────────┼────────────────┼─────────┼────────┤
│ Compile      │   1.755362404s │   2.64% │        │
│ Init         │      2.79287ms │   0.00% │     0B │
│ OT Init      │       13.525µs │   0.00% │   16kB │
│ Peer Inputs  │    45.376796ms │   0.07% │   57kB │
│ Stream       │ 1m4.624303427s │  97.28% │   15GB │
│ ├╴InstrInit  │   1.166489974s │   1.81% │        │
│ ├╴CircComp   │     18.17144ms │   0.03% │        │
│ ├╴StreamInit │   1.886360054s │   2.92% │        │
│ ╰╴Garble     │ 1m0.866348862s │  94.18% │        │
│ Result       │      225.299µs │   0.00% │    8kB │
│ Total        │ 1m6.428074321s │         │   15GB │
│ ├╴Sent       │                │ 100.00% │   15GB │
│ ├╴Rcvd       │                │   0.00% │   45kB │
│ ╰╴Flcd       │                │         │ 231284 │
└──────────────┴────────────────┴─────────┴────────┘
Max permanent wires: 53913890, cached circuits: 25
#gates=830166294 (XOR=533177896 XNOR=28813441 AND=267575026 OR=496562 INV=103369 xor=561991337 !xor=268174957 levels=10548 width=1796) #w=853882864
       66.59 real        69.15 user         6.69 sys
          3568140288  maximum resident set size
          4119990272  peak memory footprint

Optimized stream garbler and evaluator permanent wire allocation:

┌──────────────┬────────────────┬─────────┬────────┐
│ Op           │           Time │       % │   Xfer │
├──────────────┼────────────────┼─────────┼────────┤
│ Compile      │   2.168279103s │   3.32% │        │
│ Init         │     1.155399ms │   0.00% │     8B │
│ OT Init      │        8.667µs │   0.00% │   16kB │
│ Peer Inputs  │    45.275464ms │   0.07% │   57kB │
│ Stream       │ 1m3.048559635s │  96.61% │   15GB │
│ ├╴InstrInit  │   1.605912018s │   2.55% │        │
│ ├╴CircComp   │    13.741677ms │   0.02% │        │
│ ├╴StreamInit │   108.190472ms │   0.17% │        │
│ ╰╴Garble     │ 1m0.536558004s │  96.02% │        │
│ Result       │      158.736µs │   0.00% │    8kB │
│ Total        │ 1m5.263437004s │         │   15GB │
│ ├╴Sent       │                │ 100.00% │   15GB │
│ ├╴Rcvd       │                │   0.00% │   45kB │
│ ╰╴Flcd       │                │         │ 235345 │
└──────────────┴────────────────┴─────────┴────────┘
Max permanent wires: 69663266, cached circuits: 23
#gates=844183998 (XOR=542126152 XNOR=29103361 AND=272350024 OR=496562 INV=107899 xor=571229513 !xor=272954485 levels=10548 width=1796) #w=868191256
       65.38 real        68.91 user         5.60 sys
          1263144960  maximum resident set size
          1534406656  peak memory footprint

Benchmark snapshot with the latest sources and go1.25.0:

┌──────────────┬────────────────┬─────────┬────────┐
│ Op           │           Time │       % │   Xfer │
├──────────────┼────────────────┼─────────┼────────┤
│ Compile      │   2.169829899s │   3.34% │        │
│ Init         │     1.191631ms │   0.00% │     8B │
│ OT Init      │       12.596µs │   0.00% │   16kB │
│ Peer Inputs  │    47.223559ms │   0.07% │   57kB │
│ Stream       │  1m2.68335876s │  96.58% │   15GB │
│ ├╴InstrInit  │   1.573777358s │   2.51% │        │
│ ├╴CircComp   │    14.305831ms │   0.02% │        │
│ ├╴StreamInit │     108.1213ms │   0.17% │        │
│ ╰╴Garble     │ 1m0.227261821s │  96.08% │        │
│ Result       │      146.013µs │   0.00% │    8kB │
│ Total        │ 1m4.901762458s │         │   15GB │
│ ├╴Sent       │                │ 100.00% │   15GB │
│ ├╴Rcvd       │                │   0.00% │   45kB │
│ ╰╴Flcd       │                │         │ 235345 │
└──────────────┴────────────────┴─────────┴────────┘
Max permanent wires: 69663266, cached circuits: 23
#gates=844183998 (XOR=542126152 XNOR=29103361 AND=272350024 OR=496562 INV=107899 xor=571229513 !xor=272954485 levels=10548 width=1796) #w=868191256
Result[0]: f43c1cf1755345852211942af0838414334eec9cbf36e26a9f9e8d4bb720deb145ffbeec82249c875116757441206bcdc56b501e750f1f590917d772dfee980f
       65.02 real        68.95 user         5.55 sys
          1307033600  maximum resident set size
          1303769088  peak memory footprint

Go1.26.0, OR elimination:

┌──────────────┬────────────────┬─────────┬────────┐
│ Op           │           Time │       % │   Xfer │
├──────────────┼────────────────┼─────────┼────────┤
│ Compile      │   1.920674074s │   2.99% │        │
│ Init         │     1.146779ms │   0.00% │     8B │
│ OT Init      │         7.85µs │   0.00% │   16kB │
│ Peer Inputs  │    62.691021ms │   0.10% │   57kB │
│ Stream       │    1m2.190701s │  96.91% │   15GB │
│ ├╴InstrInit  │   1.283632614s │   2.06% │        │
│ ├╴CircComp   │    13.582819ms │   0.02% │        │
│ ├╴StreamInit │    89.464442ms │   0.14% │        │
│ ╰╴Garble     │ 1m0.078508996s │  96.60% │        │
│ Result       │      148.564µs │   0.00% │    8kB │
│ Total        │ 1m4.175369288s │         │   15GB │
│ ├╴Sent       │                │ 100.00% │   15GB │
│ ├╴Rcvd       │                │   0.00% │   45kB │
│ ╰╴Flcd       │                │         │ 235418 │
└──────────────┴────────────────┴─────────┴────────┘
Max permanent wires: 69663266, cached circuits: 23
#gates=845172430 (XOR=543116930 XNOR=29103361 AND=272844240 OR=0 INV=107899 xor=572220291 !xor=272952139 levels=10548 width=2048) #w=869179688
Result[0]: f43c1cf1755345852211942af0838414334eec9cbf36e26a9f9e8d4bb720deb145ffbeec82249c875116757441206bcdc56b501e750f1f590917d772dfee980f
       64.39 real        67.14 user         5.50 sys
          1425551360  maximum resident set size
          1422180352  peak memory footprint

Theoretical minimum single-threaded garbling time:

XOR:    533177896 *  21.47 = 11447329427.119999 ns
XNOR:   28813441  *  19.98 =   575692551.180000 ns
AND:    267575026 * 155.10 = 41500886532.600000 ns
OR:     496562    * 143.20 =    71107678.399999 ns
INV:    103369    *  77.97 = 53603075870.229996 ns
                             =====================
                             53603075870.229996 ns
                                      53.603076 s

The gate garbling speeds are measured with the circuit/stream_garble_test.go:

cpu: Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
BenchmarkGarbleXOR-8              	59785843	        21.47 ns/op
BenchmarkGarbleXNOR-8             	61427943	        19.98 ns/op
BenchmarkGarbleAND-8              	 7628728	       155.1 ns/op
BenchmarkGarbleOR-8               	 8398204	       143.2 ns/op
BenchmarkGarbleINV-8              	14924721	        77.97 ns/op

RSA signature computation

InputMODPGatesNon-XORStream GatesStream !XORStream
2470820174027197.50ms
485596157155481719250.25ms
81644796124234625213199271.69ms
1632374844102255364892101535295.81ms
326429865568018872895932788799675.86ms
641282317106861370232249452460293112.2685s
128256177580028464953591729455324573209512.9422s
25651213264611803467975671m31.5s
512102410197960188264125235111m28.7s

Refactored math.Exp() to use wideMul() builtin function:

InputGatesNon-XORStream GatesStream !XORStream
641901682849281271.234s
128148924924382154239.341s
25611670036442974069751m12.5s
512916921138823252008959m27.9s

Multiplication

Input SizeTotal gatesNon-XOR gates
273
42913
814557
16655241
3233471100
64135464242
1284924914986
25616797750167
512549965162147
10241752826512099
204854857001592234
4096169540324897756
81925194080314953708

Mathematic operations with compiler and optimized circuits

Optimized circuits from pkg/math/:

ImplementationXOR gatesXOR %!XOR gates!XOR %
add64.circ31363
sub64.circ313126
mul64.circ96424033
div64.circ248175109
MPCL a+b25180.263100.0
MPCL a-b25280.56551.6
MPCL a*b826185.7400799.4
MPCL R int a/b33273134.110463204.8
MPCL R uint a/b32133129.510084197.4
MPCL A int a/b25655103.48574167.8
MPCL A uint a/b2451598.88194160.4
MPCL L int a/b25209101.68447165.3
MPCL L uint a/b2406997.08068160.0