feat: move code here (#11)

This commit is contained in:
Eduard S. 2025-01-31 16:20:57 +01:00 committed by GitHub
parent 5bb98e2645
commit ef3dd308e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 889 additions and 10 deletions

1
book/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
book

10
book/README.md Normal file
View file

@ -0,0 +1,10 @@
# pod2-docs
> Hackmds for sharing ideas, once there is consensus around it, move it into this repo to consolidate it. Also we can use PRs to discuss asynchronously specific ideas of the spec.
## Usage
A rendered version of the site can be found at: https://0xparc.github.io/pod2-docs/
To run it locally:
- Needs [mdbook](https://github.com/rust-lang/mdBook), to install: `cargo install mdbook`
- Needs [mdbook-katex](https://github.com/lzanini/mdbook-katex), to install: `cargo install mdbook-katex`
- Run locally: `mdbook serve`

6
book/book.toml Normal file
View file

@ -0,0 +1,6 @@
[book]
authors = ["0xPARC"]
language = "en"
multilingual = false
src = "src"
title = "POD2-docs"

15
book/src/SUMMARY.md Normal file
View file

@ -0,0 +1,15 @@
# Summary
- [Introduction](./introduction.md)
# Specification
- [Data types](./datatypes.md)
- [MerkleTree](./merkletree.md)
- [Deductions](./deductions.md)
- [Statements](./statements.md)
- [Operations](./operations.md)
- [POD types](./podtypes.md)
- [SignedPOD](./signedpod.md)
- [MainPOD](./mainpod.md)
- [MockPOD](./mockpod.md)
- [Examples](./examples.md)

1
book/src/datatypes.md Normal file
View file

@ -0,0 +1 @@
# Data types

1
book/src/deductions.md Normal file
View file

@ -0,0 +1 @@
# Deductions

128
book/src/examples.md Normal file
View file

@ -0,0 +1,128 @@
# Examples
Examples of POD2 use cases
## EthDos
Original in prolog https://gist.github.com/ludns/f84b379ec8c53c97b7f95630e16cc39c#file-eth_dos-pl
An EthDos Pod exposes a single custom statement with two custom deduction
rules, the inductive case and the base case.
```
statement eth_dos_distance(src: PubKey, dst: PubKey, distance: Int):
- OR():
- AND(attestation_pod: Pod, intermediate: PubKey, n: int):
- eq(attetation_pod.attestation, dst)
- eq(attetation_pod.type, SIGNATURE)
- sum_of(distance, 1, n)
- eth_dos_distance(src, attetation_pod.signer, n)
- AND():
- eq(src, dst)
- eq(distance, 0)
```
## ZuKYC (classic)
Original using GPC https://github.com/proofcarryingdata/zukyc
Authority public keys:
- `ZOO_GOV`: PubKey, issues IDs
- `ZOO_DEEL`: PubKey, issues bank statements
Authority lists:
- `SANCTION_LIST`: Hash, Merkle Tree Root of set of sanctioned public keys
- values: `["G2345678", "G1987654", "G1657678"]`
Date values:
- `NOW_MINUS_18Y`: Int, 18 years ago
- `NOW_MINUS_1Y`: Int, 1 year ago
- `NOW_MINUS_7D`: Int, 7 days ago
A ZuKYC Pod exposes a single custom statement with one custom deduction rule.
```
statement loan_check(receiver: PubKey):
- OR():
- AND(gov_id: Pod, paystub: Pod):
- eq(gov_id.pk, receiver)
# Not in the sanction list
- does_not_contain(SANCTION_LIST, gov_id.pk)
# Valid government-issued ID
- eq(gov_id.signer, ZOO_GOV)
- eq(gov_id.type, SIGNATURE)
# At least 18 years old
- lt(gov_id.date_of_birth, NOW_MINUS_18Y) # date_of_birdth is more than 18y old
- eq(paystub.signer, ZOO_DEEL)
- eq(paystub.type, SIGNATURE)
- eq(paystub.ssn, gov_id.ssn)
# At least one year of consistent employment with your current employer
- lt(paystub.start_date, NOW_MINUS_1Y) # start_date is more than 1y old
- gt(paystub.issue_date, NOW_MINUS_7D) # issue_date is less than 7d old
# Annual salary is at least $20,000
- gt(paystub.anual_salary, 20000)
```
## ZuKYC (simplified for P1)
This simplified version uses less statements but requires a very similar set of
features.
Authority lists:
- `SANCTION_LIST`: Hash, Merkle Tree Root of set of sanctioned public keys
- values: `["G2345678", "G1987654", "G1657678"]`
Date values:
- `NOW_MINUS_18Y`: Int, 18 years ago
- `NOW_MINUS_1Y`: Int, 1 year ago
A ZuKYC Pod exposes a single custom statement with one custom deduction rule.
```
statement loan_check(receiver: string):
- OR():
- AND(gov_id: Pod, paystub: Pod):
- eq(gov_id.id_number, receiver)
# Not in the sanction list
- does_not_contain(SANCTION_LIST, gov_id.id_number)
# Valid government-issued ID
- reveal(gov_id.signer)
- eq(gov_id.type, SIGNATURE)
# At least 18 years old
- lt(gov_id.date_of_birth, NOW_MINUS_18Y) # date_of_birdth is more than 18y old
- reveal(paystub.signer)
- eq(paystub.type, SIGNATURE)
- eq(paystub.ssn, gov_id.ssn)
# At least one year of consistent employment with your current employer
- lt(paystub.start_date, NOW_MINUS_1Y) # start_date is more than 1y old
```
## GreatBoy
A Good Boy Pod exposes one custom statement with one custom deduction rule.
```
statement good_boy(receiver: PubKey, good_boy_issuers: MerkleTree):
- OR():
- AND(pod: Pod):
# A good boy issuer is my friend
- eq(pod.type, SIGNATURE)
- contains(good_boy_issuers, pod.signer)
- eq(pod.friend, receiver)
```
A Great Boy Pod exposes (in addition to the above) one new custom statement
with one custom deduction rule.
```
statement great_boy(receiver: PubKey, good_boy_issuers: MerkleTree):
- OR():
- AND(friend_pod_0: Pod, friend_pod_1: Pod):
# good boy 0 is my friend
- eq(friend_pod_0.type, SIGNATURE)
- good_boy(friend_pod_0.signer, good_boy_issuers)
- eq(friend_pod_0.friend, receiver)
# good boy 1 is my friend
- eq(friend_pod_1.type, SIGNATURE)
- good_boy(friend_pod_1.signer, good_boy_issuers)
- eq(friend_pod_1.friend, receiver)
# good boy 0 != good boy 1
- neq(friend_pod_0.signer, friend_pod_1.signer)
```

1
book/src/introduction.md Normal file
View file

@ -0,0 +1 @@
# Introduction

1
book/src/mainpod.md Normal file
View file

@ -0,0 +1 @@
# MainPOD

1
book/src/merkletree.md Normal file
View file

@ -0,0 +1 @@
# MerkleTree

1
book/src/mockpod.md Normal file
View file

@ -0,0 +1 @@
# MockPOD

1
book/src/operations.md Normal file
View file

@ -0,0 +1 @@
# Operations

1
book/src/podtypes.md Normal file
View file

@ -0,0 +1 @@
# POD types

1
book/src/signedpod.md Normal file
View file

@ -0,0 +1 @@
# SignedPOD

1
book/src/statements.md Normal file
View file

@ -0,0 +1 @@
# Statements