64 Commits

Author SHA1 Message Date
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
c6cf5cf130 Move PartitionWitness 2021-08-20 09:55:49 +02:00
wborgeaud
a44bf9ffd8 Added witness trait 2021-08-20 09:50:07 +02:00
wborgeaud
74c2be5090 First pass 2021-08-19 14:54:11 +02:00
wborgeaud
561228103f More scalar muls 2021-08-17 10:26:31 +02:00
Daniel Lubarov
69193a8dc2
Remove *_three methods (#182)
* Remove *_three methods

Since there's no longer a performance reason for them, and I think the *_many methods are about as short etc.

* PR feedback
2021-08-17 00:38:41 -07:00
wborgeaud
9a54540116 Minor 2021-08-16 11:08:26 +02: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
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
702eab1583 Add wide_arithmetic 2021-08-12 16:03:13 +02:00
Daniel Lubarov
090cf79787
Replace some old division code (#171)
- Delete unsafe methods
- Have related methods call the new div_add_extension method to simplify
2021-08-10 11:48:53 -07:00
wborgeaud
94123c456e Fix merge conflict 2021-08-10 09:21:03 +02:00
wborgeaud
4433fd8048 Merge branch 'main' into optimize_arithmetic_ops 2021-08-10 09:11:08 +02:00
wborgeaud
b15e36d29c PR feedback 2021-08-10 09:07:01 +02:00
wborgeaud
3adabbedf1 Fix comments 2021-08-09 14:15:20 +02:00
wborgeaud
8e6c30dc70 Use only one gate for div 2021-08-09 13:55:49 +02:00
wborgeaud
ff68b66bbb Add div_add 2021-08-09 13:46:20 +02:00
wborgeaud
4b44578ffa More optimizations 2021-08-09 12:39:37 +02:00
wborgeaud
ed8dc9fdc7 Cleaning 2021-08-09 11:33:38 +02:00
wborgeaud
eeb33f99ca Optimize mul_ext_algebra 2021-08-09 11:30:03 +02:00
wborgeaud
f0f8320b93 First pass 2021-08-09 10:46:29 +02:00
wborgeaud
dd076e5c73 Auto resize partial witness 2021-08-09 09:58:09 +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
d6211b8ab8
Reuse a buffer of generated values (#142)
* Reuse a buffer of generated values

To avoid allocating `GeneratedValues` all the time. Saves ~60ms or so.

* PR feedback
2021-08-02 10:55:10 -07:00
wborgeaud
df690f92bf Hardcode small exponents in exp_u64_extension 2021-08-02 13:31:12 +02:00
Daniel Lubarov
36a1386c6f
Small fix in arithmetic_extension_special_cases (#140)
This is detecting the case where we multiply something by 1 and add 0.  In that case we can just return the thing being multiplied by 1. We were using the wrong constant to detect this.

Reduces the cost of `compute_evaluation` from 8 to 6 gates.
2021-07-30 12:00:24 -07:00
Daniel Lubarov
50b07f2ceb
Special cases for extension field arithmetic (#138)
We previously checked for special cases, like arithmetic on constant Targets, in `arithmetic`. We can handle those cases without actually adding an `ArithmeticGate`.

Now that `arithmetic` just calls `arithmetic_extension`, it makes more sense to check for special cases in the latter method, so it applies to both base and extension field arithmetic.

Reduces gate count from 16149 to 15689.
2021-07-30 09:03:11 -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
Daniel Lubarov
bcf524bed0
Have add_gate take a generic type instead of GateRef (#125)
* Have add_gate take a generic type instead of GateRef

There are a couple advantages
- Users writing their own gates won't need to know about the `GateRef` wrapper; it's more of an internal thing now.
- Easier access to gate methods requiring `self` -- for example, `split_le_base` can just call `gate_type.limbs()` now.

* Update comment

* Always insert
2021-07-22 23:48:03 -07:00
wborgeaud
6cc871d30c PR feedback 2021-07-21 19:23:26 +02:00
wborgeaud
59494ff8d1 Merge branch 'main' into optimize_mul_many
# Conflicts:
#	src/gates/arithmetic.rs
2021-07-21 17:47:38 +02:00
wborgeaud
6e305f0a3e Change {add|mul}_many and cube 2021-07-21 17:41:22 +02:00
wborgeaud
d870a36dee {add|mul}_three_extension 2021-07-21 17:29:05 +02:00
Daniel Lubarov
eb18c7ea33
Faster witness generation (#116)
Saves ~300ms in the test. The main change is to have generators return fixed-size `Vec`s instead of `HashMap`s, which have more overhead.
2021-07-21 08:26:34 -07:00
wborgeaud
b59d497964 Modify ArithmeticExtensionGate to support 32 wires 2021-07-21 17:20:08 +02:00
wborgeaud
8642a10fde Start of optimization 2021-07-21 15:58:15 +02:00
Daniel Lubarov
ac1872a8c8
FRI tweaks (#111)
- Call `exp_power_of_2` instead of manual squaring
- Replace `evaluations[i]` with `evals`
2021-07-20 12:49:02 -07:00
Daniel Lubarov
35c8643681 Tiny cleanup 2021-07-18 23:31:21 -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
Daniel Lubarov
9c17a00c00
Division related changes (#99)
* Division related changes

- Simplify `div_unsafe_extension` using virtual targets
- Add methods for inversion and safe division

As a followup I'll switch some calls to safe division.

* Test safe division also

* add_virtual_extension_target
2021-07-18 23:05:57 -07:00
wborgeaud
097413479e PR feedback 2021-07-18 10:35:42 +02:00