summa
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Help
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Summa V2: Polynomial Interpolation Approach ## Motivation Summa V1 was using a Merkle sum tree (MST) as the main data structure and cryptographic commitment. MST that has $n$ leaves involves hashing operations over $2n-1$ entries, making it computationally demanding. Additionally, the MST inclusion proofs in Summa V1 have to be wrapped into a ZK-SNARK, making it computationally demanding to generate all of them at once for the entire user base of the Custodian that can be on the order of hundreds of millions of users. ## Preliminaries ### Modular Arithmetic An intuitive example of modular arithmetic from our daily life is the "clock arithmetic". When we see "19:00" boarding time on a boarding pass, we know that it corresponds to "7" on the clock face. Formally, in this case we perform the modular reduction by the modulus 12: $19 \equiv 7 \pmod{12}$, because the clock face only has twelve hours marked on it. ### Roots Of Unity In Modular Arithmetic An integer $\omega$ is an $n$-th root of unity modulo $p$ if: $\omega^n \equiv 1 \pmod{p}$ In other words, $\omega^n$ "wraps around" due to modular reduction to yield exactly $1$. A particular case is when no integers smaller than $n$ yield $1$ modulo $p$. In this case, $\omega$ is called a *primitive* root of unity: $\omega^k \not\equiv 1 \pmod{p}$ for any $0 < k < n$. ### Roots Of Unity Example Let's observe a finite field of order $p = 7$: $\mathbb{F}_7 = \{0, 1,2,3,4,5,6\}$. Let's see that $2$ and $4$ are the 3rd roots of unity in such a field: - $2^3 \equiv 8 \equiv 1 \pmod{7}$, so 2 is a 3rd root of unity modulo 7. - $4^3 \equiv 64 \equiv 1 \pmod{7}$, so 4 is another 3rd root of unity modulo 7. $1$ itself is a root of unity, too, and is called a trivial root of unity. ### Special Property Of The Sum Of Roots of Unity Let's consider a finite field $\mathbb{F}_p$ that has $n$-th roots of unity. Let $\omega$ be a primitive $n$-th root of unity in $\mathbb{F}_p$, which means $\omega^n = 1$ and no smaller positive power of $\omega$ equals $1$. The $n$-th roots of unity in $\mathbb{F}_p$ are $1, \omega, \omega^2, \ldots, \omega^{n-1}$. **Claim**: $1 + \omega + \omega^2 + \ldots + \omega^{n-1} = 0$ (**the sum of all the roots of unity in a finite field is equal to zero**). **Proof**: Consider the sum $S = 1 + \omega + \omega^2 + \ldots + \omega^{n-1}$. We can multiply $S$ by $\omega - 1$, noting that $\omega - 1 \neq 0$ so that such a multiplication preserves the equality: $(\omega - 1)S = (\omega - 1)(1 + \omega + \omega^2 + \ldots + \omega^{n-1})$ Expanding the right hand side, we get: $\omega + \omega^2 + \omega^3 + \ldots + \omega^n - (1 + \omega + \omega^2 + \ldots + \omega^{n-1})$ Notice that if we were to expand further, every term except $\omega^n$ and $-1$ would cancel out: $(\omega - 1)S = \omega^n - 1$ Since $\omega$ is a primitive $n$-th root of unity, $\omega^n = 1$. So, $\omega^n - 1 = 0$. Therefore: $(\omega - 1)S = 0$ If the product of two factors is zero, at least one of them must be zero. We already established that $\omega - 1 \neq 0$, thus $S$ must be zero: $S = 0$ Therefore, $\boxed{1 + \omega + \omega^2 + \ldots + \omega^{n-1} = 0}$. Let's also check it on our previous toy example of $\mathbb{F}_7$ and $n = 3$: $1 + 2 + 4 = 7 \equiv 0 \pmod{7}$. ## Summa V2 Let's see how we can take advantage of *the sum of all roots of unity being zero* when applied to the proof of solvency. ### Data Structure & Commitment Scheme The desired commitment scheme for Summa should have the following properties: * Committing to the total liabilities of the Custodian that is the sum of all user balances; * Allowing to publicly reveal the total liabilities without revealing any information about user balances; * Allowing to prove the individual user inclusion into the commitment without revealing any information about other user balances; * Preserving the user privacy and hiding the user data (namely the user cryptocurrency balances); * Outperform the Merkle sum tree in both commitment phase and proving phase. We will demonstrate how a polynomial commitment can be used to achieve all of these properties. Let's consider a polynomial $B(X)$ that evaluates to an $i$-th user balance $b_i$ at a "user's point" - some value $x_i$ that is designated for this specific user: $B(x_i) = b_i$. We can call it a user balance polynomial. It is quite easy to construct such a polynomial using the Lagrange interpolation. The formula for the polynomial that interpolates these data points is: $B(X) = \sum_{i=1}^{n} b_i \cdot L_i(X)$ Where $L_i(X)$ is the Lagrange basis polynomial defined as a product: $L_i(X) = \prod_{\substack{j=1 \\ j \neq i}}^{n} \frac{X - x_j}{x_i - x_j}$ A polynomial constructed using the Lagrange interpolation is known to have the degree $d = n - 1$ where $n$ is the number of users (and the number of the corresponding balance evaluation points). The resulting polynomial should look like the following: $\boxed{B(X) = a_0 + a_1x + a_2x^2 + ... + a_{n-1} x^{n-1}}$ Let's choose the $x_i$ values as the $i$-th degrees of an $n$-th root of unity (assuming that we are performing all the calculations in the prime field with a sufficiently large modulus): $\boxed{B(\omega^i) = b_i}$ where $\omega$ is the $n$-th primitive root of unity and $i\in0..n-1$. ### KZG Commitment Scheme We choose a KZG commitment scheme to commit to this polynomial for the compatibility with Halo2 API (more on that later). In brief, a KZG commitment is a single elliptic curve point $C$ that uniquely represents the polynomial $B$. It is impossible to reconstruct the polynomial from the commitment, so our requirement of user privacy is satisfied because it is impossible to infer any evaluations of the polynomial from the single-value commitment $C$. During the reveal (aka opening) phase, the committed value $C$ is used along with the claimed polynomial evaluation $B(x)$ to provide a succinct proof $\pi$ verifying that the value $B(x)$ is indeed an evaluation of a polynomial $B(X)$ at point $x$ and corresponds to the original commitment $C$. Therefore, KZG commitment allows the Custodian to individually provide the opening proofs $\pi_i$ to each user to prove that the polynomial $B(X)$ indeed evaluates to the user balance $b_i$ at the point $x_i = \omega^i$. Knowing $\langle C, B(\omega^i),\pi\rangle$, the user is able to verify the opening. More broadly, the KZG commitment allows the prover to open the polynomial at *any* point, and we will later see how it benefits our case. ### Grand Total Of The Polynomial Evaluations To prove the solvency of the Custodian, we need to find its total liabilities by summing up all the user balances and to prove to the public that the sum is less than the assets owned by the Custodian. An individual $i$-th user balance is the evaluation of the polynomial at the $\omega^i$ value corresponding to the user: $B(\omega^i) = b_i =a_0 + a_1(\omega^i)^1 + a_2(\omega^i)^2 + ... + a_{n-1} (\omega^i)^{n-1}$ Let's calculate the sum $S$ of all the user balances as the sum of the polynomial evaluations: \begin{align*} S = \sum\limits_{i=0..n-1} B(\omega^i)& = &a_0\quad& + &a_1\omega^{0\phantom{-1}}\quad & + & a_2(\omega^{0\phantom{-1}})^2\quad & + & \cdots\quad & + & a_{n-1} (\omega^{0\phantom{-1}})^{n-1} +\\ & + &a_0\quad& + &a_1\omega^{1\phantom{-1}}\quad & + & a_2(\omega^{1\phantom{-1}})^2\quad & + & \cdots\quad & + & a_{n-1} (\omega^{1\phantom{-1}})^{n-1} +\\ & + &a_0\quad& + &a_1\omega^{2\phantom{-1}}\quad & + & a_2(\omega^{2\phantom{-1}})^2\quad & + & \cdots\quad & + & a_{n-1} (\omega^{2\phantom{-1}})^{n-1} +\\ &&&&&\vdots \\ & + &a_0\quad& + &a_1\omega^{n-1}\quad & + & a_2(\omega^{n-1})^2\quad & + & \cdots\quad & + & a_{n-1} (\omega^{n-1})^{n-1} =\\ \\ \rlap{\text{(let's factor out each $a_i$)}} \end{align*} \begin{align*}&=n a_0 + a_1(\underbrace{\omega^0 + \omega^1 + \omega^2 + \cdots +\omega^{n-1}}_{=0}) + \cdots + a_{n-1}(\underbrace{\omega^0 + \omega^1 + \omega^2 +\cdots+ \omega^{n-1} }_{=0})^{n-1} = \\ &\rlap{\text{(using the property of the sum of all roots of unity inside the parentheses being zero)}} \\\quad \\&= n a_0 \end{align*} Therefore, the grand sum of the user balances is simply the constant coefficient of the polynomial times the number of users: $\boxed{S = \sum\limits_{i} B(\omega_i) = n a_0}$ As it turns out, the Halo2 proving system is internally using the roots of unity as $X$ coordinates for the polynomial construction, and we will later see how we can take advantage of that. ### Proof Of Solvency Using the described polynomial construction technique and the KZG commitment, it is sufficient for the Custodian to "open" the KZG commitment at $x = 0$: $\langle C, B(0),\pi_{x=0}\rangle: B(0) = a_0 + a_10 + a_20^2 + ... + a_{n-1} 0^{n-1} = a_0$ The total liabilities can then be calculated by multiplying the $a_0$ value by the number of users: $S = n a_0$ ### Proof Of Inclusion As described in the KZG section, individual users would receive the KZG opening proofs $\langle C, B(\omega^i),\pi_i\rangle$ at their specific point $\omega^i$ and they would be able to check that - the opening evaluation is equal to their balance: $B(\omega^i) = b^i$; - the opening proof $\pi_i$ corresponds to the public KZG commitment $C$. The caveat is that if two or more users have the same cryptocurrency balance value, a malicious Custodian could give them the same KZG proof because the user index $i$ is defined by the Custodian. We will use the following technique to mitigate this: - the Custodian has to additionally commit to another polynomial that evaluates to the hashes of user IDs at the specific user points: $H(\omega^i) = h_i$; - the user ID should be known to the user (e.g, the email address used to register with the Custodian), so the user can check that the value $h_i$ is indeed the hash of their ID; - the Custodian then gives two KZG commitments and two opening proofs to the user - $\langle C_B, B(\omega^i),\pi_B\rangle$ proving the balance inclusion into the balances polynomial, and $\langle C_H, H(\omega^i),\pi_H\rangle$ proving the user ID inclusion into the ID polynomial.

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully