Aard custom (#49)

* Merge changes to docs

* Fix typo

* Correct SUMMARY so it compiles; update .gitignore

* Clean up statements.md

Make syntax and notation consistent with Rust source code.

* Fix statements for Merkle trees and compound types

* First draft of custom statements and small updates to signedpod.md

* Update book/src/merkletree.md

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

* merklestatements correct typo

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

* add todo for gadget ids

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

* Separate out custom statements version 1

* More details on custom statements version 1

* new file custom2

* Partial draft of version 2

* First draft of version 2 spec, it's kind of a mess

* Another version of the custom predicates spec

* Update book/src/custom2.md

Co-authored-by: Eduard S. <eduardsanou@posteo.net>

* Simple example of deduction rule applied in circuit

* Implement Edu's comments on custom predicates

* Backend predicates must be defined in groups

* Add more examples

* Two diff statements using same constant

* Remove deprecated example

---------

Co-authored-by: Ahmad Afuni <root@ahmadafuni.com>
Co-authored-by: Eduard S. <eduardsanou@posteo.net>
This commit is contained in:
tideofwords 2025-02-24 09:05:30 -08:00 committed by GitHub
parent c101d94530
commit d3bc892906
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 543 additions and 0 deletions

View file

@ -136,3 +136,96 @@ statement is_great_boy(great_boy: PubKey, good_boy_issuers: MerkleTree):
# good boy 0 != good boy 1
- neq(friend_pod_0.signer, friend_pod_1.signer)
```
## Attested GreatBoy
An Attested Great Boy Pod is like a Great Boy Pod, but the names of the signers are revealed.
```
statement is_great_boy(great_boy: PubKey, friend0: String, friend1: String, good_boy_issuers: MerkleTree):
- OR():
- AND(friend_pod_0: Pod, friend_pod_1: Pod):
# Two good boys consider this user their friend
- is_friend(friend_pod_0.signer, great_boy)
- is_friend(friend_pod_1.signer, great_boy)
# good boy 0 != good boy 1
- neq(friend_pod_0.signer, friend_pod_1.signer)
# publicize signer names
- value_of(friend_pod_0.name, friend0)
- value_of(friend_pod_1.name, friend1)
```
To produce a Great Boy Pod, you need two Friend Pods, `friend_pod0` and `friend_pod1`, each of which reveals its `signer`.
## Tracking PodIDs: Posts and comments
The goal of this example is to model a social network, where posts and comments are pods.
A Post is a signature pod with the following fields:
```
content: String
poster: String
signer: PubKey
timestamp: Int
```
A Comment is a signature pod with the following fields:
```
content: String
referenced_post: PodID
signer: PubKey
timestamp: Int
```
A post is popular if it has at least two comments from different signers.
```
statement is_popular(post: PodID):
- AND():
- IsEqual(comment1.referenced_post, post)
- IsEqual(comment2.referenced_post, post)
- NotEqual(comment1.signer, comment2.signer)
```
## Multiple people over 18
Suppose I want to prove that two different people are over 18, and a third person is under 18, using the custom predicates `over_18` and `under_18`.
```
statement over_18(age):
- AND():
- ValueOf(eighteen, 18)
- GEq(age, eighteen)
```
```
statement under_18(age):
- AND():
- ValueOf(eighteen, 18)
- Lt(age, eighteen)
```
With wildcards:
```
statement over_18(*1, *2):
- AND():
- ValueOf(*3, *4, 18)
- GEq(*1, *2, *3, *4)
```
Maybe I have two input pods `gov_id1` and `gov_id2`, and I want to prove that these pods refer to two different people, both of whom are over 18; and a third pods `gov_id3` refers to someone under 18. So in my public output statements, I want to have:
```
IsUnequal(gov_id1.name, gov_id2.name)
over_18(gov_id1.age)
over_18(gov_id2.age)
under_18(gov_id3.age).
```
I would prove this with the following sequence of deductions:
| Statement | Reason |
| --- | --- |
| ValueOf(local_eighteen, 18) | (new entry) |
| over_18(gov_id1.age) | over_18, <br> *1 = _SELF, <br> *2 = "local_eighteen", <br> *3 = gov_id1, <br> *4 = "age" |
| over_18(gov_id2.age) | over_18, <br> *1 = _SELF, <br> *2 = "local_eighteen", <br> *3 = gov_id2, <br> *4 = "age" |
| under_18(gov_id3.age) | under_18, <br> *1 = _SELF, <br> *2 = "local_eighteen", <br> *3 = gov_id3, <br> *4 = "age" |
| IsUnequal(gov_id1.name, gov_id2.name) | (is unequal from entries) |