Commit Graph

2480 Commits

Author SHA1 Message Date
Jack Grigg d43c8612a3 CI: Use `ubuntu-latest` runner for book workflow
The `mdbook` binaries are currently built using `ubuntu-latest`, meaning
can end up relying on newer versions of GLIBC. Until this is fixed
upstream (https://github.com/rust-lang/mdBook/issues/1779), we will use
the same runner configuration as them.
2022-04-24 22:57:02 +00:00
Jack Grigg b02800466a halo2_gadgets: Migrate chip gates to `Constraints::with_selector`
Only one gate couldn't be migrated without altering the Orchard circuit.
2022-04-24 22:13:38 +00:00
Daira Hopwood 66827f3df9
Merge pull request #544 from zcash/book-patch-vanishing
[book] Use more intuitive expression for vanishing poly degree
2022-04-22 16:46:39 +01:00
dependabot[bot] f52d477257
Bump codecov/codecov-action from 2.1.0 to 3.1.0
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2.1.0 to 3.1.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v2.1.0...v3.1.0)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-22 10:23:09 +00:00
str4d 66b2b3ba7e
Merge pull request #414 from zcash/constraints-helper
Add a `Constraints` helper
2022-04-22 11:52:06 +02:00
str4d f49f4d16f2
Merge pull request #552 from zcash/benchmark-fft
Add benchmark for various FFT sizes
2022-04-20 23:42:22 +02:00
Sean Bowe a02b9e2e7e
Add benchmark for various FFT sizes. 2022-04-20 13:09:58 -06:00
Jack Grigg d93846f8fd Note that `Constraints::with_selector` accepts arrays from 1.53 2022-04-20 10:55:55 +00:00
Jack Grigg 78de8a5c94 Add a `Constraints` helper
There are two existing patterns for constructing a gate from a set of
constraints with a common selector:

- Create an iterator of constraints, where each constraint includes the
  selector:
  ```
  vec![
      ("foo", selector.clone() * foo),
      ("bar", selector.clone() * bar),
      ("baz", selector * bar),
  ]
  ```
  This requires the user to write O(n) `selector.clone()` calls.

- Create an iterator of constraints, and then map the selector in:
  ```
  vec![
      ("foo", foo),
      ("bar", bar),
      ("baz", bar),
  ].into_iter().map(move |(name, poly)| (name, selector.clone() * poly))
  ```
  This looks cleaner overall, but the API is not as intuitive, and it
  is messier when the constraints are named.

The `Constraints` struct provides a third, clearer API:
```
Constraints::with_selector(
    selector,
    vec![
        ("foo", foo),
        ("bar", bar),
        ("baz", bar),
    ],
)
```
This focuses on the structure of the constraints, and handles the
selector application for the user.
2022-04-20 10:55:50 +00:00
str4d 46ba444169
Merge pull request #480 from zcash/477-mockprover-pretty-failures
Add `MockProver::assert_satisfied` with pretty-printed failures
2022-04-20 12:53:16 +02:00
Daira Hopwood a307bc4e2d
Merge pull request #551 from daira/daira-book-combining
[book] Add description of selector combining optimization. fixes #466
2022-04-19 15:38:11 +01:00
str4d 69c138c25c
Clarify some comments and messages
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-04-19 16:04:19 +02:00
str4d 606afb8349
Merge pull request #445 from daira/mockprover-regression
Fix mock prover performance regression for lookup arguments
2022-04-19 14:17:17 +02:00
Daira Hopwood 424a2748d1
Clarify a comment 2022-04-19 12:36:02 +01:00
Daira Hopwood 84f5c26b7f [book] Add description of selector combining optimization.
fixes #466

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-04-18 20:19:26 +01:00
str4d 221766986b
Merge pull request #532 from zcash/bench-lookup-mockprover
Bench heavily padded lookup in MockProver.
2022-04-18 12:45:30 +02:00
str4d 19b2b3b7e2
Fix clippy lints 2022-04-18 12:25:58 +02:00
str4d dc2e454aa2
Merge pull request #549 from zcash/patch-cost-model-lookup
cost-model.rs: Correct lookup required degree calculation.
2022-04-18 11:52:47 +02:00
ying tong 066bd15d7e
cost-model.rs: Correct lookup required degree calculation. 2022-04-14 16:25:52 +02:00
ying tong 8cb9226670
[book] Use more intuitive expression for vanishing poly degree 2022-04-10 17:10:51 +02:00
Jack Grigg 0c50500a4f Add an umbrella copyright line to cover future contributors
After the relicense, and removal of the CLA, contributors will retain
copyright over any future contributions. They are just required to
dual-license their contributions as MIT OR Apache 2.0, as with most
other Rust libraries.
2022-04-07 14:51:05 +00:00
Jack Grigg 90e671e77c Relicense Halo 2 crates as MIT OR Apache 2.0
See this blog post for details:
    https://electriccoin.co/blog/zero-knowledge-proving-system-halo-now-licensed-under-mit-making-it-available-for-anyone-to-use/
