Просмотр исходного кода

spec2: vote nullifiers and finish dao model page

zero 2 лет назад
Родитель
Сommit
901793bb79

+ 26 - 6
doc/src/spec2/contracts/dao/model.md

@@ -1,6 +1,8 @@
 # Model
 
-Let $ℙₚ, 𝔽ₚ, \mathcal{X}, \mathcal{Y}$ be defined as in the section [Pallas and Vesta](../../crypto-schemes.md#pallas-and-vesta).
+Let $\t{Bulla}$ be defined as in the section [Bulla Commitments](../../crypto-schemes.md#bulla-commitments).
+
+Let $ℙₚ, 𝔽ₚ, \mathcal{X}, \mathcal{Y}, \t{𝔹³²2𝔽ₚ}$ be defined as in the section [Pallas and Vesta](../../crypto-schemes.md#pallas-and-vesta).
 
 ## DAO
 
@@ -33,10 +35,12 @@ class $[\frac{q}{d}]$ of fractions defined by $q₁d₂ = q₂d₁ ⟺  [\frac{q
 {{#include ../../../../../src/contract/dao/src/model.rs:dao}}
 ```
 
-$$ \t{DAO2𝔽ₚ} : \t{Params}_\t{DAO} → 𝔽ₚ⁷ $$
-$$ \t{DAO2𝔽ₚ}(p) = (\t{ℕ₆₄2𝔽ₚ}(p.L), \t{ℕ₆₄2𝔽ₚ}(p.Q), \t{ℕ₆₄2𝔽ₚ}(p.A^\%), p.T, \mathcal{X}(p.PK), \mathcal{Y}(p.PK)) $$
+$$ \t{Bulla}_\t{DAO} : \t{Params}_\t{DAO} → 𝔽ₚ $$
+$$ \t{Bulla}_\t{DAO}(p) = \t{Bulla}(ℕ₆₄2𝔽ₚ(p.L), ℕ₆₄2𝔽ₚ(p.Q), ℕ₆₄2𝔽ₚ(p.A^\%), p.T, \mathcal{X}(p.PK), \mathcal{Y}(p.PK)) $$
+
+## Proposals
 
-## Proposal
+### Auth Calls
 
 Let $\t{FuncId}$ be defined as in [Function IDs](../../concepts.md#function-ids).
 
@@ -49,8 +53,11 @@ contract to enforce additional invariants.
 {{#include ../../../../../src/contract/dao/src/model.rs:dao-auth-call}}
 ```
 
-Define $\t{Commit}_\t{Auth} : \t{AuthCall} → 𝔽ₚ$ by.
-$$ \t{Commit}_\t{Auth}(c) = 𝔹³²2𝔽ₚ(\t{BLAKE3}(\t{Encode}(c))) $$
+Define $\t{Commit}_\t{Auth} : \t{AuthCall}^* → 𝔽ₚ$ by
+$$ \t{Commit}_{\t{Auth}^*}(c) = 𝔹³²2𝔽ₚ(\t{BLAKE3}(\t{Encode}(c))) $$
+which commits to a `Vec<DaoAuthCall>`.
+
+### Proposal
 
 Define the proposal params
 $$ \begin{aligned}
@@ -65,5 +72,18 @@ $$ \begin{aligned}
 {{#include ../../../../../src/contract/dao/src/model.rs:dao-proposal}}
 ```
 
+$$ \t{Bulla}_\t{Proposal} : \t{Params}_\t{Proposal} → 𝔽ₚ⁵ $$
+$$ \t{Bulla}_\t{Proposal}(p) = (\t{Commit}_{\t{Auth}^*}(p.C), ℕ₆₄2𝔽ₚ(p.T₀), ℕ₆₄2𝔽ₚ(p.D), p.φ, p.\t{DAO}) $$
+
 ## Vote Nullifiers
 
+Additionally for proposals, we keep track of nullifiers for each token weighted
+vote for or against a proposal.
+
+Let $\mathcal{C}$ be the coin params, and $C$ be the coin commitment
+as defined in [Money Contract](TODO).
+
+Let $P$ be a proposal bulla as in the section [Proposal](#proposal).
+
+Define $\t{Nullifier}_\t{Vote} : 𝔽ₚ × 𝔽ₚ × 𝔽ₚ → 𝔽ₚ$ as follows:
+$$ \t{Nullifier}_\t{Vote}(\mathcal{C}.s, C, P) = \t{PoseidonHash}(\mathcal{C}.s, C, P) $$

+ 5 - 1
doc/src/spec2/crypto-schemes.md

@@ -71,7 +71,11 @@ Likewise there is no $P = (x, 0) ∈ Eₚ$ so $\mathcal{Y}(P) = 0 ⟹  P = ∞$.
 
 ### Encoding and Decoding for $𝔽ₚ$
 
-TODO: define $\t{Encode}_{𝔽ₚ} : 𝔽ₚ → 𝔹³²$.
+Define $𝔽ₚ2𝔹³² : 𝔽ₚ → 𝔹³²$ as encoding the canonical representation
+of $𝔽ₚ$ in little endian byte format.
+
+Define $𝔹³²2𝔽ₚ : 𝔹³² → 𝔽ₚ$ as the matching decoding of $𝔽ₚ$ modulo
+the canonical class in little endian byte format.
 
 ## BLAKE3 Hash Function
 

+ 2 - 2
src/contract/test-harness/src/lib.rs

@@ -78,8 +78,8 @@ pub fn init_logger() {
     // We check this error so we can execute same file tests in parallel,
     // otherwise second one fails to init logger here.
     if simplelog::TermLogger::init(
-        //simplelog::LevelFilter::Info,
-        simplelog::LevelFilter::Debug,
+        simplelog::LevelFilter::Info,
+        //simplelog::LevelFilter::Debug,
         //simplelog::LevelFilter::Trace,
         cfg.build(),
         simplelog::TerminalMode::Mixed,