199 Commits

Author SHA1 Message Date
Evan Laufer
bda8675164 Merge commit '84b2f33e5f9b6006fadfd28a4f3fa91831209f03' into ram 2022-10-24 08:05:24 -07:00
Evan Laufer
65afa14da8 Add bellman modifications to tree 2022-10-24 07:56:07 -07:00
Evan Laufer
84b2f33e5f Update pest parsers to use PrattParser (#108)
pest::prec_climber has been deprecated.
also, fix some clippy lints
2022-10-13 11:25:46 -07:00
Edward Chen
e2edbadd0d Clone audit of the C frontend (#106) 2022-10-12 11:55:44 -07:00
Evan Laufer
ee30c0c958 Fix mirage feature flags 2022-10-10 13:45:44 -07:00
Evan Laufer
37faf3055c Merge branch 'master' of github.com:emlaufer/circ into ram 2022-10-10 13:42:03 -07:00
Evan Laufer
afa6618670 Add public coins and mirage prover 2022-10-10 09:57:40 -07:00
Edward Chen
30c88d55f3 Rotation IR intrinsic for SIMD FHE operations (#107) 2022-10-09 00:11:17 -04:00
Alex Ozdemir
c1bac11486 Broader SHA bitwise ITE optimization (#104)
It detects bitwise BV ITEs expressed using and XOR/OR of ANDs with a
NOT. Now it triggers more often.

This cuts a few percentage points (~10%) worth of constraints on ZoK's
shaRound circuit.
2022-09-12 17:20:20 +02:00
Alex Ozdemir
f6c37b505b R1CS scalability bugfix (#102)
Reduce Restrict::restrict_to_inputs from n*n to n

It needs to compute the set of terms which only on inputs in S.
It did this via *separate* containment checks for each term.
But, of course, there is a simple graph traversal that does O(1) work
per term.
I'm taking this patch now b/c I need it. All credits to Evan.
It passes our ZK tests, and a wrote a few unit tests.

Co-authored-by: Evan Laufer <evan.m.laufer@gmail.com>
2022-09-12 16:56:19 +02:00
Alex Ozdemir
15eadb6110 Fix Linter Warnings (#103) 2022-09-12 16:04:23 +02:00
Alex Ozdemir
4686854248 fmt (#98) 2022-08-12 07:32:57 -04:00
Alex Ozdemir
05ca4eda11 bv uext in smt output (#97) 2022-08-12 07:07:34 -04:00
Riad S. Wahby
20198e9012 add.c: mpc_main -> main (#96) 2022-08-03 17:38:18 -04:00
Alex Ozdemir
e362f9501b change ffOP to ff.OP in SMT backend (#94) 2022-08-01 17:12:04 -07:00
Alex Ozdemir
59d5087ab0 lint (#93) 2022-07-27 13:26:04 -07:00
Alex Ozdemir
106af9e016 integer constant folding (#92) 2022-07-27 13:16:06 -07:00
Alex Ozdemir
0b3c936a40 Integers (#91)
We already had sorts and values. Now we have operators too. These are only really in the SMT backend right now.
2022-07-26 15:12:14 -07:00
Evan Laufer
152eefc488 Fix r1cs time 2022-07-22 15:00:15 -07:00
Alex Ozdemir
2d0709342e bugfix: pfadd->pfmul (#90) 2022-07-22 09:01:18 -07:00
Evan Laufer
42bc753874 make ram pass better 2022-07-17 22:44:53 -07:00
Evan Laufer
3ea06145c1 Fix ram indices to use ram values for nested lookups 2022-07-13 13:26:15 -07:00
Evan Laufer
c0dff7a63b add ark things to third_party 2022-07-12 15:58:30 -07:00
Evan Laufer
8005aa2e37 Intermediary testing commit 2022-07-12 15:54:05 -07:00
Evan Laufer
c45f736e72 Merge branch 'master' of github.com:emlaufer/circ 2022-07-05 11:31:57 -07:00
Evan Laufer
9f39451a54 Add marlin proof system 2022-07-05 11:31:34 -07:00
Evan Laufer
7a779b478b Add encoding of checks for simple RAMs 2022-06-29 14:55:47 -07:00
Evan Laufer
cf6010869a Add encoding of checks for simple RAMs 2022-06-29 11:49:36 -07:00
Alex Ozdemir
8bd4dbaeed ZoKrates assertion bugfix and option to isolate (#89) 2022-06-23 22:14:58 -07:00
Alex Ozdemir
0658102675 RAM extraction (#88) 2022-06-23 07:33:34 -07:00
Alex Ozdemir
e9b777f40e r1cs: lift r1cs to IR term (#87) 2022-06-17 20:12:45 -07:00
Alex Ozdemir
526f5c8675 smt: ff writing & SMT2 query writer (#86) 2022-06-17 16:28:21 -07:00
Edward Chen
f88379f96f Updated binarize optimization pass (#85) 2022-05-23 23:59:03 -04:00
Edward Chen
7693d30975 Updates to C Frontend (#67)
Supporting:
- structs
- ptrs
- n-dimension arrays
- nested structs
- typedef
- sizeof
- shift operations

Benchmarks:
- Original HyCC kmeans testcase (without recursion).
- Original HyCC gauss testcase.

Co-authored-by: Alex Ozdemir <aozdemir@hmc.edu>
Co-authored-by: Ubuntu <ubuntu@neptune2.maas>
2022-05-20 02:20:36 -04:00
Alex Ozdemir
c1293464d2 Precomputations (or, as-known-for-proofs, witness extension) (#80)
Co-authored-by: Riad S. Wahby <rsw@jfet.org>
2022-05-17 08:54:04 -07:00
Alex Ozdemir
2537f4708e function calls (#83) 2022-05-16 09:12:37 -07:00
Riad S. Wahby
028f747f4d concurrency fixes for garbage collection (#81)
* concurrency fixes for garbage collection

* COLLECT lock even when not testing
2022-05-07 17:20:27 -07:00
Alex Ozdemir
fa671673a8 Bugfix: non-recursive type-checking for Op::Map (#82)
Credits to @kwantam for noticing the bug. Thank you!
2022-05-07 12:31:37 -07:00
Riad S. Wahby
a3fa232ba2 improve memory consumption ; add Z# strict unary op, ternary ?:, and type aliases (#77)
* update TODO

* add quiet mode to zxc

* Drop and garbage collection

This commit adds Drop instances and related functionality that force
garbage collection at life cycle end of various structs that contain
Terms.

I didn't implement Drop for Computation because its Terms are generally
moved into a converter. This means that back-ends are responsible for
garbage collecting (see new functionality in ILP, R1cs, and ABY).

* collect the cfold table, too

* prevent double-panic as a result of garbage_collect()

* z# parser: zx is a default extension too

* update Cargo.lock

* strictness un-op #()

also added err messages for asserts and ?: ternary support from ZoK upstream

* for assignments, strict rhs => strict lhs

* zsharp: type definitions WIP

Still missing monomorphization.

* type defns: generic inference

* struct monomorphization for type aliased structs

* different approach: no monomorphization, just canonicalize aliases

* canonicalize struct names

* typedef tests

things work except that importing an alias and not its referent breaks typechecking

* add error message about needing to import referent structs

* update hashconsing pointer in Cargo.toml

* maybe_garbage_collect should also return early when panicking

Co-authored-by: Alex Ozdemir <aozdemir@hmc.edu>
2022-05-04 10:08:23 -07:00
Edward Chen
4b01634d7d Type checks for ABY translation (#76) 2022-04-19 21:32:36 -04:00
Alex Ozdemir
157370f307 Eliminate tuples with persistent vectors (#75)
Change: The tuple elimination pass now represents its *tuple trees*
using nested persistent vectors of non-tuple terms, rather than standard
terms.

Rationale: When large oblivious arrays are transformed to tuples, said
tuples are large, and updates to them use the tuple update operator.
However, when we eliminate those tuples, we essentially replace the
update operator with an explicit tuple (tree). For a large number of
updates, this entails quadratic memory usage.

Of course, it doesn't *need* to: each update only modifies one spot in
the tuple.

Thus, in this patch, we change the representation of tuples in tuple
tree from a standard term---whose children are in a vector---such that
the children are now in a persistent vector from the `im` crate. This
allows for an "update" operation on the vector that takes log time and
log new space.

Effect: This reduces the compiler's memory usage on
`examples/C/mpc/benchmarks/2pc_biomatch_40x.c` from ~28GB to ~1GB. It
also makes the compiler substantially faster on that benchmark.
2022-04-11 13:13:58 -07:00
Alex Ozdemir
0b42f26089 Improve non-recursive type-checking (#74)
In *non-recursive* type-checking, perhaps better called *type computing*
we perform a minimal traversal in order to compute the type of a term,
without recursively type-checking it. Informally, we assume it is well
typed, and do the minimal amount of work needed to compute its type.

Two improvements:
1. No longer implemented with recursion.
2. Caches all intermediate results.

Implementation:
* `check_dependencies(Term) -> Vec<Term>`: maps a terms to the immediate
  children of it whose types are needed to compute its type.
* `check_raw_step(Term, TypeTable) -> Sort`: assumes those children have
  their types in the table, and computes this term's type.
* `check_raw`: glues the two above functions together into a suitable
  traversal. Similar to `rec_check_raw`, but the traversal isn't total.

Significance:

Previously, we had a non-recursive implementation for array stores that
*didn't cache intermediate results* which could cause quadratic
type-checking time (if the type-check callee was doing a top-down
traversal). Edward sent me a benchmark that was experiencing this,
resulting in 74.1% of total compilation time being spent type-checking.
Now it's down to 0.4% of total compilation time.
2022-04-11 11:41:02 -07:00
Riad S. Wahby
50b97f6acb zsharp fixes ; speed improvements (#73)
This PR does two things:

- Fixes some scoping issues in Z# having to do with the context in which function and struct definitions are interpreted.
- Improves speed and reduces TermTable memory consumption by 2x (by keying on Arc<TermData> rather than TermData)
- Improves speed for Z# array handling with a BTreeMap -> HashMap swap
- Adds intrinsic widening casts in Z#. These were previously handled by bit-splitting, which is wasteful.
 
On array-heavy Z# programs, this PR improves speed by about 5x and memory consumption by roughly the same.

---

* zsharp::term::ir_array should use HashMap (faster, less memory)

* perf improvements

constant folding: get rid of redundant clones
bitvector: impl arith for refs
TermTable: don't store redundant term as key

* EMBED widening casts

* generic inf: need to push fn defn context onto filestack

* canonicalize path in err msg

* need struct defn on filestack, too

* no need to warn about U32 indexing in zsharp

* fix warning
2022-04-08 21:16:35 -04:00
Edward Chen
2052869261 Removing old ABY dependency (#63)
* removing EzPC dependency
* removing old ABY dependencies
2022-04-07 14:03:27 -04:00
Edward Chen
63e3bea1b8 Adding benchmark scripts and logging for ABY backend (#72) 2022-04-06 04:04:52 -04:00
Edward Chen
ffa2ac3dc9 Updated ABY tests to ignore logging code (#71) 2022-04-05 02:08:40 -04:00
Alex Ozdemir
c784bf7054 Typo in CSE project 2022-03-27 20:24:20 -07:00
Alex Ozdemir
bdd3c59a3c Two write-ups (#68) 2022-03-27 18:45:03 -07:00
Riad S. Wahby
8c8e704914 field flexibility ; add limit for linearity reduction (#66)
Co-authored-by: Alex Ozdemir <aozdemir@hmc.edu>
2022-03-25 15:03:09 -07:00
Edward Chen
13f9a092b5 Updated ABY VM to include IN bytecode instruction (#65)
- updated ABY interpreter to include IN gates
- Added tqdm requirement
2022-03-24 15:53:44 -04:00