84 Commits

Author SHA1 Message Date
Sam Tay
9b4de3ca09 Fix missing version in dependencies (#306)
* Fix missing version in dependencies

* Fix crates.io metadata
2023-08-22 22:27:47 -04:00
Sam Tay
cbbe0bafbe Bump all versions to 0.8.0 (#305) 2023-08-22 19:40:54 -04:00
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
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
rickwebiii
09ecc0a57d Update syn and a bunch of packages (#242) 2023-05-24 15:28:52 -07:00
rickwebiii
6604afbf95 ZKP array inputs (#217)
* ZKP array inputs
2023-03-01 13:33:14 -08:00
rickwebiii
48ebc52576 Rweber/zkp (#211)
Metal GPU accelerated scalar multiplication
2023-02-16 14:31:55 -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
64036ccaee Rweber/zkp (#197)
Plumb BackendField to NativeField for negative number support.
2023-01-04 11:38:18 -08:00
rickwebiii
d03207e67e Rweber/zkp (#196)
Add BFV playground, Polynomial addition
2022-12-19 12:00:23 -08:00
rickwebiii
18fb031953 Rweber/zkp (#195)
Can now use #[constant] and #[public] inputs
2022-12-09 16:21:34 -08:00
rickwebiii
85e3a60e35 Rweber/zkp (#194)
Add to_unsigned gadget and test
2022-12-08 17:57:31 -08:00
rickwebiii
c6056bf8d9 Rweber/zkp (#193)
Can use gadgets
2022-12-08 10:08:57 -08:00
rickwebiii
72f00391ea Rweber/zkp (#188)
ZKP works E2E
2022-11-29 13:47:29 -08:00
rickwebiii
d847021858 Rweber/zkp (#186)
Add ZKP backend for Bulletproofs
2022-11-18 20:06:48 -08:00
rickwebiii
28ea71118f Rweber/zkp (#185)
Start ZKP compiler and refactor common code.
2022-11-15 12:43:04 -08:00
Sam Tay
2db8e90a8d Allow type complexity for macro generated code 2022-10-31 15:30:34 -07: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
0ca0052018 Rweber/release 0.7 (#178)
* 0.7 release

* Fix docs links
2022-10-17 14:56:27 -07:00
rickwebiii
c2b1850fab Rweber/maint (#176)
Fix security vulnerability warning for unmaintained ansi_term.
2022-09-22 11:55:59 -07:00
rickwebiii
334355067a Rweber/chaining (#171)
Chaining
2022-08-15 13:58:22 -07:00
rickwebiii
b8cbacac69 Downgrade minimum required toolchain (#160) 2022-07-20 12:05:07 +01:00
rickwebiii
136d03f081 Rweber/crateupdate (#152)
* Fix broken links

* Bump packages
2022-07-14 11:37:27 -07:00
rickwebiii
123da60636 Rweber/packages (#150)
* No network during build

* Bump packages
2022-07-13 18:47:54 -07:00
rickwebiii
121e7be325 Rweber/multiprogram (#130)
Allow compiling multiple FHE programs to use the same parameters.
2022-07-06 17:04:43 -07:00
rickwebiii
04d0ee90d2 Fixup Cargo.toml files for release 2022-05-16 18:00:39 -07:00
Rick Weber
2ad081f9c7 Version bump 2022-04-28 16:07:35 -07:00
Rick Weber
a6592b9760 Can return arrays from FHE programs 2022-04-26 21:44:37 -07:00
Rick Weber
fb7241acc7 Unit test self in macro 2022-04-26 16:12:28 -07:00
Rick Weber
4b0b3f38cd It works 2022-04-26 14:59:53 -07:00
Rick Weber
9d57a490a4 WIP 2022-04-26 13:58:58 -07:00
Rick Weber
917c0efc82 WIP 2022-04-26 13:52:10 -07:00
Rick Weber
6047fba925 Bump version 2022-04-19 10:44:17 -07:00
Rick Weber
ad930251dc Add array support 2022-04-12 11:09:59 -07:00
Rick Weber
5639f3c16b Rename sunscreen_compiler to sunscreen 2022-03-22 14:29:35 -07:00
Rick Weber
539ca57087 Bump seal crate version 2022-02-28 15:03:06 -08:00
Rick Weber
e4f50ba996 Move tests to break dependency cycle 2022-02-14 18:57:43 -08:00
Rick Weber
7a08ddb1ef update registry 2022-02-14 18:15:24 -08:00
Rick Weber
fc63ba110b Rename noise_margin 2022-02-01 17:22:03 -08:00
Rick Weber
03b120e824 Rename Secret/Public to PrivateKey/PublicKey 2022-02-01 17:14:25 -08:00
Rick Weber
b92ac2d442 cargo fmt 2022-02-01 16:36:03 -08:00
Rick Weber
13bee724ec Rename circuit to FHE program 2022-02-01 16:35:45 -08:00
Rick Weber
37f9167f04 Rename circuit WIP 2022-02-01 16:20:06 -08:00
Rick Weber
483ee9e296 circuit rename WIP 2022-02-01 15:59:05 -08:00
Rick Weber
4554dc2c05 Rename circuit WIP 2022-02-01 15:50:27 -08:00