Commit Graph

636 Commits

Author SHA1 Message Date
Sam Tay
dc23dcd673 Remove type annotations 2023-08-04 16:17:50 -04:00
Ryan Orendorff
c66469ec0c Address clippy complicated return value 2023-08-04 12:57:38 -06:00
Ryan Orendorff
e46e3182b4 Expose SEAL BFV components, full BFV proofs 2023-08-04 11:40:33 -06:00
Sam Tay
8fe63d6e88 Fix benchmark (#289) 2023-08-01 16:24:25 -04:00
Ryan Orendorff
fc892c1727 Clippy fixes (#286) 2023-07-24 15:30:02 -06:00
Sam Tay
b8521c70e4 Fix doc comment (#284) 2023-07-18 20:26:19 -04: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
Sam Tay
951ea237ee Playground bump (#281)
* Bump playground

* Re-bump playground

To up node version

* Bump playground again

* Ensure playground loads with zkp backends
2023-07-17 22:23:32 -04:00
rickwebiii
3c50ee477b Rweber/field spec (#283)
Rename NativeField<BackendField> to Field<FieldSpec>
2023-07-17 18:18:50 -07:00
rickwebiii
f05ce704b1 transparent-ciphertexts feature (#280) 2023-07-11 12:16:42 -07:00
Sam Tay
363734ff38 Properly factor inserting literal plaintexts (#278)
Throughout the const arthimetic operations. Not sure why I didnt do this in the initial PR
2023-07-10 13:39:14 -05:00
Ryan Orendorff
8dfaf33452 Switch SEAL submodule to sunscreen org (#277) 2023-07-10 10:57:56 -06:00
Ryan Orendorff
95721487a8 Mixed bounds in logproof (#276)
This enables some small performance increase for smaller proofs (up to approximately 75%). Additionally this enables the prover and verifier to agree on which components may or may not be interesting by specifying a
bounds of zero.
2023-07-07 12:37:12 -06:00
Ryan Orendorff
300c5eb019 Fix assert_poly_expansion for k > 1 (#275)
* Fix assert_poly_expansion for k > 1

The polynomial expansion was using a flattened tensor product when a normal kronecker product should have been used. This fixes that error.

As a consequence, it is now also possible to create a matrix from a
vector of vectors. This was implemented to make it easier to create the test cases for k > 1.
2023-07-07 11:52:32 -06:00
Ryan Orendorff
a91c7291fb Add CSV stdout for logproof bench (#274) 2023-07-06 10:36:27 -06:00
Sam Tay
5faf981178 Hackathon; or, various compiler improvements (#272)
* Misc doc fixes

* Fix sunscreen zkp exports

* Fix broken api doc reference

* Add starter zkp example

* Use ZkpRuntime::new in sudoku example

* Use ? over unwrap in zkp examples

* Refactor pattern matching

No functionality changes

* Disallow `mut` args in fhe/zkp programs

* Play around with allowing cipher|plain values

* Allow user-declared plain|cipher values

NOTE: Not fully implemented. Will not work on Rational types until we
factor out literal->plaintext into a proper trait.

This allows, e.g.

```rust
fn simple_sum(a: Cipher<Signed>, b: Cipher<Signed>) -> Cipher<Signed> {
    let mut sum = fhe_var(0);
    sum = sum + a;
    sum = sum + b;
    fhe_out(sum)
}
````

* Refactor array::output()

* More targeted compiler error messages on invalid return values

* Add option for var.into() rather than fhe_out(var)

* Fix incorrect macro invocation

* Add trait for inserting const as plaintext

* Impl all arithmetic operations for indeterminate nodes

* Offer an `fhe_var!` macro

* Offer a zkp_var! macro

* Offer a (safe) debug impl for zkp program nodes

* Fix tests

* Add test for fhe_var!

* Simplify tf out of sudoku

* Simplify fhe input() codegen

* Marginally better compiler error messages on invalid fhe program arg types

* Fix error for fhe program argument attributes

* Throw appropriate compiler error on generics

* Silence clippy warnings in generated code

These I think are typically ignored by default when consuming proc macros but might as well be explicit

* Fixup quote_spanned invocations

Unsure how important this is, but see here: https://docs.rs/quote/latest/quote/macro.quote_spanned.html#syntax

* Automatically call `.into()` on fhe prog return values

* Factor fhe_program_impl

* Further factor fhe_program_impl

So that token generation happens in helper methods, and the ultimate output() func is readable

* Fix doctests

* Fix clippy warnings

* Remove TODOs

* Add missing example runs to CI

* Oops: fix 232 > 64

* Allow arbitrary expressions in fhe_var!

* Use custom "into" to support impls on []

* Support explicit #[private] params

* Remove `backend = "bulletproofs"` attribute

* Address PR reveiw
2023-07-05 17:07:21 -05: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
Ryan Orendorff
8d9af63de0 Fix bounds (b, b_1, b_2) on logproof (#262)
The prior bounds for the short discrete log proof were not quite
accurate for some inputs. Specifically, the following changes were made
to match the paper:

- b: log2(B) + 1 -> ⌈log2(B)⌉ + 1
- b₁: log2(mdB + d||f||_inf) -> ⌈log2(mdB + d||f||_inf)⌉
- b₂ log2(q) + 1 -> ⌈log2(q)⌉

Specifically, b₂ was correct unless q was a power of 2, which
essentially never happens in practice.
2023-06-27 10:35:08 -07:00
Ryan Orendorff
c7052bbfda Build to_2s_complement by individual elements. (#264)
This change is a no-op on the result; it is a precursor to having
bounds that can vary on each element in the input array.
2023-06-26 19:42:51 -07:00
mliu24
4fbac668d0 Update rust.yml (#266)
added test coverage to debugger branch for matthew and bryan
2023-06-26 17:06:25 -07:00
Sam Tay
08cdfa7e94 Fix more docs (#258)
* Fix a couple broken doc links

* Fix broken batching links
2023-06-19 22:47:03 -07:00
Sam Tay
dfae36a3cb Up generator length to nearest power of 2 (#255) 2023-06-19 22:46:45 -07:00
Bryan Li
82d83cf238 Added Sudoku ZKP Example (#253)
* added sudoku zkp example

* edited main

* fixed style

* refactored code

* fixed formatting

* fixed lint
2023-06-13 10:36:38 -07:00
mliu24
5b848e1901 fixed a typo (#256) 2023-06-12 20:37:35 -07:00
Sam Tay
c2ad1138c2 Fix broken doc links (#252)
* Fix broken doc links

* Fail CI on api doc warnings

* Fix broken api docs
2023-06-12 12:46:08 -07:00
rickwebiii
c8fb1f8cb6 Rweber/msm (#254)
MSM works in OpenCL
2023-06-11 00:27:40 -07:00
rickwebiii
163deff07d Rweber/opencl (#251)
Prefix sum for RistrettoPoints
2023-06-06 23:04:24 -07:00
Sam Tay
aadde9d162 Offer a simpler API for runtime creation (#246)
* Offer a simpler API for runtime creation

* Update docs and examples to use `FheRuntime::new`
2023-06-06 18:56:46 -07:00
Sam Tay
c6c2607983 Fix clippy 1.70 (#249)
And duplicate warnings for good measure
2023-06-06 18:07:43 -07:00
rickwebiii
fc0830a834 Rweber/opencl (#250)
Compute buckets
2023-06-02 17:27:19 -07:00
rickwebiii
9ee1807c75 Rweber/opencl (#248)
Compute bucket indices for MSM
2023-06-01 20:52:18 -07:00
Sam Tay
66211f75b1 Fix 64-bit pointer assumptions (#243)
* Fix 64-bit pointer assumptions

* Appease clippy

* Bump proc-macro2

(Fixes wasm build)
2023-05-30 11:59:20 -07:00
Sam Tay
4a8f3a8fb1 Use https in submodule remotes (#244)
This makes specifying our git repo as a cargo dependency much less painful
2023-05-25 13:58:31 -07:00
rickwebiii
26bd6dab37 Allow cross compilation on mac (#245)
Allow cross compilation on mac
2023-05-25 12:29:42 -07:00
rickwebiii
09ecc0a57d Update syn and a bunch of packages (#242) 2023-05-24 15:28:52 -07:00
rickwebiii
c5fda111cc Rweber/opencl (#241)
OpenCL RLE implementation
2023-05-23 17:10:48 -07:00
rickwebiii
bf7154e49b Rweber/opencl (#240)
OpenCL Pippenger's algorithm WIP
2023-05-22 11:55:33 -07:00
rickwebiii
1089e00d1b Separate OpenCL shaders into multiple files (#239)
* Separate OpenCL shaders into multiple files
2023-05-12 17:06:53 -07:00
rickwebiii
7ded5a8e52 impl IntoIterator for opencl ScalarVec (#238)
impl IntoIterator for opencl ScalarVec
2023-05-09 18:11:00 -07:00
Sam Tay
60b345cc5e Make gadgets sync (#237)
* Make gadgets send/sync

This lets Application types be send/sync

* Bump curve25519 to appease clippy

* Speed up unsigned tests a tiny bit
2023-05-01 17:45:25 -07:00
Sam Tay
ace6d97140 Add a bfv::Unsigned type (#236)
* Add a bfv::Unsigned type

* Fix decoding from polynomial?

* Add prop test for addition

* Proptest sub, mul, and mixed cipher/plaintexts

* Reduce code dupe

* Add test for 0 - 1

* Add a few more tests
2023-04-24 11:57:33 -07:00
rickwebiii
ee5d6d9cdc Rweber/cuda (#235)
CUDA implementation
2023-04-10 19:54:24 +01:00
rickwebiii
1ba1419691 Rweber/perf (#234)
Use Bulletproofs optimization section 3.1
2023-04-02 15:55:30 +01:00
rickwebiii
9785670ae0 Cargo update (#233) 2023-03-30 12:59:01 -07:00
rickwebiii
5c0b2f5539 Parallelize RistrettoVec encoding (#231)
* Parallelize RistrettoVec encoding
2023-03-30 08:47:38 -07:00
Sam Tay
9346677d5d Expose ZkpContextOps 2023-03-29 10:08:52 -07:00
Sam Tay
680d475d7d Glob all examples as workspace members 2023-03-29 10:08:52 -07:00
rickwebiii
06e9c1cb2b Rweber/opencl (#230)
OpenCL implementation of curve25519 operations
2023-03-22 14:30:45 -07:00
rickwebiii
8b43c6db24 chi sq and unshield proofs (#225)
chi sq and unshield proofs
2023-03-09 13:46:09 -08:00
rickwebiii
af4849ddb5 Time shield circuits (#224)
* Time shield/unshield circuits
2023-03-08 19:19:59 -08:00