Commit Graph

15 Commits

Author SHA1 Message Date
Jack Grigg bfc65d5985 poseidon: Remove `self` parameter from `Domain` trait methods
For almost all the sponge constructions defined in the Poseidon paper,
the domain can be defined completely statically. Variable-length hashing
requires knowledge of the message length, but that can be provided to
the fixed padding function in a subsequent commit, and in any case we
can't use variable-length inputs in a circuit.
2021-12-10 02:40:33 +00:00
Jack Grigg 9f654005c7 poseidon: Replace the `Duplex` struct with a `Sponge` struct
The `Sponge` struct's API correctly enforces the properties of a sponge:
it can absorb an arbitrary number of elements, and then squeeze an
arbitrary number of elements, but cannot absorb after it has squeezed.

Co-authored-by: ying tong <yingtong@z.cash>
2021-12-10 02:40:32 +00:00
Jack Grigg b827298d42 poseidon: Rename `SpongeState` to `SpongeRate` 2021-12-09 17:19:05 +00:00
Jack Grigg 65a89f099b Replace `gadget::utilities::copy` with `AssignedCell::copy_advice`
Also replaces other copy-advice implementations that weren't using
`copy`.
2021-12-08 01:50:02 +00:00
Jack Grigg 3079800f42 Remove `Var::new` trait method
As the underlying `Region` methods now return `AssignedCell` instead of
`Cell`, we can simplify all the places where we then constructed a
`CellValue` struct.
2021-12-08 01:48:17 +00:00
Jack Grigg 9b41a06363 Migrate to halo2 version with `AssignedCell`
We change `CellValue` into a typedef of `AssignedCell` to simplify the
migration in this commit.

The migration from `CellValue` to `AssignedCell` requires several other
changes:

- `<CellValue as Var>::value()` returned `Option<F>`, whereas
  `AssignedCell::<F, F>::value()` returns `Option<&F>`. This means we
  need to dereference, use `Option::cloned`, or alter functions to take
  `&F` arguments.
- `StateWord` in the Poseidon chip has been changed to a newtype around
  `AssignedCell` (the chip was written before `CellValue` existed).
2021-12-08 01:45:00 +00:00
Jack Grigg 5cb838f1a2 circuit: Remove `Copy` impl from `poseidon::pow5::StateWord`
We will be making it a newtype around `halo2::circuit::AssignedCell`,
which does not impl `Copy`.
2021-12-08 01:44:09 +00:00
ying tong b02628d263 Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-12-01 09:31:53 -05:00
therealyingtong 421891f065 Benchmark proof creation and verification for RATE = 2, 8, 11. 2021-11-30 10:03:49 -05:00
therealyingtong 9b76556503 poseidon: Make gadget tests generic over WIDTH, RATE 2021-11-30 10:03:49 -05:00
therealyingtong b63c868591 poseidon: Make Spec trait methods not take (&self) parameter. 2021-11-30 10:02:16 -05:00
Jack Grigg 99d03e0d25 Migrate to latest halo2 revision 2021-11-26 16:24:26 +00:00
therealyingtong 9bb29018ac poseidon::pow5: Undo circuit change.
Co-authored-by: str4d <jack@electriccoin.co>
2021-11-23 15:38:55 -05:00
ying tong 79123629da
Docfixes and minor refactors.
Co-authored-by: str4d <jack@electriccoin.co>
2021-11-23 15:29:56 -05:00
therealyingtong fe1bc97ab4 Generalise Pow5T3 chip to be generic over WIDTH, RATE. 2021-11-19 00:50:04 -05:00