59 Commits

Author SHA1 Message Date
wborgeaud
bdbc8b6931 Merge branch 'main' into generic_configuration
# Conflicts:
#	src/field/extension_field/mod.rs
#	src/fri/recursive_verifier.rs
#	src/gadgets/arithmetic.rs
#	src/gadgets/arithmetic_extension.rs
#	src/gadgets/hash.rs
#	src/gadgets/interpolation.rs
#	src/gadgets/random_access.rs
#	src/gadgets/sorting.rs
#	src/gates/arithmetic_u32.rs
#	src/gates/gate_tree.rs
#	src/gates/interpolation.rs
#	src/gates/poseidon.rs
#	src/gates/poseidon_mds.rs
#	src/gates/random_access.rs
#	src/hash/hashing.rs
#	src/hash/merkle_proofs.rs
#	src/hash/poseidon.rs
#	src/iop/challenger.rs
#	src/iop/generator.rs
#	src/iop/witness.rs
#	src/plonk/circuit_data.rs
#	src/plonk/proof.rs
#	src/plonk/prover.rs
#	src/plonk/recursive_verifier.rs
#	src/util/partial_products.rs
#	src/util/reducing.rs
2021-12-16 14:54:38 +01:00
wborgeaud
a0b0a2d715 Move polynomial.rs to mod.rs 2021-11-30 20:17:34 +01:00
wborgeaud
2c06309cf7 Fix all clippy lints 2021-11-30 17:12:13 +01:00
wborgeaud
9cafe97731 Remove specific impls of InterpolationGate 2021-11-22 22:30:32 +01:00
wborgeaud
172fdd3d89 Comments 2021-11-22 21:20:44 +01:00
wborgeaud
6aaea002ed Choose between high- and low-degree interpolation gate depending on the arity 2021-11-22 16:10:14 +01:00
wborgeaud
8522026c36 Change file structure 2021-11-22 11:39:56 +01:00
wborgeaud
442c8560b0 Under 2^12 with 27 query rounds 2021-11-22 11:16:58 +01:00
wborgeaud
0d5ba7e755 Working recursive test 2021-11-22 10:44:19 +01:00
wborgeaud
aec88a8528 First try 2021-11-19 18:11:14 +01:00
Daniel Lubarov
9b55ff9e81
edition = 2021 (#370)
* edition = 2021

Doesn't affect anything for us as far as I've noticed.

* imports
2021-11-17 14:43:54 -08:00
wborgeaud
0f06a01ac1 Merge conflicts 2021-11-08 10:49:14 +01:00
wborgeaud
c406432814 Merge branch 'main' into generic_configuration
# Conflicts:
#	src/gadgets/arithmetic.rs
#	src/gadgets/interpolation.rs
#	src/gates/interpolation.rs
2021-11-08 10:35:29 +01:00
Daniel Lubarov
671bb9be2e
Specialize InterpolationGate (#339)
* Specialize `InterpolationGate`

To cosets of subgroups of roots of unity. This way
- `InterpolationGate` needs fewer routed wires, bringing our minimum routed wires down from 28 to 25.
- The recursive `compute_evaluation` avoids some multiplications, saving 100~200 gates depending on `num_routed_wires`.

* Update test

* feedback
2021-11-05 09:29:08 -07:00
wborgeaud
c78d7611ed Unused imports 2021-11-05 16:47:29 +01:00
wborgeaud
7482e7b613 Remove RichField 2021-11-05 15:43:58 +01:00
wborgeaud
3d74abba8a [skip-ci]Clippy 2021-11-05 15:31:24 +01:00
wborgeaud
fb18232efd Generic config 2021-11-05 10:56:23 +01:00
Jakub Nabaglo
bc57a561e6 Delete CrandallField 2021-11-02 12:29:26 -07:00
Daniel Lubarov
b922def48e
Better errors for insufficient (routed) wires for FRI (#288)
For examlpe, if I change a test to use `ConstantArityBits(4, 5)`, I get

    To efficiently perform FRI checks with an arity of 16, at least 152 wires are needed. Consider reducing arity.
2021-10-05 23:28:04 -07:00
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
Daniel Lubarov
f89f49249a wip 2021-09-04 16:27:40 -07: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
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
5c96e7b366 Trivial fixes from "cargo fix" 2021-08-02 10:58:03 -07: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
2bbcf17699 Test eval_unfiltered_* functions 2021-08-02 14:17:42 +02: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
e382decc9f Import fixes 2021-07-29 11:45:58 -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
d8b8161cb9
Merge pull request #122 from mir-protocol/eval_unfilterd_base
Manually implement `eval_unfiltered_base` for all gates
2021-07-23 08:12:01 +02:00
wborgeaud
3a24e8f4c1 Manually implement eval_unfiltered_base for all gates 2021-07-22 14:00:55 +02:00
wborgeaud
b68be57615 Simplify interpolation test 2021-07-22 13:33:57 +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
Daniel Lubarov
b8ce1d1967
Public inputs (#113)
With this approach, we don't need `Target::PublicInput`; any routable `Target` can be marked as a public input via `register_public_input`.  The circuit itself hashes these targets, and routes the hash output to the first four wires of a `PublicInputGate`, which is placed at an arbitrary location in the circuit.

All gates have direct access to the purported hash of public inputs. We could think of them as accessing `PI_hash_i(x)` (as in Plonk), but these are now (four) constant functions, so they effectively have direct access to the hash itself.

`PublicInputGate` checks that its first four wires match this purported public input hash. The other gates ignore the hash.

Resolves #64.
2021-07-21 08:26:19 -07:00
wborgeaud
a4c86a6b08 lagrange.rs -> interpolation.rs 2021-06-18 11:44:06 +02:00
wborgeaud
b44a01c975 Merge main 2021-06-15 09:20:00 +02:00
wborgeaud
4ed03f4fb1 Fix InterpolationGenerator dependencies. 2021-06-11 19:06:12 +02:00
wborgeaud
5200d70cf0 Add interpolation gadgets 2021-06-11 16:22:29 +02:00
wborgeaud
9adf5bb43f Use ExtensionAlgebra + new CircuitBuilder::mul_extension 2021-06-09 10:51:50 +02:00
Daniel Lubarov
72c2e19bc5
Bit of verifier work (#54)
* Bit of verifier work

* Minor

* next_plonk_zs now available after William's changes
2021-06-08 21:23:52 -07:00
Daniel Lubarov
db1ef913e0 Remove quartic_quartic 2021-06-08 10:08:17 -07:00
wborgeaud
c674d6c1f6 Remove unused imports 2021-06-08 12:53:04 +02:00
wborgeaud
19a38682ab Minor tweaks 2021-06-08 12:49:45 +02:00
wborgeaud
070dc7c9f1 s/ext_ext/ext_algebra 2021-06-08 11:30:39 +02:00