58 Commits

Author SHA1 Message Date
Daniel Lubarov
be7a489c6e Fix stack overflow 2023-01-10 21:03:46 -08:00
Daniel Lubarov
b8e97aaaf8 Fix logic and Keccak CTLs
Lots of little bugs!

- The Keccak sponge table's padding logic was wrong, it was mixing up the number of rows with the number of hashes.
- The Keccak sponge table's Keccak-looking data was wrong - input to Keccak-f should be after xor'ing in the block.
- The Keccak sponge table's logic-looking filter was wrong. We do 5 logic CTLs for any final-block row, even if some of the xors are with 0s from Keccak padding.
- The CPU was using the wrong/outdated output memory channel for its Keccak sponge and logic CTLs.
- The Keccak table just didn't have a way to filter out padding rows. I added a filter column for this.
- The Keccak table wasn't remembering the original preimage of a permutation; lookers were seeing the preimage of the final step. I added columns for the original preimage.
- `ctl_data_logic` was using the wrong memory channel
- Kernel bootloading generation was using the wrong length for its Keccak sponge CTL, and its `keccak_sponge_log` was seeing the wrong clock since it was called after adding the final bootloading row.
2022-12-19 15:42:59 -08:00
Daniel Lubarov
a63b73a851 Misc fixes 2022-12-02 13:56:52 -08:00
Daniel Lubarov
4f66d58de5 Fixes 2022-12-01 17:14:40 -08:00
Daniel Lubarov
9bf47ef8ac Fixes 2022-12-01 12:46:14 -08:00
Brandon H. Gomes
6fd0da216a
fix: remove unstable features from plonky2
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-02 17:50:31 -07:00
Daniel Lubarov
b6d71a7008 Keccak benchmark
And reworking things a bit to include the timing data we want.
2022-09-23 10:54:17 -07:00
Daniel Lubarov
aae9e49e90
Merge pull request #696 from mir-protocol/public_memory
Public memory, part 1
2022-08-25 23:48:01 -07:00
Daniel Lubarov
66a3999679 Keccak generation tweak 2022-08-25 23:13:29 -07:00
Daniel Lubarov
aa87f2c3ba Public memory 2022-08-25 20:19:18 -07:00
Daniel Lubarov
fb34b09888 Remove keccak_rust in favor of tiny-keccak
`keccak_rust` doesn't seem to have much usage, and it treats `x` as the major axis of its 5x5 input.  This is not exactly wrong, since Keccak itself doesn't have a notion of axis order. However, there is a convention for mapping bits of the cube to a flat list of bits, which is

> The mapping between the bits of `s` and those of `a` is `s[w(5y + x) + z] = a[x][y][z]`.

Obeying this convention would be awkward with `keccak_rust` - the words in memory would need to be transposed.
2022-08-24 15:48:02 -07:00
Daniel Lubarov
61819af07d Improved Keccak implementation
Based on the approach @SyxtonPrime described.

