74 Commits

Author SHA1 Message Date
Bryan Li
2dbd5e3ffa fixed style and linting 2023-08-11 13:21:59 -07:00
Bryan Li
4b56a178ab merged 2023-08-11 13:15:11 -07:00
Bryan Li
f5b62b4192 merge 1/2 2023-08-11 12:26:55 -07:00
rickwebiii
641bf96bd4 Rweber/deps (#295)
Move all deps to [workspace.dependencies]
2023-08-04 17:23:06 -07:00
mliu24
116226d244 implementation of contextenum (#290)
* clippy

* clippy

* fmt

* clippy

* fmt

* janky a solution to conditional compilation keeping variables out of scope

* fmt

* conditioanl compilation for debugdata

* remove print debug from measured model

* remove unnecssary comment

* remove todo

* removed serialize function for stackframeinfo, instead hashed it

* remove unnecessary conditional compilation in common subexpression eliminioatno

* change fhe program macro to preserve white space

* changed get_mult_depth to iterative bfs

* add functions to modularize overflow calculation

* overflow code now compiles but needs to actually be implemented

* can extract coefficients from innerplaintext

* implemented overflow detection for fhe programs

* modified checks for overflow

* remove internal tagging comments

* clippy

* removed unwrap or else and turned into expect

* clippy actually likes unwrap or else

* fmt

* gate some imports

* fix gating issues

* removed some gating

* removed gating from debugger module; zkp runtime uses it

* fmt

* removed some unnecessary comments from context

* debug program impl function

* contextenum for fhe and zkp ctx

* basic body for debug prgoram macro

* unwrap methods for context enum

* refactored some code to unwrap contextenum as an fhecontext

* compile errors on debug program

* removed is_multiplication from operatoin trait

* documentation for contextenum

* refactor code to not have current zkp or fhe ctx, instead generic enum

* changed uses of current fhe and zkp contexts to generic enum

* stashing changes

* add a clone call in fhe program macro so code compiles. this does not work

* fix mutability issue in fhe program macro

* fix mutability issue in zkp program macro

* modify methods for unwrapping contextenum

* fmt

* half of clippy fixes

* clippy

* fmt

* fixed mutability issue in create inputs test

* fmt
2023-08-02 15:27:39 -07:00
Bryan Li
2377d3287f addressed some code review changes 2023-07-31 10:27:59 -07:00
Bryan Li
c8a036ba89 cargo fmt 2023-07-30 23:55:29 -07:00
Bryan Li
ca3c6aec35 replaced cfg! call with attribute 2023-07-30 23:52:33 -07:00
Bryan Li
3d0b11ad76 fixed linting ahhh 2023-07-30 22:09:49 -07:00
Bryan Li
8c9c47b9f2 fixed formatting again 2023-07-30 22:03:39 -07:00
Bryan Li
f4128ecb5e fixed style and linting 2023-07-30 22:01:14 -07:00
Bryan Li
6f829a703c some ui fixes 2023-07-30 21:59:08 -07:00
Bryan Li
4019e47cd9 merged debugger into bryan/add-frontend 2023-07-30 21:29:16 -07:00
mliu24
f66aa69b62 basically the whole debugger project (#269)
* added support for group id's in nodeinfo struct and modified new/add_node methods

* addedd support for group counter to fheprograms

* added support for group ids for zkp backend

* aded support for group id's in fhe and zkp programs

* finished support for group id in zkp programs

* added new function signature for creating new nodeinfo with debugger featuer on

* updated zkp jit compilation to support constructing nodes with group id

* added support for node group ids in fhe compiler

* format changes

* fixed clippy issues

* added a stacktrie struct

* added a function to add a stack trace. need to figure outhow to get group id's into the stacktrie

* Update rust.yml

* style fixes

* added structure for StackFrameLookup and stackframes trait

* support to add stack traces and updated dependencies

* clippy fixes

* clippy fixes

* created stackframeinfo struct, added get_stack_trace which has lifetime issues

* clippy fixes

* implementation for stackframelookup

* insertion and getting work

* formatting and documentation

* updated stackframeinfo constructor to not panic with no values

* changed it so trie stores stackframeinfo instead of backtraces

* format and clippy fixes

* started some work with fheprograms

* single frame insert test

* single backtrace insert

* single backtrace insert

* fixed minor loggic error in test single backtrace insert

* some more tests

* programcontext/programgroup structs defined

* more programgroup

* added a get for stackframelookup, added clone to programgroup

* infrastructure for groups

* fixed references of .0 into .graph and enabled conditional compilation of debugging structs, but this broke fhe_program proc macro

* cleaned up some conditional compilation logic in context, also formatting fixes

* fixed context compilation errors

* fixed dependency issues and can now return graph information of basic fhe program

* format fixes

* remains to figure out how to display graphs with rationals

* can display graph for given rational operations

* displays serialized graph strings

* added run_impl and debug_fhe_program, also added debuginfo struct and added parameter for secret key in run unchecked

* fixed compilation errors for tests in run file, now does tests with secret key

* updated measuredmodel call to run_program_unchecked with a secret key

* clippy and format fixes

* doc fixes

* fixed some fhe program tests based on changes to compilationresult data structure

* format fixes

* modified tests in validation.rs

* sessions file + data structure:

* documentation for sessions

* documentation, removed some unused dependencies

* format and clippy fix

* moved sessions to runtime

* rick's coimments/changes

* implemented set_data, also added calls to set_data in run unchecked

* fixed compilation rrors in tests for run.rs

* more compilation error fixes + moved fhe-debugger into debugger module

* added fhe-debugger files as modules

* fxied remaining compilation issues in run

* removed nodes file from debugger

* created start web server function

* fixed some depenendcy issues to enable debugger feature across workspace, now going to fix compilation results/add support with debugger feature

* enabled debugger in zkp backend

* compilation errors in graph construction test, enabled debugger feature in sunscreen_fhe_program

* fixed more compilation errors and enabled debugger feature in sunscreen_backend. next step: figure out secret vs privatekey and change debug_fhe_program accordingly

* modified visibility of sealsecretkey in privatekey struct to be public

* format

* modified debug_fhe_program to not return anything

* fixed compilation errors based on conditional dependencies when debugger not enabled

* fixed errors due to conditional compilation with debugger feature in fhe_program_tests

* managed to get webserver up and running. remains to figure out how to get the graph data

* can now support dynamic paths but currently web server is not set up in a way that you can debug multiple programs

* moved code from sessions.rs to server.rs

* server file

* added support for cors so frontend can now grab data from backend. currently it only grabs a string that allows the frontend to construct a graph

* proc macro updates to be able to get source code of an fhe program with .source()

* added support for fhe program source code. in debug mode, run.rs tests wont compile because debug_fhe_program now asks for 7 arguments instead of 6

* fmt fixes

* clippy fixes

* get fhe node data impleented, still doesnt ocmpile. need to figure out how to handle sealdata stuff

* fixed async issues, now can support multiple sessions

* rick fixes

* updated fhe_program_tests to have metadata fields and group_id. need to fix construction of graph so that group ids are updated

* fhe program tests now pass with debugger feature enabled, updated group counter when assigning ids to nodes

* passes tests with debugger feature enabled and disabled

* fmt fixes

* clippy fixes

* addressed race conditions in run tests, now pass those tests with and without debugger feature

* removed changes to settings.json

* removed unncessary comments from fhe_program_tests

* removed some unnecessary TODO

* removed more unnecessary comments

* removed group struct, defined Group type as a String

* modifying interface for lookup data structures

* removed unnecessary prints

* remove more prints

* removed secretkey from debug_fhe_program, now uses privatekey instead

* removed conditional compilation from a functoin that shouldnt have it

* removed group counter updates from common_subexpression_elimination test. graphs can be isomorphic even if group id's don't match up exactly

* clippy and fmt

* undid some clippy changes so that code compiles

* error handling for get_fhe_node_data and implemented idlookup trait for stackframelookup

* stack id for nodeinfo

* stack id for node info and context changes

* removed serialization of sealdata, instead created serializedsealdata struct which contains debugger info about cipher/plaintexts

* removed unnecessary todos

* skeleton for getting cipher/plaintext data

* modified visibility of Error field in lookup, cloned some values in server

* sunscreen fhe znd zkp support for stack ids on ndoes

* fmt

* clippy

* can now see dummy node data

* removed some old/dead code from server and added backtrace to compiler crate

* dependency updates

* put multiplicative depth on nodeinfo, also updated operationtrait

* enabled internal tagging with conditional compilation with debugger feature

* compile fixes, added multiplicative_depth field to nodeinfos

* attempted to allow for multiplicative depth ... this currently does not work. also group ids dont seem to be assigned correctly

* two changes: modified Operation enum to be struct instead of tuple variants and fixed associated compilation errors, also removed multiplicaitve depth field from NOdeInfo and fixed corresponding compilation errors

* more compilation errors for struct variants of Operatio nenum fixed

* moved group and stack counters off context and onto metadata ... maybe should move this onto the lookup structs themselves?

* skeleton for idlookup trait for grouplookup

* moved lookup to compiler ocmmon from runtime

* moved lookup into src

* documentation for lookup

* attempting naive multiplicative depth algorithm

* removed get_mult_depth that didn't function, currently returns 0

* can display coefficients for plaintexts

* moved build to sunscreen_runtime directory from debugger

* WIP

* rick's changes

* fixed webpack errors

* progress towards coefficients

* Don't ship dist folder

* WIP

* fmt changes. also can display coefficients of plaintexts

* attempting to debug ciphertext coefficient info

* removed groups.rs file

* conditional compilation for dependency import to stop clippy complaints

* more clippy fixes

* more conditional compilation for dependncies

* fmt

* implemented default trait for lookup structures

* combine 2 dependency imports

* just allowed for unused imports

* updated serialization types

* changed serializable enums to be internally tagged

* capturing stack traces

* format

* added sleep calls in infinite loop to reduce cpu usage

* remove default cals from chi_sq example

* format

* allow for insertion of ids/keys in lookup structure

* added a 2nd call to mad for debugging example. also inserted some dummy keys for stack lookup

* attempts to debug decryption of coefficients with seal:

* removed dbg from seal file

* added a stacktrace endpoint, but it doesnt display anything useful yet

* fmt

* can now display coefficients

* clippy fix

* fmt

* noise budget is nullable

* named cipher and plaintexts

* removed some unnecesasry comments

* error handling for run program unchecked

* remove internal tagging so that literals work

* format

* unnecessary comments removed

* get_mult_depth works in some cases, need to write tests

* singular empty etst

* attempt to redesign stack frame lookup -- this is a very inefficeint way of doing it, but should work

* added support to capture stack traces, but there's an issue with the data not being saved so it can be served to the frontend

* fmt

* clippy

* default implementation for gorup and stacklookup

* fmt

* can now display stack traces

* fmt

* clippy

* fmt

* refactoring code to change serializedsealdata to bfvnodetype

* comment out dead code

* start zkp sessions

* moved decrypt seal logic to a new function

* wrote polynomial multiplication functions

* zkpsession and imports

* overflow for polynomials

* overflow can now only be true for ciphertexts that are the output of an arithmetic operation

* examples for overflow and chaining

* remove some unnecssary imports

* server now supports serializing zkp data

* zkp now returns bigint as a string

* set up params that cause noise budget exceeded in debugger example

* remove tests from lookup

* added name metadata to zkp programs

* updated construction of expected graphs for fhe_program_tests

* modified tests for validation to account for struct variants

* added session provider

* SessionProvider

* added gorup and stack id for some validation tests

* Fix a test

* Fix tests

* Fix feature plumbing

* Fix lookup

* fuck off

* changed generic to Box of dyn

* functional zkp debugger

* clippy

* clippy

* fmt

* clippy

* fmt

* janky a solution to conditional compilation keeping variables out of scope

* fmt

* conditioanl compilation for debugdata

* remove print debug from measured model

* remove unnecssary comment

* remove todo

* removed serialize function for stackframeinfo, instead hashed it

* remove unnecessary conditional compilation in common subexpression eliminioatno

* change fhe program macro to preserve white space

* changed get_mult_depth to iterative bfs

* add functions to modularize overflow calculation

* overflow code now compiles but needs to actually be implemented

* can extract coefficients from innerplaintext

* implemented overflow detection for fhe programs

* modified checks for overflow

* remove internal tagging comments

* clippy

* removed unwrap or else and turned into expect

* clippy actually likes unwrap or else

* fmt

* gate some imports

* fix gating issues

* removed some gating

* removed gating from debugger module; zkp runtime uses it

* fmt

---------

Co-authored-by: Bryan Li <bryanyuezhouli@gmail.com>
Co-authored-by: rickwebiii <rick.weber.iii@gmail.com>
Co-authored-by: Bryan Li <51716784+bryanyli@users.noreply.github.com>
2023-07-30 18:14:22 -07:00
Bryan Li
817e998aee stacktrace part 1 2023-07-30 16:18:46 -07:00
Bryan Li
6caef04edc added program source data to debug zkp programs 2023-07-29 17:01:55 -07:00
Bryan Li
3d6d4e84eb added basic zkp frontend functionality 2023-07-28 15:46:11 -07:00
Bryan Li
b4a2717e38 Merge branch 'mliu-backend' into bryan/zkp-backend 2023-07-28 11:02:54 -07:00
Bryan Li
51d5cede04 functional zkp debugger 2023-07-28 10:49:51 -07:00
Bryan Li
3ee8fd677a changed generic to Box of dyn 2023-07-27 19:33:55 -07:00
rickwebiii
65df198271 Fix feature plumbing 2023-07-27 15:46:27 -07:00
rickwebiii
30f293d752 SessionProvider 2023-07-27 14:28:18 -07:00
Bryan Li
70c1a08930 added session provider 2023-07-27 13:14:44 -07:00
Bryan Li
1651eec0a5 added name metadata to zkp programs 2023-07-27 11:55:58 -07:00
Matthew Liu
b29784afcd remove internal tagging so that literals work 2023-07-25 16:03:03 -07:00
Matthew Liu
9293f05e70 format 2023-07-24 11:26:42 -07:00
Matthew Liu
c571744480 changed serializable enums to be internally tagged 2023-07-24 10:27:30 -07:00
Matthew Liu
eaddb9d6b9 updated serialization types 2023-07-24 09:25:30 -07:00
Matthew Liu
a193ab4aaf fmt changes. also can display coefficients of plaintexts 2023-07-21 15:09:29 -07:00
Matthew Liu
2309793881 two changes: modified Operation enum to be struct instead of tuple variants and fixed associated compilation errors, also removed multiplicaitve depth field from NOdeInfo and fixed corresponding compilation errors 2023-07-20 13:35:42 -07:00
Matthew Liu
2aff8d0f1f compile fixes, added multiplicative_depth field to nodeinfos 2023-07-20 12:30:10 -07:00
Matthew Liu
f435ca9eb2 enabled internal tagging with conditional compilation with debugger feature 2023-07-20 01:32:07 -07:00
Matthew Liu
c950a0a5e6 put multiplicative depth on nodeinfo, also updated operationtrait 2023-07-20 01:27:12 -07:00
Matthew Liu
904361ff84 fmt 2023-07-19 15:39:16 -07:00
Matthew Liu
38224850a7 stack id for node info and context changes 2023-07-19 13:20:47 -07:00
Sam Tay
badb8f9c8f ZKP tweaks (#279)
* Export type alias for bulletproof backend fields

Also, keep bulletproof stuff namespaced to a `bulletproofs` module.

* Change sudoku to use pub over const

* Docs updates

* Rename / clean up sudoku

* Export `Proof` type

Basically required for being able to deserialize a proof

* Add zkp/serde workspace example

* Drive by cleaning

* Exports necessary for gadget impls

* Rename compute_inputs to compute_hidden_inputs

* Add prove/verify builders

* Export the builder types

This isnt strictly necessary but it would be weird for these to not show up in the cargo docs

* Clippy fix

* Add helper .compile() & .runtime() methods to fhe prog fns

I do wonder if these should be defined in a separate trait, just so that they don't live next to the more internal functions in documentation.

* Use new swag to simplify the front-facing api docs example

* Add some whitespace

* Switch to an extension trait

* Add an extension to ZkpProgramFn

* Take an owned ZkpBackend, rather than reference

Its typical to have the caller handle cloning, rather than taking a reference, requiring Clone impl, and forcing clone. Plus, as of now the only backend is a zero size null struct, so nothing to be gained by using a reference. It also just looks weird to always pass `&BulletproofsBackend::new()`

* Update sudoku to use new swag

* Target second attribute in multi attribute error

* Enforce ordering zkp inputs: constants,public,private

Honestly this feels a little unnatural to me. Might want to reverse: private, public, constant and then change all the prove/verify methods to that ordering

* Build whitelist example in CI

* Reorder constant->public->private to private->public->constant

* Fix trailing ws

* Fix example

* Make .runtime() more consistent with .compile()

* Get rid of some boilerplate impls

* Add custom zkp type example

* Move example run checks into example tests

Should speed up CI a bit

* Change whitelist -> allowlist
2023-07-18 15:15:51 -04:00
rickwebiii
3c50ee477b Rweber/field spec (#283)
Rename NativeField<BackendField> to Field<FieldSpec>
2023-07-17 18:18:50 -07:00
Matthew Liu
6cf313ada2 managed to get webserver up and running. remains to figure out how to get the graph data 2023-07-17 02:50:21 -07:00
Matthew Liu
5f66f73602 fixed compilation errors based on conditional dependencies when debugger not enabled 2023-07-17 00:46:05 -07:00
Matthew Liu
145295584b format 2023-07-16 23:06:17 -07:00
Matthew Liu
cb46c4b85b fixed more compilation errors and enabled debugger feature in sunscreen_backend. next step: figure out secret vs privatekey and change debug_fhe_program accordingly 2023-07-16 02:05:27 -07:00
Matthew Liu
21683f2e23 enabled debugger in zkp backend 2023-07-14 16:33:46 -07:00
Matthew Liu
8f6a1d7b98 cleaned up some conditional compilation logic in context, also formatting fixes 2023-07-10 11:28:56 -07:00
Matthew Liu
243d748cdf fixed references of .0 into .graph and enabled conditional compilation of debugging structs, but this broke fhe_program proc macro 2023-07-10 11:03:09 -07:00
Sam Tay
036b782a69 Misc typos / Fix lib exports (#265)
* Misc doc fixes

* Fix sunscreen zkp exports

* Fix broken api doc reference
2023-06-27 19:43:20 -06:00
mliu24
ad64e0f070 Mliu backend (#267)
* commented out some code from main, bulid in debugger file to fix compile errors. also added optional field group_id for context

* added support for unique group ids

* added debug flag to sunscreen_fhe_program, need to check every instance of Context

* updated features and renamed feature to debugger

* removed atomic from context, renamed group_id to group_counter

* changed node id's to u64s instead of hashes

* modified expressiontreenode to be fheexpressiontreenode. will implement zkpexpressiontreenode later

* added support for group id's in nodeinfo struct and modified new/add_node methods

* addedd support for group counter to fheprograms

* added support for group ids for zkp backend

* aded support for group id's in fhe and zkp programs

* finished support for group id in zkp programs

* added new function signature for creating new nodeinfo with debugger featuer on

* updated zkp jit compilation to support constructing nodes with group id

* added support for node group ids in fhe compiler

* format changes
2023-06-27 17:15:59 -07:00
Matthew Liu
500a50d144 updated zkp jit compilation to support constructing nodes with group id 2023-06-27 16:59:22 -07:00
Matthew Liu
70b5d21d7c finished support for group id in zkp programs 2023-06-27 14:27:04 -07:00
Matthew Liu
e9816606b0 aded support for group id's in fhe and zkp programs 2023-06-27 14:17:13 -07:00
Matthew Liu
256237c73a added support for group ids for zkp backend 2023-06-27 13:04:16 -07:00