diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f3ad47..f3951a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,3 +18,14 @@ jobs: - uses: actions/checkout@v4 - name: Clippy run: cargo clippy --all-targets --all-features + typos: + if: github.event.pull_request.draft == false + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use typos with config file + uses: crate-ci/typos@master + with: + config: .github/workflows/typos.toml + diff --git a/.github/workflows/typos.toml b/.github/workflows/typos.toml new file mode 100644 index 0000000..30e6074 --- /dev/null +++ b/.github/workflows/typos.toml @@ -0,0 +1,2 @@ +[default.extend-words] +groth = "groth" diff --git a/Cargo.toml b/Cargo.toml index 8463605..e5ef798 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,9 +26,7 @@ rand_core = {version = "0.6", default-features = false} base64 = "0.22.1" folding-schemes = { git = "https://github.com/privacy-scaling-explorations/sonobe", package = "folding-schemes", features=["light-test"], rev="c6f1a246e0705582a75de6becf4ad21f325fa5a1"} -# folding-schemes = { path = "../sonobe/sonobe_FCIRCUIT-EXTERNALINPUTS-TO-VEC/folding-schemes", package = "folding-schemes", features=["light-test"]} arkeddsa = { git = "https://github.com/arnaucube/arkeddsa", features=["r1cs"], rev="0a9ea7ac1df07363af0fda723e313e775563b9f4"} -# arkeddsa = { path = "../arkeddsa_TE-to-C", features=["r1cs"]} blake2 = "0.10" diff --git a/README.md b/README.md index 94c2944..4814bb0 100644 --- a/README.md +++ b/README.md @@ -24,21 +24,50 @@ So for example, in the previous diagram: - $pk_3$ is 3 degrees of distance from $pk_0$ - $pk_3$ has signed $pk_2$, who has signed $pk_1$, who has signed $pk_0$ - $pk_B$ is 4 degrees of distance from $pk_0$ - - $pk_B$ has signed $pk_A$, who has signed $pk_2$, who has signed $pk_2$, who has signed $pk_1$ + - $pk_B$ has signed $pk_A$, who has signed $pk_2$, who has signed $pk_1$, who has signed $pk_0$ - $pk_\beta$ is 3 degrees of distance from $pk_0$ - $pk_\beta$ has signed $pk_\alpha$, who has signed $pk_1$, who has signed $pk_0$ -With folding schemes, we can map those relations into an IVC model, where at each recursive step we're proving the [`FCircuit` relation](https://github.com/arnaucube/ethdos-fold/blob/main/src/fcircuit.rs) (key part: the method `EthDosCircuit.generate_step_constraints`). +With folding schemes, we can map those relations into an IVC model, where at each recursive step we're proving the [`FCircuit` relation](https://github.com/arnaucube/ethdos-fold/blob/main/src/fcircuit.rs) (key part: the method `EthDosCircuit.generate_step_constraints`), which ensures that the new state ($s_{i+1}$) comes from the previous state ($s_i$) with the verification of the new signature of the $pk_{i+1}$ over the previous public key $pk_i$. -The *state* of the IVC is $s_i = [pk_0, pk_i, i]$, where $pk_i$ is the public key $i$ degrees of distance from $pk_0$. At each step $i$ we have the IVC proof $\pi_i$, which proves this relation. +![](img/ethdos-fcircuit.png) + +The *state* of the IVC is $s_{i+1} = [pk_0, pk_{i+1}, i+1]$, where $pk_i$ is the public key $i$ degrees of distance from $pk_0$, and $pk_{i+1}$ is $i+1$ degrees of distance from $pk_0$. At each step $i$ we have the IVC proof $\pi_i$, which proves this relation. + +The following diagram shows the relation between the states and signatures at each folding step, showing also divergent paths. ![](img/ethdos-states-diagram.png) Each new folding step, only needs to have the previous step's state ($s_i = [pk_0, pk_i, i]$) and the respective IVC proof ($\pi_i$), which proves that the given public key $pk_i$ is $i$ degrees of distance from the public key $pk_0$. -A new recursive step is done from the $\pi_i$ and the $s_i$, and by inputing the new signature $sig_{pk_{i+1}}(pk_i)$, which is at degree of distance $i+1$ from $pk_0$. +A new recursive step is done from the $\pi_i$ and the $s_i$, and by inputting the new signature $sig_{pk_{i+1}}(pk_i)$, which is at degree of distance $i+1$ from $pk_0$. + +Notice that in order to generate the proof of relations between different public keys, it is not necessary to know any of their private keys, but just by knowing their public keys and having their signatures suffices to generate the proofs. So for example the signatures could be publicly accessible, and any user could just fetch them to generate their specific proofs of degrees of distance from other keys. + + +## Code structure + +As you can see, thanks to the simplicity & modularity of Sonobe and arkworks, this whole implementation reduces to defining the [`FCircuit` trait](https://github.com/arnaucube/ethdos-fold/blob/main/src/fcircuit.rs), which takes less than 70 lines of code, the key part being the method `generate_step_constraints` which takes <40 lines of code. + +Additionally, we can swap between folding schemes: + +With Sonobe we define the Folding Scheme being used at the line (file `src/lib.rs`): +```rust +type FS = Nova, Pedersen>; +``` +which we could switch it to use HyperNova, is as simple as updating the previous line to: + +```rust +type FS = HyperNova< G1, G2, FC, Pedersen, Pedersen, 1, 1>; +``` + +similarly we can switch to using ProtoGalaxy folding scheme: +```rust +type FS = ProtoGalaxy, Pedersen>; +``` -Notice that in order to generate the proof of relations between different public keys, it is not necessary to know any of their private keys, but just by knowing their public keys and having their signatures suffices to generate the proofs. +And the rest of the code would remain the same, while using a completely different folding scheme. +We can also use any arkworks available cycle of curves at the `G1` and `G2`, the current implementation uses BN254 and Grumpkin curves, since we're verifying EdDSA signatures over the BabyJubJub curve. ## Some numbers diff --git a/img/ethdos-fcircuit.png b/img/ethdos-fcircuit.png new file mode 100644 index 0000000..8b904b1 Binary files /dev/null and b/img/ethdos-fcircuit.png differ diff --git a/index.html b/index.html index c136822..fbb0e16 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,6 @@ ETHdos fold -