Commit Graph

2110 Commits

Author SHA1 Message Date
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
Jack Grigg 62eea4c457 dev: Move cell loaders into `dev::util` 2022-02-16 13:56:17 +00:00
Jack Grigg 44e3cf8c61 dev: Move expression stringifier into `dev::failure::emitter` 2022-02-16 13:56:17 +00:00
Jack Grigg 212e3d07ce dev: Move cell layout emitter into a submodule 2022-02-16 13:56:17 +00:00
Jack Grigg 8e1fb87a33 dev: Add a custom `VerifyFailure::ConstraintNotSatisfied` emitter
An example failure, shown via `assert_eq!(err, Ok(()))`:
```
  left: `Err([ConstraintNotSatisfied { constraint: Constraint { gate: Gate { index: 0, name: "R1CS constraint" }, index: 0, name: "buggy R1CS" }, location: InRegion { region: Region { index: 0, name: "Example region" }, offset: 1 }, cell_values: [(VirtualCell { name: "", column: Column { column_type: Advice, index: 0 }, rotation: 0 }, "0x2"), (VirtualCell { name: "", column: Column { column_type: Advice, index: 1 }, rotation: -1 }, "0x4"), (VirtualCell { name: "", column: Column { column_type: Advice, index: 2 }, rotation: 1 }, "0x8")] }])`,
 right: `Ok(())`',
```

Via `impl Display for VerifyFailure`:
```
Constraint 0 ('buggy R1CS') in gate 0 ('R1CS constraint') is not satisfied in Region 0 ('Example region') at offset 1
- Column('Advice', 0)@0 = 0x2
- Column('Advice', 1)@-1 = 0x4
- Column('Advice', 2)@1 = 0x8
```

Via `VerifyFailure::emit`:
```
error: constraint not satisfied
  Cell layout in region 'Example region':
    | Offset | A0 | A1 | A2 |
    +--------+----+----+----+
    |    0   |    | x1 |    |
    |    1   | x0 |    |    | <--{ Gate 'R1CS constraint' applied here
    |    2   |    |    | x2 |

  Constraint 'buggy R1CS':
    S0 * (x0 * x1 + x2) = 0

  Assigned cell values:
    x0 = 0x2
    x1 = 0x4
    x2 = 0x8
```
2022-02-16 13:56:17 +00:00
Jack Grigg 5cdc029bb4 dev: Add `MockProver::assert_satisfied`
This is equivalent to `assert_eq!(mock_prover.verify(), Ok(()))`, but
pretty-prints the verification failures instead of debug-printing them.
In its initial state, it just prints the `Display` impl.
2022-02-16 13:56:17 +00:00
Jack Grigg 0e08903669 dev: Move `VerifyFailure` and `FailureLocation` into submodule 2022-02-16 13:55:29 +00:00
str4d c12620c598
Merge pull request #505 from zcash/ci-updates
CI updates
2022-02-16 13:54:19 +00:00
Jack Grigg 82bb4e6141 CI: Test against Windows and macOS in addition to Ubuntu 2022-02-15 23:35:11 +00:00
Jack Grigg e2932427ed CI: Update `codecov/codecov-action` to v2.1.0 2022-02-15 23:34:43 +00:00
str4d c63828b51a
Merge pull request #504 from zcash/release-0.1.0-beta.2
`halo2 0.1.0-beta.2` etc.
2022-02-15 01:57:34 +00:00
Daira Hopwood c5cdea1eb0
Merge pull request #487 from daira/book-improve-incomplete-addition
Improve the explanation of incomplete addition
2022-02-15 01:05:00 +00:00
Jack Grigg 80953d02c2 halo2 0.1.0-beta.2 2022-02-14 22:03:40 +00:00
Jack Grigg c9852c61ec halo2_gadgets 0.1.0-beta.1 2022-02-14 21:58:20 +00:00
Jack Grigg f642727e51 halo2_proofs 0.1.0-beta.2 2022-02-14 21:58:20 +00:00
Jack Grigg 1d2f698aca Update license dates and links 2022-02-14 21:58:20 +00:00
Jack Grigg e0cc7b39d3 Update changelogs 2022-02-14 21:29:42 +00:00
ebfull 247cd620ee
Merge pull request #502 from zcash/simplify-ipa-equation
halo2_proofs: change IPA check equation to match the book
2022-02-14 11:17:11 -07:00
Sean Bowe 0b73c74f72
Address comments brought up by @str4d. 2022-02-14 10:44:14 -07:00
Sean Bowe f2daf91315
halo2_proofs: change IPA check equation to match the book
The verifier's check in the inner product argument used to assume that the
G'_0 value had an additional (trivial) blinding factor term, which makes
it slightly easier to reason that it never is the point at infinity.
However, we never sample challenges that are zeroes (both for security
and completeness reasons) so this element would never be the point at
infinity anyway. Thus, we can simplify the check with the added benefit of
matching the book's description of the protocol.
2022-02-14 09:37:57 -07:00
ebfull 8c0deb10aa
Merge pull request #495 from zcash/book-consistency
halo2_proofs: rename variables for consistency
2022-02-14 09:24:20 -07:00
str4d 552c5beb23
Merge pull request #501 from zcash/hardcoded-proof
Add hardcoded proof to plonk_api test
2022-02-14 16:07:52 +00:00
Sean Bowe 90bebdf29a
halo2_proofs: add hardcoded proof to plonk_api test for backwards compatibility testing 2022-02-14 08:48:03 -07:00
Sean Bowe 289f24bb8b
Improvements due to @daira's code review. 2022-02-11 08:50:55 -07:00
Sean Bowe a129490517
Minor changes 2022-02-10 08:08:20 -07:00
Sean Bowe a4d3c328b9
halo2_proofs: rename variables for consistency
This changes variable names in the multiopen and commitment opening implementations
and the book's protocol description to keep names and indicies consistent with one
another.

