Commit Graph

101 Commits

Author SHA1 Message Date
Clive2312
6ca9d6c698 assignment mode support 2022-03-17 04:27:11 +00:00
Edward Chen
9bbcbb517d bytecode + mut graph 2022-02-24 21:42:06 -05:00
Edward Chen
7716e956c1 merged aby interpreter and mut graphing 2022-02-24 15:06:13 -05:00
Edward Chen
fc5621ec10 tested! 2022-02-22 17:35:03 -05:00
Edward Chen
2b36c986e0 updated ABY 2022-02-17 17:32:18 -05:00
Edward Chen
7fec867319 aby interpreter! 2022-02-14 22:07:45 -05:00
Edward Chen
9a51697956 bytecode parser 2022-02-13 01:48:07 -05:00
Edward Chen
99305e3a2e remove input parser 2022-02-10 03:10:51 -05:00
Edward Chen
2c252b63f8 updated ABY test setup 2022-02-10 03:07:44 -05:00
Edward Chen
bd58945b53 new input parser for testing 2022-02-09 16:12:54 -05:00
Edward Chen
331b8b07a0 minor 2022-02-09 16:05:51 -05:00
Edward Chen
3a4642223a new parser 2022-02-09 02:13:10 -05:00
Edward Chen
6a6126509d merged with master 2022-02-07 19:34:18 -05:00
Riad S. Wahby
52f793f3a0 feature branch: zsharp (#30)
* macos deps script (broken on M1 for now)

* arch dep should be coin-or-cbc

* ZoK 0.7.6 support megat status-commit

- bring in ZoK 0.7.6 libraries

- port in diffs from old thirdparty

- first-cut const and literal support

- add toposort for includes so that we can resolve const values in next pass

- statement handling, include-walking fix

- type should cover u64 case, too

- structs: store for now

- const handling

- flatten import map up-front to make later derefs easier to handle

- stash note

- need array consts, too

- rough in const array support, I think

- error message

- small cleanups: change type of ZGen::constants and make comments more meaningful

- generics in fn calls

- small: better error message

- need to resolve exprs as const in const_type_

- wip simple typing pass

- ast visitor wip

- zokrates ast visitor 1st cut

- double check that we cover all product types

- const typing visitor ; visitor error handling

- reorg visit_files ; unification infra wip

- unification infra wip

- need to walk accesses for an assignment

- walk_accesses wip

- small q

- refactor: data structs should be Hash(Hash), not flat

- walk_accesses wip

- monomorphize structs on LHS of declarations

- check identifiers when monomorphizing structs

- unification wip

- unification wip

- inline struct members must declare all fields

- unification for array_initializer

- unify postfix

- unify fdef with call

- ZExpressionTyper wip

- ZExpressionTyper wip

- ZExpressionTyper first cut

- type equality first cut

- type equality improved

- update struct handling

- stash note

- zok_fe trivial

- error msg fix

- params in scope during stmt visiting

- stash note

- and_then rather than unwrap in flatten_import_map

- handle special names (e.g. EMBED) in toposort

- types for EMBED

- EMBED is now a valid file in stdlib

- rewriter should handle Types, too

- need to rewrite literals on LHS of def stmts

- iteration: fix type of iter var

- for now, allow indexing with both Field and u*

- add warning for indexing with Field

- impl pow

- don't add ITE when unconditionally assigning

- oops, Uint takes bv_lit not pf_lit

- simplify

- fix arg order to bv_lit, improve new_<integral> functions

- use constant folding for term::const_int

- EMBED rework wip

- EMBED rework wip

- EMBED rework wip

- EMBED rework wip

- EMBED rework wip

- prep for generic inf push

- generic inf wip

- generic inf wip

- generic inf wip

- struct generic inference

- struct array inference wip

- make const_expr_ return Result<> rather than blowing up

- finish first-cut generic inf for Array

- turn on fn generic inf

- rework struct monomorphization code

- add support for const asserts

- process declarations lexically

    previously we'd processed all consts, then structs, then fns.
    now we want to add const initialization via function call,
    which is easiest to implement if we simply process declarations
    in-order as they appear in the file and require that all uses
    follow defs lexically.

    This seems to rule out mutual recursion, so we may want to revisit.

- add const initialization via ternary

- const fn call wip

- ZGen interior mutability

    this lets us call expr, const_expr_ without mut ref.
    this seems to be the right way to go here.

- small touches after rebase

- reorganize zvisit code

- generic lookup: should go through whole stack! (and not panic if stack is empty)

- wip bugfixes

- const_identifier_ should consult generics ; generic_lookup shouldn't traverse the whole stack

- expr type inf for array accesses

- small

- const_stmt_ infra

- const_stmt_ most var infra in place

- cvar_assign handles AssigneeAccesses now

- split type_ and const_type_ using const generics

- cvar_assign: build up list of accesses before resolving them, so that we don't try to double-borrow cvars_stack

- interpreter intf

- zoki --- zok interpreter front-end

- const_expr direct access vs through term impl

- very quick zsharp readme

- feature gate ILP back-end

    this makes it easier to build CirC on M1 macs (otherwise,
    need to build coin-or from source, which is not hard but
    is annoying)

- rename zokrates to zsharp

- heavy hitting stuff here

- update z# readme

- turn off ci for zsharp branch

- small

- add cfg to switch to bn254 curve

- zsharp readme quick

- struct consts

- handle literals on LHS of const decls

- typechecker: ! can take U*, too

- refactor typechecking in InlineStructExpression handling, const_eexpr_ (this is going to move, though)

- support inline structs in ZConstLiteralRewriter

- really turn of ci this time, don't just induce a failure

- don't build circ or opa_bench examples when 'lp' option is off ; fix example builds given renamed zokrates module

- unify_inline_array: respect array dims!

- better InlineArray len handling

- check fn return type

- small, plus a few tiny test cases

- redefinition is an error

- update thinking / status on uglinesses

- explicit generic literals are U32

- remove redundant typechecking in InlineStruct const expr handling

- array and struct equality

- generic-in-generic const test

- inline array and struct generic tests

- small

- sticky notes

- stash note

- small cleanup in zstmtwalker

- support ZSHARP_STDLIB_PATH envvar in ZStdLib

- get_field_size in EMBED ; field comparisons

- test runner

- hex literal fix

- inconsistent array test

- literals test

- TODO quick update

* generic inf refactor wip

* generic inf refactor

- keep plugging away at revamped generic inference

- generic inf refactor wip

- generic inf rework wip

- stash note about divrem

- generic inf wip

- build up one term rather than a vec; walk struct members; remove old crap

- small

- generic inf rework wip

- generic inf refactor wip

- partially hook up new generic inf

- zgenericinf: invoke solver, return result

- ZGenericInf hooked up

- stash a note

- find_unique_model function

- enable incremental mode for find_unique_model

- hook up find_unique_model in zgenericinf

* go over TODOs and small cleanup

* field %

- field to bv should use full width

- need to make sure MSB is 0 when lowering to R1CS\!

* update todos

* unify const and non-const code paths

- unify function_call and const_function_call

- unify stmt and const_stmt

- type_impl_ returns Result<>

- unify expr and const_expr

* update TODO

* rework after rebase

* fix circ example and clippies

* constant folding for array select and store

* cfold: Tuple and extend Eq

* more informative generic params error message in function call

* array accesses should be Field if not otherwise typed

* support Uxx array indexing (automatic type coercion) ; check array index and value for consistency

* tuple const folding

* stash note about array construction

* todos

* more todos

* IR tuple repr: use boxed slices rather than vecs

this enforces the invariant that tuple lengths cannot be changed

closes #39

* IR tuple typing checks

the value in a given tuple slot has a fixed type.
this invariant isn't fully captured right now---it's
up to front- and back-ends to enforce this.

[ EDIT: I think the above is wrong. `ir::term::ty::rec_check_raw`
  appears to enforce this. ]

I've added a couple extra safety checks for this.

* todo update

* const fold bvconcat and booltobv

* IR array key_sort and bounds checks

* array oob todos / tests

* ZGenericInf early exit for monomorphized calls

* self.unwrap cleanup

* cache generic inference results

* small debug/assert

* array construction optimization

when constructing an array, push leaf terms directly into the array
rather than building up a huge term. This reduces memory pressure and
reduces constant folding cost in the (common) case of large const
arrays

* todos

* clippy

* bit order consistency fix / tests

to_bits and from_bits functions use msb0 ordering
(i.e., index 0 of the bool array is the MSB)

* clippy small

* update TODOs

* clippy for zsharp frontend

* cargo fmt ; pretty-printing T

* add span for error context in expr and stmt

* update TODOs

* add s_divisible and s_remainder in 'field' in stdlib

* comment on signed field fns

* superfluous front-end example

* zxi unused imports

* zxc first cut

* zxc: in count mode, dump out constraints

* sidestep stack blowup in ir::term::ty::check_raw

* add option to skip linearity reduction in zxc with -L

* debug messages... darn

* lru caching for cfold

* unbounded/bounded cache

unbounded during a single fold_cache call, bounded between

* rebase fixes

feature gate aby back-end with lp
changes in zxi/zxc, and some clippies

* don't check-in non-top-level Cargo.lock

* increase LRU cache size for cfold to avoid n^2 behavior

* heuristic term/type cache collector

* tidy

* fmt

* small bugfix

* small fixes ; move zx_tests

* re-enable ci

* fmt

* tentative obliv-fix

* more obliv-fix

* clippy (for tests)

* Polish the obliv fix a bit. Document

* Addressing my unsolicited comment

* fix build

* typo

* stash Alex's idea about modeling RAM transformations

* back to upstream hashconsing

Co-authored-by: Alex Ozdemir <aozdemir@hmc.edu>

Co-authored-by: Riad S. Wahby <rsw@jfet.org>
Co-authored-by: Alex Ozdemir <aozdemir@hmc.edu>
2022-02-06 22:47:30 -05:00
Edward Chen
450aa8df93 cleaning merge 2022-01-27 03:41:42 -05:00
Edward Chen
60a5c2d866 merged main to graphing 2022-01-26 13:14:32 -05:00
Edward Chen
32c5fd18db graphing v1 2022-01-25 14:14:05 -05:00
Edward Chen
75572c6a2c C Frontend (#22) 2022-01-20 10:16:27 -08:00
Edward Chen
616aea7475 local assignments 2022-01-19 21:52:06 -05:00
Edward Chen
996ee74c76 partitioned ir 2022-01-19 17:06:24 -05:00
Edward Chen
c8070bbd09 updating graph partitioning scheme 2022-01-13 01:41:33 -05:00
Alex Ozdemir
cba4bdc925 Cache submodule build (#38) 2022-01-09 08:49:07 -08:00
Alex Ozdemir
f2744e0c06 IR-based Zokrates front-end (#33)
The ZoKrates front-end now represents ZoK arrays as IR arrays, and ZoK structures as (type-tagged) IR tuples.

During this change, I discovered that IR support for eliminating tuples and arrays was not complete.

Thus the change list is:

    The ZoK front-end uses IR arrays and tuples
    Improve IR passes for array and tuple elimination
    Enforce cargo fmt in CI
    Bugfix: handle ZoK accessors in L-values in the correct order
    Bugfix: add array evaluation to the IR

This PR does not:

    implement an array flattening pass
    implement permutation-based memory-checking

Benefits:

    The ZoK->R1CS compiler is now ~5.88x faster (as defined by the time it takes to run the tests in master's scripts/zokrates_test.zsh script: this goes from 8.59s to 1.46s)
        For benchmarks with multi-dimensional arrays, the ZoK->R1CS compiler can now compile them with reasonable speed. Before it it would time out on even tiny examples.
    The ZoK->R1CS compiler will be able to benefit from future memory-checking improvements
    IR support for arrays and tuples is complete now, making those parts of the IR more accessible to future front-ends.

alex-ozdemir added 21 commits 11 days ago
2022-01-01 11:44:56 -08:00
Edward Chen
3c7227e2c9 working commit 2021-12-17 03:15:44 -05:00
Edward Chen
2a11ecf8ed added graphing support for converting IR to Chaco format 2021-12-17 02:58:22 -05:00
Alex Ozdemir
8914c007cd Public inputs for proofs. (#27) 2021-12-10 13:09:05 -08:00
Edward Chen
57166c7cc9 updated cost models for hycc 2021-12-09 17:45:01 -05:00
Edward Chen
adac3c114f added proof to c frontend 2021-12-07 03:33:03 -05:00
Edward Chen
30ccc35bec updating c frontend to include proof mode 2021-12-07 03:18:30 -05:00
Edward Chen
4d51c27ff4 remove pycache files 2021-12-07 02:05:47 -05:00
Alex Ozdemir
b25b18ea8f Merge remote-tracking branch 'origin/c_frontend' into c_frontend 2021-12-06 21:05:56 -08:00
Edward Chen
fdd29e89e3 biomatching test works 2021-12-03 01:04:36 +00:00
Alex Ozdemir
a702a55e93 very basic C zkp 2021-12-02 15:48:16 -08:00
Edward Chen
8268841128 demo 2021-12-01 08:16:35 +00:00
Alex Ozdemir
be8fd6a536 Merge branch 'master' into c_frontend 2021-11-30 17:00:29 -08:00
Alex Ozdemir
4ffa05fca6 Datalog (#26)
Support a datalog variant.
2021-11-30 13:26:25 -08:00
Ubuntu
201f41d941 working kmeans test 2021-11-30 04:17:53 +00:00
Alex Ozdemir
8a05a107ed Deterministic compilation & better CLI (#25)
This PR makes compilation deterministic (by switching to fxhash) and improves the CLI.

Technically, the std-based hash tables cannot be guaranteed to have the deterministic iteration order that we need, regardless of what hash you use, so I've added some micro-tests for the property that we need. I'm not optimistic about getting better guarantees from std, but I'll try.

The CLI has also changed.
2021-11-29 15:17:32 -08:00
Ubuntu
51e5bfdf28 updated ilp solver 2021-11-25 08:34:09 +00:00
Edward Chen
cdb6e4c3e0 working kmeans test! 2021-11-18 03:16:18 -05:00
Edward Chen
9416f6af77 update 2021-11-17 18:01:33 -05:00
Edward Chen
6fcbaddee7 oom on gcc compiler now? 2021-11-17 17:35:19 -05:00
Edward Chen
f6cb183c8c time to change lowering memory efficiency 2021-11-17 13:32:26 -05:00
Edward Chen
ec8bf83558 does kmeans work? 2021-11-15 20:50:14 -05:00
Edward Chen
082dd79617 almost there 2021-11-14 02:53:13 -05:00
Edward Chen
4d903b77c7 kmeans test works! 2021-11-12 02:39:32 -05:00
Edward Chen
ccc939b3c0 almost fixed kmeans 2021-11-12 01:14:01 -05:00
Edward Chen
fe9f66b69c kmeans test 2021-11-12 00:24:44 -05:00
Edward Chen
9eeeea15f9 fixing array size const folding 2021-11-11 22:19:07 -05:00
Edward Chen
62f0e53381 adding in folding calls 2021-11-11 21:29:51 -05:00