273 Commits

Author SHA1 Message Date
Edward Chen
b201ecfbcb locating libcrypto in ci machine 2025-02-09 17:13:02 -05:00
Alex Ozdemir
a36eb1faa5 fmt 2025-02-07 14:29:38 -08:00
Alex Ozdemir
eab55b6722 more fmt 2025-02-07 14:25:46 -08:00
Alex Ozdemir
2e7c0aac6d Start fixing the build 2025-02-07 14:10:27 -08:00
Alex Ozdemir
589ae00f3f README: rm circom, add pointer to old implementation 2025-02-06 10:36:44 -08:00
Alex Ozdemir
8140b1369e reduce traversal memory usage through iterators (#209)
Previously, the traversal stack held (node, children queued) pairs.
When visiting a node without it's children queued, we would queue them
all. They take a lot of memory!

Now, the stack holds children iterators.

Also: this patch fixes many bugs introduced by the prior one.
2024-09-29 13:27:26 -07:00
Chad Sharp
d3e1f6817e Z# integers
Co-authored-by: Chad Sharp <chad@cs50.harvard.edu>
2024-09-25 15:52:33 -07:00
Alex Ozdemir
152d5ad531 Opt: memory: linear for [group] const values (#207)
For memories with constant values that have sorts which are linear
groups, there is a way to optimize linear-scan memory-checking.

This patch implements that optimization.
2024-08-19 11:51:01 -07:00
Alex Ozdemir
2b54efa5a4 Reduce the number of rounds in ROM checking to 2. (#204)
It was spuriously three because of imprecise dependency tracking
2024-07-08 16:54:14 -07:00
Alex Ozdemir
1224730215 bugfix: type error in obliv (#203) 2024-07-01 15:09:41 -07:00
Alex Ozdemir
347926501f Eliminate tuples in preprocessing (#202)
This started as an optimization patch, but my first optimization
revealed a bug. In chasing the bug, I found more optimization.

Changes:
1. Eliminate tuples in preprocessing. (opt)
2. Handle CStore in tuple elimination pass. (bugfix)
3. Use tuples instead of arrays in a few more extension ops: (opt)
  * GCD for vanishing polynomials and their derivatives
  * sorting in transcript checking
4. A few logging revisions
2024-06-27 11:35:18 -07:00
Alex Ozdemir
913da600ab fix doc gen and add to CI (#201) 2024-06-24 19:14:04 -07:00
Alex Ozdemir
4c3a1a5ac5 Arc<> in Sort (#200)
Decreases memory use in matrix multiply by up to 2.5x
2024-06-24 10:30:12 -07:00
Alex Ozdemir
4aa36e479f Decrease the size of Op and Sort. (#199) 2024-06-24 08:35:05 -07:00
Alex Ozdemir
ce5ce47a33 move op Display impls to ir::term::fmt (#198) 2024-06-23 10:48:01 -07:00
Alex Ozdemir
61059d716b Move term eval to new module (#197) 2024-06-23 10:21:29 -07:00
Alex Ozdemir
2cdc019b86 Merge updates needed for SHA with lookups. (#196)
This is highly unoptimized, for now.
2024-06-19 13:09:43 -07:00
Alex Ozdemir
aa318e55a5 opts and tests from the memory project (#195) 2024-06-11 16:50:35 -07:00
Alex Ozdemir
ca70537b68 bugfix: opt::mem::obliv (#194)
recognize scalar variables as tuple-free
2024-06-02 13:31:05 -07:00
Alex Ozdemir
9ac4c26546 further fix OOB indices in lin (#193)
test them in lin and tr
2024-05-31 01:58:43 -07:00
Alex Ozdemir
2bf4f8252a handle CStore in linearization pass (#190) 2024-05-24 13:28:21 -07:00
Alex Ozdemir
7f6d0a00fe Make the IR1CS optimizer more aggressive (#188)
Previously, we would eliminate only final-round witnesses. This is
obviously sound, but sub-optimal.

Anna has found some protocols (SHA with lookups) where the
sub-optimality matters, so I've made the optimizer a bit more
aggressive.
2024-04-16 23:43:29 -07:00
Alex Ozdemir
3ba1be4653 array v->k lookups, membership assertions, and witness computation in Z# (#186)
* draft: rev-lookup, in-array, witness

* lint

* sparse examples

* fmt
2024-04-05 11:55:02 -07:00
Alex Ozdemir
41361e4dc6 Document zokrates_test.zsh 2024-03-31 09:44:04 -07:00
Alex Ozdemir
0b88154ceb Implement ROM-checking based on Haboeck's lookup argument (#185) 2024-02-22 22:40:11 -08:00
Alex Ozdemir
2ebd0a11fa Fix spartan (and include its tests in CI) (#184)
Spartan bit-rotted because CI was misconfigured.
2024-01-31 16:20:16 -08:00
Alex Ozdemir
d0b529bc8b optimize prover: buffered IO (#183)
optimize prover: buffered IO

Both the bellman and spartan backends were using unbuffered IO. Ouch.
2024-01-03 17:13:56 -08:00
Alex Ozdemir
cafb02b848 optimize bellman ZK prover backend (#182)
three changes:
* faster integer->ff conversion
* parallel construction of bellman LCs
* parallel R1CS checking (on the CirC side)

The first change is the most important, by far. Our previous integer->ff
conversion was very slow.
2024-01-03 16:39:05 -08:00
Alex Ozdemir
6133414b44 lint (#181) 2023-12-13 08:17:41 -08:00
Alex Ozdemir
697c240148 mem notes 2023-12-12 19:24:05 -08:00
Alex Ozdemir
a26533baad zxi now takes optional inputs (#180) 2023-11-15 13:46:09 -08:00
Alex Ozdemir
fca98ddc5a add sample_challenge builtin (#179) 2023-11-15 09:59:29 -08:00
Alex Ozdemir
7a805323d0 Optimized transcript checking for covering ROMs (#178) 2023-11-14 18:20:39 -08:00
Alex Ozdemir
68b0b45556 User-directed transcript-based RAM checking. (#176)
* user-directed transcript-based RAM checking

when the `transcript` type qualifier is used.

* fix ram tests

* fmt & lint

* rm incomplete test
2023-11-02 23:50:16 -07:00
Alex Ozdemir
c0355299df r1cs optimization bugfix: use tracking (#175)
The R1CS optimizer tracks variable uses so that it can run faster.

Our tracker would sometimes think that a variable has cancelled from a
constraint when it had not.

Now, the tracker is conservative, but correct.
2023-10-31 11:41:38 -07:00
Alex Ozdemir
805a7f424f RAM for non-scalar values (#174)
It is very naive. It assumes that any top-level array should be represented as a RAM, and that all internal structure should be unfolded.
2023-10-17 22:04:38 -07:00
Alex Ozdemir
4c5dafee95 A Waksman-based RAM permutation argument (#171)
This allows folks to use the RAM machinery while sticking with (non-interactive) R1CS output.

We're going to need this anyway when we benchmark our new approach.
2023-09-19 02:39:24 -07:00
Alex Ozdemir
64dcc18175 Improve RAM: oblivious & volatile (#170)
* Improve the oblivious RAM pass by killing the hack where we treat selects as arrays.
* Fix a bug where the volatile RAM pass would not place selects before stores against the same array
* Improve that volatile RAM pass by placing selects against the same array literal in the same RAM. Before, they would each end up in different RAMs, which sucks. This is especially bad for ROMs.
2023-09-18 11:07:19 -07:00
Alex Ozdemir
fb198eeadd ram structure example (#169) 2023-09-14 13:34:27 -07:00
Alex Ozdemir
a586f7f95d GC after each optimization (#167)
Flag: `--ir-frequent-gc true`

Reduces memory usage on Jess & Eli's pgm from 398MB to 285MB.
2023-08-11 16:37:46 -07:00
Alex Ozdemir
d7217e559e Optimize GC (#166)
Previously, a GC call would scan the HC table, identifying dead nodes.

Now, whenever a Node is destroyed, if it's ready to be GC'd, it gets added to a list. That list is used at GC time instead of the scan.

This substantially decreases the cost of running GC many times (as the Z# FE does).
2023-07-09 14:45:14 -07:00
Alex Ozdemir
bf3d9c601e Remove dead r1cs vars after opt (#164)
We were already removing those that are explicitly eliminated, but they
can become dead in other ways too.
2023-06-22 19:44:35 -07:00
Alex Ozdemir
079eea1ae9 r1cs: fix boolean majority (#163)
* r1cs: fix boolean majority

for m = majority(a,b,c),
we were lowering

    (-ab + bc + ac - 2abc)

instead of

    (ab + bc + ac - 2abc)

Whoops! This is a functional correctness bug: we were lowering
soundly and completely, for the wrong specification.

Credit to Anna for raising the issue!

* add test_sha256 (commented out b/c it is slow)

* fmt + lint
2023-06-14 15:14:05 -07:00
Edward Chen
bd9cec31fb Replaced third party dependencies with binaries to reduce CI build times (#162)
To reduce CI build time:
- Replaced ABY dependency with corresponding binary.
- Removed dependencies on KaHIP and KaHyPar for now because these dependencies aren't used upstream.
Minor updates:
- Updated ABY source to Public branch
Note: 
- The aby_interpreter binary will only work on Linux. We can rebuild the binary from this repo.
2023-06-14 14:58:39 -04:00
Alex Ozdemir
961fda6fb3 Fix bug in r1cs lowering for bv cmps (#161)
We called the wrong function...
This is a soundness bug.

Credit to Anna for reporting this.
2023-06-14 09:53:10 -07:00
Alex Ozdemir
e404c13468 Access array without it cloning it. (#160)
All credits to Evan for finding this.

Co-authored-by: Evan Laufer <evan.m.laufer@gmail.com>
2023-05-26 15:33:05 -07:00
Alex Ozdemir
18990d079e Inline small elements in FieldV. (#156)
reduces memory usage during R1CS lowering by ~40%.
2023-03-20 08:59:23 -07:00
Edward Chen
2e2bf85399 Linker Optimization Pass Documentation clean-up (#155) 2023-03-15 22:27:25 -04:00
Alex Ozdemir
706405fd4f Committed witnesses & randomness in Z# (& tests) (#154)
A basic implementation of committed witnesses & volatile RAM extraction in the Z# front-end.

The passes in question are still a bit brittle, so I left them behind a flag.
2023-03-15 16:28:19 -07:00
Edward Chen
a49e03abfb Linker Optimization Pass clean-up (#153) 2023-03-15 15:21:19 -04:00