Co-Authored-By: Jack Grigg <jack@electriccoin.co>
2022-02-09 13:37:50 -07:00
str4d b45180273e
Merge pull request #486 from rex4539/typos
Fix typos
2022-02-08 17:52:28 +00:00
str4d 9617336d46
Merge pull request #489 from zcash/ci-book-pin-nightly
CI: Pin nightly version in book workflow
2022-02-04 01:27:43 +00:00
Jack Grigg 53427d19db CI: Pin nightly version in book workflow
We require nightly Rust to build the documentation, but latest nightly
has a bug where `--no-deps` causes an ICE.
2022-02-04 01:23:32 +00:00
str4d 457739593e
Merge pull request #488 from zcash/fix-ci-rustdoc
CI: Fix rustdoc rendering to handle workspace
2022-02-04 01:04:54 +00:00
Jack Grigg 0ce0280b26 CI: Fix rustdoc rendering to handle workspace
`cargo rustdoc` only works for a single package. To render docs for
a workspace while passing config options to `rustdoc`, we need to use
the `RUSTDOCFLAGS` environment variable.

We also add several other flags to handle the switch to `cargo doc`:
- `--no-deps` ensures we only build packages in the workspace.
- `--enable-index-page` (unstable) adds a landing page showing the list
  of rendered crate docs.
2022-02-04 01:03:52 +00:00
Daira Hopwood c4bdab59e3 Improve the explanation of incomplete addition:
* use biimplication in the correctness argument to ensure both soundness and completeness;
* avoid introducing lambda at all; it's unnecessary and omitting it shortens the explanation.

Co-authored-by: Jack Grigg <str4d@electriccoin.co>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-02-03 22:06:05 +00:00
Dimitris Apostolou e2f88e450b
Fix typos 2022-02-03 18:01:22 +02:00
str4d ee14e3f985
Merge pull request #481 from zcash/457-deprecated-bigint
halo2_gadgets: Migrate from bigint to uint
2022-02-02 00:40:30 +00:00
Jack Grigg c6886600a9 halo2_gadgets: Migrate from bigint to uint
Closes zcash/halo2#457.
2022-02-01 16:19:53 +00:00
str4d 4bb7496b6f
Merge pull request #473 from zcash/halo2_gadgets-import
Import `halo2_gadgets` as extracted from `orchard`
2022-02-01 15:58:12 +00:00
Jack Grigg 5312343e6d halo2_gadgets: Expose testing APIs required by `orchard` 2022-01-28 17:52:48 +00:00
str4d f3502421cd
Merge pull request #475 from zcash/patch-gadgets-import
`halo2_gadgets` import: Visibility fixes and Clippy fixes.
2022-01-28 16:28:03 +00:00
therealyingtong 3547008d35 Clippy fixes. 2022-01-28 23:50:14 +08:00
therealyingtong 7c7c281000 Visibility fixes. 2022-01-28 23:38:22 +08:00
Jack Grigg bb76d8c292 CI: List explicit features to check against WASM
We can't check the `test-dependencies` feature flag, because `proptest`
fails to compile on WASM.
2022-01-27 23:44:42 +00:00
Jack Grigg 9a12beee73 halo2_gadgets: Rename `halo2` to `halo2_proofs`
The previous commit renamed `halo2_proofs` back to `halo2` temporarily
to keep the commit size down. This commit performs the rename in a
single pass.
2022-01-27 23:32:04 +00:00
Jack Grigg 5202ec6eda Integrate `halo2_gadgets` into the workspace
THe SHA-256 example gadget has been moved into the `halo2_gadgets` crate
behind an `unstable` feature flag.
2022-01-27 23:32:04 +00:00
Jack Grigg 7e9ced2eaa Merge `halo2_gadgets` from zcash/orchard into halo2_gadgets-import 2022-01-27 23:08:35 +00:00
Jack Grigg a2367abcaf Migrate to `halo2_gadgets` crate in subdir
- The crate module structure from `orchard` has been flattened.
- The book pages we want to include in `halo2` have been moved to their
  target location, to avoid any conflicts during the merge.
- Common files that already exist in zcash/halo2 have been removed.
2022-01-27 23:08:01 +00:00
Jack Grigg c4ef177e07 Implement in-crate gadget tests (independent of Orchard constants)
We define some simple fixed bases around the default Pallas generator,
and a simple Sinsemilla instantiation. The tests now compile and pass.

Co-authored-by: ying tong <yingtong@z.cash>
2022-01-27 23:08:01 +00:00
Jack Grigg c2866beb47 Delete Orchard-specific code, dependencies, and book pages
The tests do not compile as of this commit, due to Orchard-specific
constants being deleted, but everything else compiles.

Co-authored-by: ying tong <yingtong@z.cash>
2022-01-27 23:07:59 +00:00
str4d 159ab53da5
Merge pull request #186 from zcash/refactor-gadget-crates
Prepare to extract gadgets into crates
2022-01-27 17:53:18 +00:00