فهرست منبع

spec: elgamal enc, cleanup use of subscripts

zero 2 سال پیش
والد
کامیت
98fd142aa4
2فایلهای تغییر یافته به همراه16 افزوده شده و 14 حذف شده
  1. 1 1
      doc/src/spec/contract/dao/scheme.md
  2. 15 13
      doc/src/spec/crypto-schemes.md

+ 1 - 1
doc/src/spec/contract/dao/scheme.md

@@ -14,7 +14,7 @@ Let $\t{Params}_\t{DAO}, \t{Bulla}_\t{DAO}, \t{Params}_\t{Proposal}, \t{Bulla}_\
 
 Let $\t{AeadEncNote}$ be defined as in [In-band Secret Distribution](../../crypto-schemes.md#in-band-secret-distribution).
 
-Let $\t{ElGamal.Encryptₙ}, \t{ElGamalEncNote}ₙ$ be defined as in the section [Verifiable In-Band Secret Distribution](../../crypto-schemes.md#verifiable-in-band-secret-distribution).
+Let $\t{ElGamal.Encrypt}, \t{ElGamalEncNote}ₖ$ be defined as in the section [Verifiable In-Band Secret Distribution](../../crypto-schemes.md#verifiable-in-band-secret-distribution).
 
 ## Mint
 

+ 15 - 13
doc/src/spec/crypto-schemes.md

@@ -277,11 +277,9 @@ Let $\t{PoseidonHash}$ be defined as in the section [PoseidonHash Function](#pos
 This scheme is verifiable inside ZK using the [Pallas and Vesta](#pallas-and-vesta) curves.
 
 Let $n ∈ ℕ$.
-Denote the plaintext space $N$ and ciphertext $C$ with $N = C = 𝔽ₚⁿ$.
-$$ \t{ElGamal}.\t{Encrypt}ₙ : N × 𝔽ₚ × ℙₚ → C × ℙₚ $$
-$$ \t{ElGamal}.\t{Decrypt}ₙ : C × 𝔽ₚ × ℙₚ → N $$
+Denote the plaintext space $Nₖ$ and ciphertext $Cₖ$ with $Nₖ = Cₖ = 𝔽ₚᵏ$ where $k ∈ ℕ$.
 
-Denote $\t{ElGamalEncNote}ₙ = (E, C)$ where $E$ is the space of *ephemeral
+Denote $\t{ElGamalEncNote}ₖ = (E, Cₖ)$ where $E$ is the space of *ephemeral
 public keys* and $C$ is the ciphertext space.
 
 See `ElGamalEncryptedNote` in `src/sdk/src/crypto/note.rs`.
@@ -289,7 +287,10 @@ See `ElGamalEncryptedNote` in `src/sdk/src/crypto/note.rs`.
 ### Encryption
 
 We let $P ∈ ℙₚ$ denote the recipient's public key.
-Let $\t{note} ∈ N = 𝔽ₚⁿ$ with $n ∈ ℕ$ denote the plaintext note to be encrypted.
+Let $𝐧 ∈ N$ denote the plaintext note to be encrypted.
+
+Define $\t{ElGamal}.\t{Encrypt} : Nₖ × 𝔽ₚ × ℙₚ → Cₖ × ℙₚ$
+by $\t{ElGamal}.\t{Encrypt}(𝐧, P)$ as follows:
 
 Let $\t{esk} ∈ 𝔽ₚ$ be the randomly generated *ephemeral secret key*.
 
@@ -299,31 +300,32 @@ Let $\t{shared\_secret} = \t{KeyAgree}(\t{esk}, P)$
 
 Let $k = \t{PoseidonHash}(\cX(\t{shared\_secret}), \cY(\t{shared\_secret}))$
 
-For $i ∈ [n]$ then compute:
+For $i ∈ [k]$ then compute:
 
   Let $bᵢ = \t{PoseidonHash}(k, i)$
 
   Let $cᵢ = \t{note}ᵢ + bᵢ$
 
-Return $𝐜 = (cᵢ) ∈ C$ and $\t{EPK}$
+Return $(𝐜, \t{EPK})$ where $𝐜 = (cᵢ)$
 
 ### Decryption
 
 We denote the recipient's secret key with $x ∈ 𝔽ₚ$.
-Let $\t{note} ∈ N = 𝔽ₚ^n$ with $n ∈ ℕ$ denote the plaintext note to be encrypted.
-
 The recipient receives the *ephemeral public key* $\t{EPK} ∈ ℙₚ$ used to decrypt
-the ciphertext note $𝐜 ∈ C = 𝔽ₚⁿ$.
+the ciphertext note $𝐜 ∈ Cₖ$.
+
+Define $\t{ElGamal}.\t{Decrypt} : Cₖ × 𝔽ₚ × ℙₚ → Nₖ$
+by $\t{ElGamal}.\t{Decrypt}(𝐜, x, \t{EPK})$ as follows:
 
 Let $\t{shared\_secret} = \t{KeyAgree}(x, \t{EPK})$
 
 Let $k = \t{PoseidonHash}(\cX(\t{shared\_secret}), \cY(\t{shared\_secret}))$
 
-For $i ∈ [n]$ then compute:
+For $i ∈ [k]$ then compute:
 
   Let $bᵢ = \t{PoseidonHash}(k, i)$
 
-  Let $\t{note}ᵢ = cᵢ - bᵢ$
+  Let $nᵢ = cᵢ - bᵢ$
 
-Return $\t{note} = (\t{note}ᵢ)$
+Return $𝐧 = (nᵢ)$