In terms of columns, the changes are:
- Store inputs (`A`) as `u32` limbs, rather than individual bits.
- Remove `C_partial`. It was used to store an intermediate product in a 5-way xor, but we've since realized that we can do a 5-way xor directly.
- Add `C_prime`, an intermediate result used to help verify the relation between `A` and `A'`.
2022-08-14 21:33:35 -07:00
Daniel Lubarov
5d74a19ad6 Add test (won't work for a while, but to illustrate) 2022-07-04 18:10:03 -07:00
wborgeaud
f30889b7d7 NUM_REGISTERS -> NUM_COLUMNS 2022-06-29 10:06:46 +02:00
wborgeaud
7812ad242c s/registers/columns 2022-06-29 10:02:03 +02:00
Daniel Lubarov
e73d01a037
packed_field -> packed (#584)
* `packed_field` -> `packed`

For cleaner imports; "field" is usually clear from context

* fix
2022-06-27 15:07:52 -07:00
Daniel Lubarov
3346d3f902
field_types -> types (#583)
* `field_types` -> `types`

Here too, I think "field" is usually clear from context, e.g. in `use plonky2::field::types::Field;`.

* fixes

* fmt
2022-06-27 12:24:09 -07:00
Daniel Lubarov
410e03349c
extension_field -> extension (#581)
It seems redundant in most contexts, e.g. `use plonky2::field::extension_field::Extendable;`. One could import `extension_field`, but it's not that common in Rust, and `field::extension` is now about as short.
2022-06-27 07:18:21 -07:00
Jacqueline Nabaglo
3aaab765dd
define columns for CTL closer to the constraints (#573) 2022-06-21 10:28:44 -07:00
wborgeaud
d9b5d83383 Minor 2022-06-14 16:21:37 +02:00
wborgeaud
1dce18495a Remove Keccak input limbs 2022-06-14 01:21:17 +02:00
wborgeaud
1356b980c6
Merge pull request #558 from mir-protocol/filtered_ctl
Filtered CTL
2022-06-13 19:21:06 +02:00
wborgeaud
bf375390b7 Keccak round flags constraints 2022-06-13 17:41:17 +02:00
wborgeaud
fdd6a7cad8 Wired CPU and Keccak 2022-06-10 21:02:56 +02:00
wborgeaud
8bd6bebdc7 INPUT_LIMBS -> NUM_INPUTS 2022-06-10 19:30:51 +02:00
wborgeaud
30abe19e42 Fix 2022-06-10 00:49:22 +02:00
wborgeaud
413a5a30eb Merge branch 'main' into keccak_input_registers 2022-06-10 00:14:11 +02:00
wborgeaud
2f3a280b90 Circuit fix 2022-06-09 23:40:58 +02:00
wborgeaud
51f66d4dac Fix constraint 2022-06-09 23:36:43 +02:00
wborgeaud
8af99cba5d Progress 2022-06-09 22:42:48 +02:00
wborgeaud
1cc38bb032 Add Keccak input registers 2022-06-09 22:31:33 +02:00
Nicholas Ward
1ad8ec5f33 fix 2022-06-07 10:57:06 -07:00
Nicholas Ward
67167d8e03 use bit operations 2022-06-07 10:57:06 -07:00
Nicholas Ward
8b37d5d25a fix 2022-06-07 10:57:06 -07:00
Nicholas Ward
3b9cb7a9cf fmt 2022-06-07 10:57:06 -07:00
Nicholas Ward
cacc073e4e fix 2022-06-07 10:57:06 -07:00
Nicholas Ward
9d118ca1ef fix 2022-06-07 10:57:06 -07:00
Nicholas Ward
901525c185 constants crate 2022-06-07 10:57:06 -07:00
Nicholas Ward
f0ed391865 clippy 2022-06-07 10:57:06 -07:00
Nicholas Ward
78b2a5ebef fixed constraints, in line with generator 2022-06-07 10:57:06 -07:00
Nicholas Ward
52afdae551 cleanup 2022-06-07 10:57:06 -07:00
Nicholas Ward
dc082139c5 fmt 2022-06-07 10:57:06 -07:00
Nicholas Ward
80d5e5375e fixes, cleanup, and correctness test 2022-06-07 10:57:06 -07:00
Nicholas Ward
9fbae06b61 fmt 2022-06-07 10:57:06 -07:00
Nicholas Ward
04978473d2 fix yay 2022-06-07 10:57:06 -07:00
Nicholas Ward
964849d956 fix 2022-06-07 10:57:06 -07:00
Nicholas Ward
ac18c39044 fmt 2022-06-07 10:57:06 -07:00
Nicholas Ward
69aed6586a fixes 2022-06-07 10:57:06 -07:00
Nicholas Ward
60c0b4ee79 fix 2022-06-07 10:57:06 -07:00
Nicholas Ward
e34626e9ba fix 2022-06-07 10:57:06 -07:00