Knowledge Base
  • Introduction
  • SHIELDING
    • Shielded pools
    • Key generation process
    • Privacy best practices
  • Fraud protection
  • Web App – User Guide
  • SMART YIELD
    • How does Smart Yield work?
    • Governance Model
    • Shielding
  • COMMON ECONOMY
    • The Economy of Common
    • CMN Token
    • CMN Tokenomics and Vesting Schedules
    • CMN Airdrops
    • Shared Fees and Reward Economics of Common
  • Wallet (Extension)
    • Introduction
    • Getting Started
    • Usage
    • Settings
  • DEX and Bridge (Aleph Zero WASM layer 1)
    • Account
      • How to Connect Your Wallet
      • Video Guide: How to Connect Your Wallet
      • How to Check Your Balance
      • Video Guide: How to Check Your Balance
    • Swap
      • How to Swap Tokens
      • Video Guide: How to Swap Tokens
    • Farm
      • How to Farm
      • Video Guide: How to Farm
    • Pool
      • Explaining Liquidity Pools
      • Video guide: Explaining Liquidity Pools
      • Managing Liquidity Pools with Custom Tokens
      • Video Guide: Managing Liquidity Pools with Custom Tokens
    • Bridge
      • How to Bridge With Most
        • Ethereum to Aleph Zero WASM
        • Aleph Zero WASM to Aleph Zero EVM
      • Video Guide: How to Bridge With MOST?
      • Bridging 10,000+ AZERO from Aleph Zero WASM to EVM
  • Protocol Details
    • Shielder
    • Overview
    • Design Against Bad Actors
    • Preliminaries: ZK Relations
    • Notes and Accounts
    • ZK-ID and Registrars
    • Anonymity Revokers
    • PoW Anonymity Revoking
    • Relayers
    • Deterministic Secret Management
    • SNARK-friendly Symmetric Encryption
    • SNARK-friendly Asymmetric Encryption
    • Cryptography
    • Token Shortlist
    • User Wallet
    • Versioning
    • PoC
    • Version 0.1.0
    • Version 0.2.0
Powered by GitBook
On this page
  • Problem Statement
  • Solution

Was this helpful?

  1. Protocol Details

SNARK-friendly Symmetric Encryption

Problem Statement

We want an encryption scheme that would work well in arithmetic circuits (for SNARKS). So both the key and the input to the encryption should be m∈Fnm∈\mathbb{F}^nm∈Fn vectors (with F\mathbb{F}F being the field).

Solution

Keygen: generate key x∈Fx∈\mathbb{F}x∈F uniformly at random

Encrypt:

  • Input: message m∈Fnm∈\mathbb{F}^nm∈Fn, key x∈Fx∈\mathbb{F}x∈F

  • Sample a nonce k∈Fk∈\mathbb{F}k∈F uniformly at random. Compute a=hash(k,x)∈Fa=hash(k,x)∈\mathbb{F}a=hash(k,x)∈F

  • Compute ri​=hash(a,i)ri​=hash(a,i)ri​=hash(a,i) for i=1,2,…,ni=1,2,…,ni=1,2,…,n and let r∈Fnr∈\mathbb{F}^nr∈Fn be the resulting vector

  • Compute e=m+re=m+re=m+r (note e∈Fne∈\mathbb{F}^ne∈Fn)

  • Output (k,e)(k,e)(k,e)

Decrypt:

  • Input: ciphertext (k,e)(k,e)(k,e), key x∈Fx∈\mathbb{F}x∈F,

  • Compute r∈Fnr∈\mathbb{F}^nr∈Fn based on k,xk,xk,x as above

  • compute m=e−rm=e−rm=e−r

  • Output mmm

Total cost for encryption and decryption is: ≈n⋅Ghash≈n⋅G_{hash}≈n⋅Ghash​​ where GhashG_{hash}Ghash​​ is the number of gates one hashing costs.

PreviousDeterministic Secret ManagementNextSNARK-friendly Asymmetric Encryption

Last updated 6 days ago

Was this helpful?