Commit graph

117 commits

Author SHA1 Message Date
tideofwords
a37b96ab4f
Serialize and hash custom predicates (#90)
* Print pods from SignedPodBuilder

* Add additional print to test printing SignedPodBuilder

* Mock-prove and print MainPod

* Implement ToFields for custom predicates and dependencies

* Test: print serialization of a recursive batch

* Rearrange serialization of CustomPredicate so args_len is always in the same position

* Serialize predicates with first entry nonzero to avoid collision with padding

* Off by one error in ethdos test BatchSelf(2)

* cargo fmt

* not a typo

* Typos, trying again
2025-02-26 20:28:27 +01:00
Ahmad Afuni
05c21ebe6a
feat: partial incorporation of custom predicates into statement and operation structures in middleware (#84)
* Add custom predicates to middleware Statement enum

* Add custom op enum variant and wildcard matching procedures
2025-02-25 15:44:27 +01:00
arnaucube
538353a701
Frontend: simplify custom predicates interfaces (#83)
* add comments detailing logic, migrate middleware::custom::tests to frontend::custom

* simplify custom predicate's frontend interfaces, making it less verbose to define Statement Template arguments

The main idea is that when defining the arguments at a statement
template, it can be done from 3 different inputs:
i. `(&str, literal)`: this is to set a POD and a field, ie. `(POD, literal("field")`)
ii. `(&str, &str)`: this is to define a origin-key wildcard pair, ie. `(src_origin, src_dest)`
iii. `Value`: this is to define a literal value, ie. `0`
2025-02-25 14:15:08 +10:00
arnaucube
c101d94530
implement the specified sparse merkletree (#82)
* wip

* prototype custom predicates 1b

* feat: implement custom pred recursion

* files reorg, add github CI for rustfmt checks

* start sparsemerkletree. impl add_leaf method, initial Leaf & Intermediate types with methods

* mt: add hash computation of all the nodes in the tree, add method to print the tree to visualize it as a graphviz

* mt: add  (till the leaf) method which is used by get,contains,prove methods

* mt: add verify (of inclusion) method

* mt: update 'down' method to reuse siblings, update get,contains,prove methods (the three use 'down' under the hood)

* Add nonexistence proofs and iterator

* Add iterator test

* migrate usage of old merkletree to the new merkletree impl in POD2 code

---------

Co-authored-by: Eduard S. <eduardsanou@posteo.net>
Co-authored-by: Ahmad <root@ahmadafuni.com>
2025-02-21 11:13:58 +10:00
2e9719a1ca
Prototype custom predicates (#74)
* wip

* prototype custom predicates 1b

* feat: implement custom pred recursion

* files reorg, add github CI for rustfmt checks

---------

Co-authored-by: arnaucube <git@arnaucube.com>
2025-02-21 10:55:36 +10:00
Ahmad Afuni
c2d23b0b1b
chore: enums for statement and op types (#69)
* Experiment with statement & op enums

* Clean-up & fixes

* More clean-up

* Add argument length checks

* More clean-up

* Place statement and operation logic in submodules
2025-02-20 10:08:29 +01:00
Richard Liu
83a4f8969f
feat: add bool frontend type (#63) 2025-02-18 10:16:46 -08:00
1b6e0c9395
feat: unify SignedPod and MainPod traits (#64)
* feat: unify SignedPod and MainPod traits

* fix: test

* feat: enable workflows after draft
2025-02-18 13:00:54 +01:00
Richard Liu
452bda8087
small fixes for various todos (#62)
* todos for frontend

* mock_main todos

* have OperationArgError bubble up

* revert frontend.rs
2025-02-17 10:54:37 -08:00
arnaucube
bb865a4fea
Implement Containers (Dictionary,Set,Array) on top of MerkleTree. And restructure the code. (#55)
* Implement Containers (Dictionary,Set,Array) on top of MerkleTree. And restructure the code.

- Reorganize the code grouping backends, middleware, frontend, (crypto) primitives.
- Add types Dictionary,Set,Array at the middleware layer, so that
  it can be used both by the backend and frontend. The Dictionary, Set,
  Array use the merkletree differently as specified at
f2575d1524/book/src/values.md (dictionary-array-set)
	- The containers introduce the trait Container, which has the
	  method 'cm()'. At the current version this uses a merkletree
	  under the hood, and the method 'cm' returns the merkle root.
- Ideally neither frontend nor backend use the MerkleTree type, and they
  use the wrappers {Dictionary,Set,Array}. Note that the current commit
  the MerkleTree is used at the mock-backend to check internal values, but
  not at the struct types.
- updated the spec's merkletree section updating the defined interface
- add github ci to run the tests

---------

Co-authored-by: Ahmad Afuni <root@ahmadafuni.com>
Co-authored-by: Eduard S. <eduardsanou@posteo.net>
2025-02-12 12:06:40 +01:00
f2575d1524
Add great boy example (#48)
* Progress towards mock MainPod verification

* add MockMainPod.pub_statements logic so that when originid==SELF it is replaced by self.id()

* Basic op checking for mock MainPOD

* More op checking

* wip

* feat: add great boy example

* feat: put examples under cfg(test)

---------

Co-authored-by: Ahmad <root@ahmadafuni.com>
Co-authored-by: arnaucube <git@arnaucube.com>
2025-02-11 13:54:26 +01:00
Ahmad Afuni
90e9782e62
feat: Basic verification logic for mock MainPOD (#43)
* Progress towards mock MainPod verification

* add MockMainPod.pub_statements logic so that when originid==SELF it is replaced by self.id()

* Basic op checking for mock MainPOD

* More op checking

* Add TODO notes

---------

Co-authored-by: arnaucube <git@arnaucube.com>
2025-02-10 19:07:41 +01:00
arnaucube
5236b46214
Migrate fmt to use Display trait (#44)
Migrate fmt to use Display trait to simplify the usage of it.

Also with this, in the same snipped of code we can print types from
backend, middleware and frontend; which before needed to import the two
different `Printer` structs (frontend::Printer and mock_main::Printer).

Before:
```
let printer = mock_main::Printer { skip_none: false };
let mut w = io::stdout();
printer.fmt_mock_main_pod(&mut w, &pod).unwrap();

let printer = frontend::Printer { skip_none: false };
printer.fmt_main_pod_builder(&mut w, &pod_builder).unwrap();
```

now:
```
println!("{:#}", pod);
println!("{:#}", pod_builder);
```

And the equivalent to the old `skip_none: true`, now is done by just
using `println!("{}", pod);
2025-02-10 12:37:11 +01:00
arnaucube
ca1be65b85
compute MainPod.id from pub_statements; and introduce the trait ToFields (#35)
* compute MainPod.id from pub_statements; and introduce the trait `ToFields`

Compute MainPod.id from pub_statements hash; for it, introduce the trait
`ToFields` at the middleware and implement it for the Statement related
types.

* cleaner statements tofield iter

Co-authored-by: Ahmad Afuni <root@ahmadafuni.com>

---------

Co-authored-by: Ahmad Afuni <root@ahmadafuni.com>
2025-02-06 11:35:57 +01:00
8945d7f8a1
Partial implementation of the MockMainPod (#33)
* wip

* wip

* feat: handle public statements

* fix: remove old backend module
2025-02-05 16:50:00 +01:00
085d5fff2c
feat: integrate mt in mock_sign (#23)
* feat: integrate mt in mock_sign

* fix: handle compile error

* fix: use PodClass::Main in MainPod origin
2025-02-05 11:24:35 +01:00
3445bd98bd
feat: add middleware and signer traits (#18)
* feat: add middleware and signer traits

* wip

* wip

* feat: MainPod traits
2025-02-04 12:35:32 +01:00