90 Commits

Author SHA1 Message Date
Daniel Lubarov
91f7b4e300
Replace CrandallQuarticField with a more generic QuarticExtension (#232)
* Replace `CrandallQuarticField` with a more generic `QuarticExtension`

And likewise for `CrandallQuadraticField`.

There are a few parameters which we can't automatically derive (in const Rust), so I specified them in a `AutoExtendable` trait.

This would make it fairly easy to add extension fields for `GoldilocksField` and any future fields.

* Attempt to derive 2-adicity, see Hamish's feedback

* Simplify TWO_ADICITY based on chat with Hamish

* PR feedback

* Merge AutoExtendable into Extendable (#235)
2021-09-13 11:45:17 -07:00
Daniel Lubarov
3bc34c59d8
Refactor GMiMC code (#224)
* Refactor GMiMC code

Adds a sub-trait of `Field` called `GMiMCInterface`, which is similar to `PoseidonInterface`.

This lets us have different fields with different GMiMC constants in a type-safe way.

* Remove `Interface`

* Const generic for width
2021-09-07 18:28:28 -07:00
Nicholas Ward
c07f99ac81 merge 2021-09-06 21:38:52 -07:00
Daniel Lubarov
236a143abf
Move some Field members to a Field64 subtrait (#213)
* Move some Field members to a Field64 subtrait

I.e. move anything specific to 64-bit fields.

Also, relatedly,
- Tweak a bunch of prover code to require `Field64`, since 64-bit stuff is used in a couple places, like the FRI proof-of-work
- Remove `bits()`, which was unused and assumed a 64-bit field
- Rename a couple methods to reflect that they're u64 variants

There are no functional changes.

* Field64 -> PrimeField

* Remove `exp_u32`, `kth_root_u32`

* PrimeField: PrimeField

* Move `to_canonical_biguint` as well

* Add back from_noncanonical_u128
2021-09-05 10:27:11 -07:00
Nicholas Ward
013c8bb612 progress 2021-09-03 18:07:20 -07:00
Jakub Nabaglo
21b263ee3e
Shave off 2% by optimizing check_partial_products (#205)
* Shave off 2% by optimizing check_partial_products

Removes a bunch of allocations/deallocations

* Minor style (Daniel PR comment)
2021-08-28 14:59:56 -07:00
wborgeaud
71f64329c7 Minor 2021-08-24 08:30:34 +02:00
wborgeaud
69a945547a route, assert_equal -> connect 2021-08-24 08:25:11 +02:00
wborgeaud
cd1bd9e77b
Merge pull request #195 from mir-protocol/partition_witness
Remove `CopyGenerator`s and add new `PartitionWitness`
2021-08-24 08:16:35 +02:00
Jakub Nabaglo
8c4961222f
Optimize bit reverse transpose (#198)
* Bit reverse improvements

* Formatting

* Tests

* Daniel PR comment
2021-08-23 12:10:49 -07:00
wborgeaud
a90ea6ec79 PartialWitness back to HashMap 2021-08-20 11:56:57 +02:00
wborgeaud
e81001b9ba Clippy 2021-08-20 11:13:40 +02:00
wborgeaud
6584734928 Cleaning 2021-08-20 10:44:19 +02:00
wborgeaud
a44bf9ffd8 Added witness trait 2021-08-20 09:50:07 +02:00
Daniel Lubarov
90c7a72ceb
Remove some unused warnings (#192)
- Made some methods public, if they seemed like they'd be useful crates that depend on plonky2, and seemed like good/stable APIs
- Deleted a few things I didn't think seemed very useful
- Left a few for now that I was on the fence about
2021-08-19 08:23:45 -07:00
Jakub Nabaglo
7c97751c13
Optimized transpose (#191)
* Start work on optimized transpose

* Optimized transpose: 12-14% improvement on benchmark

* Transpose: Avoid bounds checks and change order of loops dynamically

* Transpose: re-enable bounds checks
2021-08-18 16:45:17 -07:00
Daniel Lubarov
d41924dad3
Benchmark transpose (#190)
* Benchmark transpose

* fmt
2021-08-18 09:43:19 -07:00
wborgeaud
5a9c5b295c Minor 2021-08-16 10:41:12 +02:00
wborgeaud
b366482866 The mother of all arithmetic optimizations 2021-08-16 10:18:10 +02:00
wborgeaud
6ba6201b94 Merge branch 'main' into push_to_8192
# Conflicts:
#	src/fri/recursive_verifier.rs
#	src/plonk/circuit_data.rs
#	src/plonk/recursive_verifier.rs
#	src/util/reducing.rs
2021-08-16 08:49:49 +02:00
Daniel Lubarov
e4cbee2b57
Disable ZK in large_config (#180)
* Disable ZK in large_config

Speeds up the tests from ~6m to ~1m (debug mode). `large_config` is crate-private so I don't think we need to worry about real users forgetting ZK, and I don't think ZK seems important in these tests, though we should probably have ZK enabled for a couple tests.

A couple tests need ZK or they fail; I added a TODO to look later.

This led to a few other changes:
- Fixed a bug where `trim` could truncate the final poly to a non-power-of-two length. This was improbable when ZK is on due to randomization.
- Gave a few methods access to the whole `CircuitConfig` vs `FriConfig` -- sort of necessary for the above fix, and I don't think there's much downside.
- Remove `cap_height` from `FriConfig` -- didn't really need it any more after giving more methods access to `CircuitConfig`, and having a single copy of the param feels cleaner/safer to me.

* PR feedback
2021-08-14 10:01:10 -07:00
wborgeaud
bb548fe148 More cleaning 2021-08-13 20:31:04 +02:00
wborgeaud
ceae6b9588 Cleaning 2021-08-13 20:12:20 +02:00
wborgeaud
43641174cb Comments 2021-08-13 18:00:40 +02:00
wborgeaud
611c1767b1 add reducing ext gate 2021-08-13 16:04:31 +02:00
wborgeaud
1c78965763 better 2021-08-13 15:24:38 +02:00
wborgeaud
7da4412de5 working 2021-08-13 15:22:03 +02:00
wborgeaud
75ad055f40 First try 2021-08-13 14:28:05 +02:00
wborgeaud
73ab11f420 More arithmetic optimizations 2021-08-13 11:35:20 +02:00
wborgeaud
21669be246 Some arithm optims 2021-08-13 10:40:31 +02:00
wborgeaud
dd076e5c73 Auto resize partial witness 2021-08-09 09:58:09 +02:00
wborgeaud
fe46aafb3e Merge branch 'main' into partial_witness_vec 2021-08-06 20:07:53 +02:00
wborgeaud
c328fb6733 unused import 2021-08-06 17:57:05 +02:00
wborgeaud
674b0a51e8 faster_transpose 2021-08-06 17:42:05 +02:00
wborgeaud
db236e4824 Fix tests 2021-08-06 15:14:38 +02:00
wborgeaud
7d11d0f8a1 Change PartialWitness to use Vecs 2021-08-06 14:58:39 +02:00
Daniel Lubarov
2d9891983f
Add a reduce_polys_base (#149)
* Add a reduce_polys_base

Reducing the polynomials in `open_plonk` was taking ~100ms on my machine. It was converting BF polynomials to the EF early on; by doing more work in the BF we can reduce it to ~20ms.

* PR feedback
2021-08-03 13:00:50 -07:00
Daniel Lubarov
1229d90fae
Add a tree of scopes for proving times (#141)
* Add a tree of scopes for proving times

To replace the old `timed!` macro, which had no hierarchy.

It's similar to `ContextTree`, which tracks gate counts of circuit operations.

This gives a more organized output, with indentation levels based on scope depth, parent durations listed before child durations, etc.

* PR feedback
2021-08-02 10:38:09 -07:00
Daniel Lubarov
018fb005f8
Move stuff around (#135)
No functional changes here. The biggest change was moving certain files into new directories like `plonk` and `iop` (for things like `Challenger` that could be used in STARKs or other IOPs). I also split a few files, renames, etc, but again nothing functional, so I don't think a careful review is necessary (just a sanity check).
2021-07-29 22:00:29 -07:00
wborgeaud
deea1c979b PR feedback 2021-07-25 18:12:26 +02:00
wborgeaud
2ea35bd9e4 Comments 2021-07-23 17:38:24 +02:00
wborgeaud
5a16d7c555 Change number of coeffs supported in ReducingGate depending on config 2021-07-23 17:35:23 +02:00
wborgeaud
c16d93ab33 scaling.rs -> reducing.rs 2021-07-23 17:31:00 +02:00
wborgeaud
ca540a8475 Working fri_combine_initial 2021-07-23 17:29:31 +02:00
wborgeaud
0526a9e149 Working ReducingGate 2021-07-23 17:16:53 +02:00
wborgeaud
59494ff8d1 Merge branch 'main' into optimize_mul_many
# Conflicts:
#	src/gates/arithmetic.rs
2021-07-21 17:47:38 +02:00
Daniel Lubarov
7d8bac7169
Change FFT methods to accept references (#115) 2021-07-21 08:26:41 -07:00
wborgeaud
b59d497964 Modify ArithmeticExtensionGate to support 32 wires 2021-07-21 17:20:08 +02:00
Daniel Lubarov
dff950c502
No Copy on ReducingFactor (#110)
It feels a little dangerous; would be easy to "fork" one accidentally. We already clone explicitly, this just enforces that in the future.
2021-07-20 09:27:35 -07:00
Daniel Lubarov
0a5d46bfa9
Have prove return Result (#100)
* Have `prove` return `Result`

To address that TODO.

* PR feedback
2021-07-18 23:14:48 -07:00