Commit graph

7 commits

Author SHA1 Message Date
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
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