From 901793bb796b0c731dc4036b9cfdc359e2e9202b Mon Sep 17 00:00:00 2001 From: zero Date: Wed, 10 Jan 2024 08:53:39 +0100 Subject: [PATCH] spec2: vote nullifiers and finish dao model page --- doc/src/spec2/contracts/dao/model.md | 32 ++++++++++++++++++++++------ doc/src/spec2/crypto-schemes.md | 6 +++++- src/contract/test-harness/src/lib.rs | 4 ++-- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/doc/src/spec2/contracts/dao/model.md b/doc/src/spec2/contracts/dao/model.md index bea6c0113..111011fb9 100644 --- a/doc/src/spec2/contracts/dao/model.md +++ b/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)) $$ -## Proposal +## Proposals + +### 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`. + +### 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) $$ diff --git a/doc/src/spec2/crypto-schemes.md b/doc/src/spec2/crypto-schemes.md index d9d1ed8e2..27f83d22c 100644 --- a/doc/src/spec2/crypto-schemes.md +++ b/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 diff --git a/src/contract/test-harness/src/lib.rs b/src/contract/test-harness/src/lib.rs index 9d9999f0f..f6ae2dd2d 100644 --- a/src/contract/test-harness/src/lib.rs +++ b/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,