2022-04-07 14:22:49 +00:00
str4d 1e6bb51790
Merge pull request #540 from zcash/release-0.1.0-beta.4
Release halo2_proofs 0.1.0-beta.4
2022-04-06 12:23:23 +01:00
therealyingtong 75b5c1e923 halo2_gadgets 0.1.0-beta.3 2022-04-06 12:28:36 +08:00
therealyingtong a11cb9796e halo2_proofs 0.1.0-beta.4 2022-04-06 12:24:28 +08:00
str4d 95df0af86d
Merge pull request #537 from zcash/fix-stack-overflow
Reduce depth of AST by special casing the application of Horner's rule
2022-04-04 23:13:30 +01:00
Sean Bowe 6a31a0e6a1
Apply @str4d's review suggestions. 2022-04-04 14:07:31 -06:00
Sean Bowe fa069a7455
Use unwrap_or_default() instead of unwrap_or(HashMap::new()) 2022-04-03 10:06:19 -06:00
Sean Bowe fd7e9ddbb0
rustfmt 2022-04-02 15:38:46 -06:00
Sean Bowe 4163b8765a
Reduce depth of AST by special casing the application of Horner's rule.
The existing code will fold together a very deep AST that applies Horner's
rule to each gate in a proof -- which could include multiple circuits and
so for some applications will quickly grow such that when we recursively
descend later during evaluation the stack will easily overflow.

This change special cases the application of Horner's rule to a
"DistributePowers" AST node to keep the tree depth from exploding in size.
2022-04-02 13:13:46 -06:00
Jack Grigg 0946bdb455 dev: Enable `VerifyFailure::Permutation` to point to region offsets 2022-03-30 01:39:50 +00:00
therealyingtong 51d34c12a2 Bench heavily padded lookup in MockProver.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-03-24 22:02:29 +08:00
str4d 406f622e33
Merge pull request #531 from zcash/release-0.1.0-beta.3
Release `halo2_proofs 0.1.0-beta.3`
2022-03-22 20:29:09 +00:00
Jack Grigg 11dcfb88ba halo2_gadgets 0.1.0-beta.2 2022-03-22 20:04:14 +00:00
Jack Grigg 8acd4abfb3 halo2_proofs 0.1.0-beta.3 2022-03-22 19:59:10 +00:00
Jack Grigg e39c8e94d2 Update changelogs 2022-03-22 19:55:53 +00:00
str4d 8abd7b74db
Merge pull request #417 from zcash/fix-assigned-usage
Expand `Assigned<F>` APIs
2022-03-22 19:46:51 +00:00
ying tong 084ecf185a
Merge pull request #523 from zcash/therealyingtong-patch-1
[book] Correct typo in Q_0 of protocol description.
2022-03-18 12:56:36 +08:00
str4d 642efc1536
Merge pull request #521 from zcash/reconstruct-selectors
Remove selector_map from pinned verification key and remove VerificationKey serialization
2022-03-18 00:14:36 +00:00
str4d 31b68fab25
Merge pull request #524 from zcash/fix-docs-rs-build
Fix docs.rs build
2022-03-17 19:34:52 +00:00
Jack Grigg c6b4fcaf34 Fix docs.rs build
The published source code for each package needs to include the required
header file, and the path to that header file needs to be relative to
the package source (not the repository source). We therefore need to
have the header file present in each workspace package.

