Commit Graph

18 Commits

Author SHA1 Message Date
Sam Tay
5b3ee93b3b Fixup api docs a bit (#300)
* Fixup api docs a bit

* FieldSpec should live in types::zkp along with Field
2023-08-17 13:48:00 -04:00
rickwebiii
641bf96bd4 Rweber/deps (#295)
Move all deps to [workspace.dependencies]
2023-08-04 17:23:06 -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
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
c6c2607983 Fix clippy 1.70 (#249)
And duplicate warnings for good measure
2023-06-06 18:07:43 -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
rickwebiii
6837de9290 Randomness range proof now correct (#210) 2023-02-01 15:28:03 -08:00
rickwebiii
a8be112cb8 Randomness range proof in R1CS now correct (#208)
* Randomness range proof now correct
2023-01-25 11:06:13 -08:00
rickwebiii
61032735f8 Rweber/zkp (#205)
Can create pure R1CS BFV proof.
2023-01-20 13:38:04 -08:00
rickwebiii
c01f0c59e3 Improve assert binary gadget (#200)
* Improve assert binary gadget

* cargo fmt

* clippy

* clippy
2023-01-15 13:45:10 -08:00
rickwebiii
d03207e67e Rweber/zkp (#196)
Add BFV playground, Polynomial addition
2022-12-19 12:00:23 -08:00
Sam Tay
e2e5da3f60 Manually fix the rest of the clippy warnings 2022-10-31 15:30:34 -07:00
Sam Tay
4b53103953 Auto fix clippy warnings 2022-10-31 15:30:34 -07:00
rickwebiii
3019c78496 Rweber/model (#170)
* WIP

* Fix prediction measurements
2022-08-12 15:52:36 -07:00
rickwebiii
507c70f1c3 Rweber/model (#167)
* Add invariant noise

* WIP

* Update Results

* cargo fmt

* cargo fmt

Co-authored-by: EC2 Default User <ec2-user@ip-172-31-36-95.us-west-2.compute.internal>
2022-08-09 13:13:45 -07:00
rickwebiii
51b942a849 Reduce test cases, eliminate multiple sampling where stddev is 0 (#164) 2022-08-05 10:42:31 -07:00
rickwebiii
2e70480e63 Add benchmark (#163) 2022-08-04 11:48:02 -07:00