Commit Graph

70 Commits

Author SHA1 Message Date
chriseth
b7f89d9d45 Add degree checks. (#1370)
Co-authored-by: Leo <leo@powdrlabs.com>
2024-05-13 08:32:31 +00:00
Georg Wiese
7617be2b98 Add std::math::fp2 module (#1310)
Depends on #1346

Adds a module to the standard library to implement extension field
arithmetic. This should work and be correct on both the Goldilocks and
BN254 field. Needed for #1306.

---------

Co-authored-by: chriseth <chris@ethereum.org>
2024-05-10 16:17:29 +00:00
chriseth
bd422befcf Use true/false from the prelude. (#1367) 2024-05-10 10:52:30 +00:00
chriseth
3e43e33796 Constr as user-defined enum (#1252)
Turns some of the built-in types into user types in the prelude.
2024-05-01 10:29:19 +00:00
chriseth
88946edfa5 Make query functions enum-exhaustive. (#1327) 2024-04-30 17:59:41 +00:00
Georg Wiese
52148be547 Add std::field::known_field() (#1328)
Similar to what we have in Rust, this adds a function that detects
"known" fields (Goldilocks and BN254 for now). Planning to use that in
#1310 to assert that the field extension module is only used with
compatible fields.
2024-04-30 14:19:01 +00:00
chriseth
880aed444d The prelude (#1329)
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2024-04-30 12:19:54 +00:00
chriseth
75968f286a Btree data structure (#1299)
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2024-04-30 09:40:58 +00:00
chriseth
2b63dd8032 Add degree builtin. (#1259) 2024-04-29 12:08:26 +00:00
Leandro Pacheco
cea207ff3f Machine properties using with syntax (#1267)
This implements issue #1251.
Basically `machine Foo(a,b) { ... }` is now `machine Foo with latch: a,
operation_id: b { ... }`
2024-04-25 16:02:01 +00:00
Georg Wiese
46e8bb8ee5 Move STD machines into submodule (#1201)
Moves all machines in the standard library to `std::machines`. That way,
it is separated from the PIL utilities in STD.
2024-04-25 12:14:33 +00:00
Georg Wiese
a917e4f35a Add permutation to PIL STD (#1297)
First part of #1296 

This PR adds a `permutation()` function to the standard library. The
code is inspired by the `permutation_via_challenges` test (removed now),
[this
comment](https://github.com/powdr-labs/powdr/issues/424#issuecomment-1931686047)
by @chriseth and [this Halo2
implementation](https://github.com/privacy-scaling-explorations/halo2/blob/main/halo2_proofs/examples/shuffle.rs).
2024-04-25 07:32:35 +00:00
Steve Wang
056630049b keccak.asm (#1231)
Adapted from:
https://github.com/Zokrates/ZoKrates/blob/develop/zokrates_stdlib/stdlib/hashes/keccak/keccak.zok

Line reference comments are for the .zok file linked above.
2024-04-24 15:12:58 +00:00
chriseth
13e5084315 Sort. (#1254)
Needs generic enums.
2024-04-23 22:19:08 +00:00
chriseth
4cea357d11 More flexible print. (#1257) 2024-04-05 17:21:03 +00:00
chriseth
6096afb218 Patterns in let statements and function parameters (#1214)
Co-authored-by: Leo <leo@powdrlabs.com>
2024-04-03 18:39:19 +00:00
chriseth
f46d59dfe1 Basic version of patterns. (#1205)
Depends on #1187 

Implements part of https://github.com/powdr-labs/powdr/issues/982

Will document in https://github.com/powdr-labs/powdr/pull/1214
2024-04-03 09:30:42 +00:00
chriseth
28f0bb9c1d Statements in blocks and function annotations (#1187)
Adds statements at block level and introduces function kinds to be
either pure, constr or query.

closes https://github.com/powdr-labs/powdr/issues/960

---------

Co-authored-by: Leo <leo@powdrlabs.com>
2024-04-02 08:23:39 +00:00
Georg Wiese
96893cc143 Add Write-once memory to STD (#1202)
Fixes #844

This PR adds a new machine to the STD: `WriteOnceMemory`. This can be
used in our RISC-V machine for bootloader inputs (#1203).

Most of the issues mentioned in the issue were fixed in the meantime or
had a simple workaround (like defining `let LATCH = 1`). The only
remaining issues were in the machine detection, which I fixed here.

I also re-factor two existing tests.
2024-03-26 18:50:30 +00:00
chriseth
f42ca35f83 Let statements in expressions. (#1138)
Allows braced blocks everywhere where expressions are expected.
The statements in those blocks can be `let x` or `let x = ...`.
The former declares a new witness column, the latter just binds a local
variable.

fixes #959
2024-03-25 21:08:45 +00:00
Georg Wiese
a18577fed2 Add read/write memory to standard library (#1129)
With the recent changes by @pacheco, we can extract our [memory
machine](https://github.com/powdr-labs/powdr/blob/main/riscv/src/compiler.rs#L687-L841)
as a separate machine and add it to the standard library.

The result should be the same as calling the function linked above with
`with_bootloader=false`, except that the memory alignment stuff is not
inlined. For this reason, the machine is not yet used by the RISC-V
machine, but it could be after #1077 is implemented.

[This](eb320dca0c) shows the diff from
what we have in `compiler.rs`.

<!--

Please follow this protocol when creating or reviewing PRs in this
repository:

- Leave the PR as draft until review is required.
- When reviewing a PR, every reviewer should assign themselves as soon
as they
start, so that other reviewers know the PR is covered. You should not be
discouraged from reviewing a PR with assignees, but you will know it is
not
  strictly needed.
- Unless the PR is very small, help the reviewers by not making forced
pushes, so
that GitHub properly tracks what has been changed since the last review;
use
  "merge" instead of "rebase". It can be squashed after approval.
- Once the comments have been addressed, explicitly let the reviewer
know the PR
  is ready again.

-->
2024-03-25 17:33:55 +00:00
Georg Wiese
10aeae6cb5 Allow and use permutation in all std machines 2024-03-21 17:20:18 +01:00
chriseth
e1753fd88e Challenges and stages. 2024-03-20 12:40:51 +01:00
Leo Alt
efe11f40fc enum declarations 2024-03-18 22:09:44 +01:00
Georg Wiese
3f863b77a0 Fix hints in split machines 2024-03-18 17:12:44 +01:00
Georg Wiese
f87a760071 Hints for arithmetic machine 2024-03-18 11:57:40 +01:00
chriseth
78d87a8b9c Document and test conversion to expr. 2024-03-14 13:16:36 +01:00
chriseth
dc96509070 Make expressions and constraints native values. 2024-03-05 11:22:12 +01:00
chriseth
97ed14c48b Type checking. 2024-03-01 17:36:54 +01:00
Leo
41d856c698 Merge pull request #1068 from powdr-labs/poseidon-latch-first-row
Poseidon Machines: Change latch to be on first row
2024-02-27 12:49:28 +00:00
Georg Wiese
39ab430595 For block machines, don't generate constraints on operation ID 2024-02-27 09:09:28 +01:00
Georg Wiese
f2c6caa991 Poseidon Machines: Change latch to be on first row 2024-02-26 11:59:36 +01:00
chriseth
ed6b4d8ebf Merge pull request #1067 from powdr-labs/refactor-poseidon-gl
Refactor PoseidonGL machine
2024-02-26 10:47:37 +00:00
chriseth
daffb65c0c Add type schemes. 2024-02-22 13:39:39 +01:00
Georg Wiese
e82d6f5249 Refactor PoseidonGL machine 2024-02-21 14:11:16 +01:00
Georg Wiese
d5825738f3 PoseidonBN254: Use intermediate polynomials instead of witness columns 2024-02-21 12:24:01 +01:00
Leo
1485f50cf6 Merge pull request #1058 from powdr-labs/update_utils
Some more uses of cross_product
2024-02-19 10:48:09 +00:00
Georg Wiese
aa3955801c Refactor PoseidonBN254 2024-02-15 18:15:08 +01:00
chriseth
e644be4d39 Update utils. 2024-02-14 16:52:30 +01:00
Georg Wiese
076f7b5129 Improve error message in std::math::ff:inverse 2024-02-14 13:12:46 +01:00
chriseth
259f35d4ac Merge pull request #1031 from powdr-labs/split_bits
cross product utility function.
2024-02-09 15:31:21 +00:00
chriseth
b04439d405 cross_product utility function. 2024-02-09 09:42:38 +01:00
chriseth
f4113cbb32 Adjust arith.asm. 2024-02-09 08:18:04 +01:00
Georg Wiese
40fe394c19 Add equations 1-4 2024-02-08 11:41:53 +01:00
chriseth
8f6cd49969 Introduce identity operator. 2024-02-07 16:04:55 +01:00
chriseth
31e4c1ad97 Support arrays of fixed columns. 2024-02-07 11:55:16 +01:00
Georg Wiese
9ea67369ce Arithmetic machine: Add equation selectors 2024-02-06 16:55:20 +01:00
chriseth
2765e59a9f Add types. 2024-02-06 10:25:04 +01:00
chriseth
fc15d92744 Modular operations. 2024-02-01 12:13:12 +01:00
Georg Wiese
321edb891f Merge pull request #967 from powdr-labs/arith-eq0
Arith machine, Equation 0
2024-02-01 10:36:02 +00:00