Closes zcash/halo2#506.
2022-03-17 19:14:11 +00:00
Jack Grigg d3f2980349 Remove VerifyingKey serialization from sha256 gadget benchmark 2022-03-17 18:58:53 +00:00
ying tong 2194973aa8
[book] Correct typo in protocol description.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-03-17 21:35:06 +08:00
Sean Bowe f46d77763e
Remove logic for reading and writing VerificationKey to/from buffers. 2022-03-16 14:19:33 -06:00
Sean Bowe 819bc3c2f5
Stop placing the selector_map (which is an internal API detail) in the pinned verification key. 2022-03-16 14:19:13 -06:00
Sean Bowe e10f4e1d0e
Add mechanism for generating a new proof in test. 2022-03-16 12:53:04 -06:00
Daira Hopwood b48b032041
Minor simplification 2022-02-16 17:14:41 +00:00
Jack Grigg 57596cab36 dev: Add a custom `VerifyFailure::CellNotAssigned` emitter
The `dev::tests::unassigned_cell` test case, shown via `assert_eq!(err, Ok(()))`:
```
  left: `Err([CellNotAssigned { gate: Gate { index: 0, name: "Equality check" }, region: Region { index: 0, name: "Faulty synthesis" }, gate_offset: 1, column: Column { index: 1, column_type: Advice }, offset: 1 }])`,
 right: `Ok(())`',
```

Via `impl Display for VerifyFailure`:
```
Region 0 ('Faulty synthesis') uses Gate 0 ('Equality check') at offset 1, which requires cell in column Column { index: 1, column_type: Advice } at offset 1 to be assigned.
```

Via `VerifyFailure::emit`:
```
error: cell not assigned
  Cell layout in region 'Faulty synthesis':
    | Offset | A0 | A1 |
    +--------+----+----+
    |    0   | x0 |    |
    |    1   |    |  X | <--{ X marks the spot! 🦜

  Gate 'Equality check' (applied at offset 1) queries these cells.
```
2022-02-16 13:57:53 +00:00
Jack Grigg 369ff521d3 dev: Store gate offset in `VerifyFailure::CellNotAssigned` 2022-02-16 13:57:53 +00:00
Jack Grigg c19a1ade2a dev: Add a custom `VerifyFailure::Lookup` emitter
The `dev::tests::bad_lookup` test case, shown via `assert_eq!(err, Ok(()))`:
```
  left: `Err([Lookup { lookup_index: 0, location: InRegion { region: Region { index: 2, name: "Faulty synthesis" }, offset: 1 } }])`,
 right: `Ok(())`',
```

Via `impl Display for VerifyFailure`:
```
Lookup 0 is not satisfied in Region 2 ('Faulty synthesis') at offset 1
```

Via `VerifyFailure::emit`:
```
error: lookup input does not exist in table
  (L0) ∉ (F0)

  Lookup inputs:
    L0 = x1 * x0 + (1 - x1) * 0x2
    ^
    | Cell layout in region 'Faulty synthesis':
    |   | Offset | A0 | F1 |
    |   +--------+----+----+
    |   |    1   | x0 | x1 | <--{ Lookup inputs queried here
    |
    | Assigned cell values:
    |   x0 = 0x5
    |   x1 = 1
```
2022-02-16 13:56:17 +00:00