kilic
    • Create new note
    • Create a note from template
      • 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
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me 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
    • Save as template
    • 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 Create Help
Create Create new note Create a note from template
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
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me 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
2
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# ECC multiplication strategies inside PLONK This document assumes constrained elliptic curve is in SW form with `a = 0` ## Montgomery Ladder We require lots of sequential double and adding operations in ecc multiplication algorithms. Fortunately we have small but cool optimization trick to calculate `P_2 = 2 * P_0 + P_1`. Rather than one doubling and one addition we combine two formulas and find a simpler `P_2 = P_0 + P_1 + P_0` formula. Below we can calculate the result skipping calculation of `y` coordinate of intermediate result. ``` lambda_0 = (y_1 - y_0) / (x_1 - x_0) x_2 = lambda_0 * lambda_0 - x_0 - x_1 lambda_1 = lambda_0 + 2 * y_0 / (x_2 - x_0) x_res = lambda_1 * lambda_1 - x_0 - x_2 y_res = lambda_1 * (x_res - x_0) - y_0 ``` ## Random accumulation initializer Random accumulation initializer is a point that should allow us to use incomplete formulas. In naive way in doubling we would need such constaints: ```python def double(P_0): cond_is_inf = is_inf(P_0) canditate_res = constrain_doubling(P_0) return select(cond_is_inf, candidate_res, infinity) ``` So can we make sure that input point `P_0` is not infinity without asserting each time while we constrain doubling? And in addition it looks like this ```python def add(P_0, P_1): cond_is_inf_0 = is_inf(P_0) cond_is_inf_1 = is_inf(P_1) cond_is_equal = is_equal(P_0, P_1) canditate_res_add = constain_addition(P_0, P_1) canditate_res_dou = constrain_doubling(P_0) T = select(cond_is_equal, canditate_res_dou, canditate_res_add) T = select(cond_is_inf_0, P_1, T) T = select(cond_is_inf_1, P_0, T) return T ``` In the intermediate step just before selection we have 5 candidate results! Also we had to apply doubling to stay safe while `P_0 == P_1`. | c_0 | c_1 | c_eq | R | | --- | --- | ------------------ | -------------- | | 1 | 1 | guaranteed to be 1 | infinity | | 0 | 1 | guaranteed to be 0 | P_0 | | 1 | 0 | guaranteed to be 0 | P_1 | | 0 | 0 | 1 | 2*P_0 == 2*P_1 | | 0 | 0 | 0 | P_0 + P_1 | Below conditions are ideally what we would like to have that operands satisfies to make formulas much shorter. * `P_0 != 0` and `P_1 != 0` to skip infinity checks * `P_0 != P_1` to just constrain addition * `P_0 != -P_1` to avoid result goes to infinity. > And also keep in mind that we are not using an embedded curve ie. base field of the subject elliptic curve is not equal to the scalar field where we constrain equations. Therefore infinity and equality checks becomes more expensive than we would like. We can just make sure that any public inputs are not point of infinity by simply checking if point is on curve. However this won't guarantee `P_0 == P_1` to escape branching in addition since an earlier addition with `P_0 = -P_1` operands would produce an infinity inside of the circuit. ### Case: Simple double-and-add method. Let's denote multiplication like `R = P * e` where `e` is a scalar and can be decomposed as `[b_0, b_1, ...]` ```python def mul(P_0, e): bits = decompose(e) table = [infinity, P_0] Acc = select(bits[0], table) for b in bits[1:]: Acc = double(Acc) to_add = select(b, table) Acc = add(Acc, to_add) return Acc ``` In the naive multiplication above in the table we have point of infinity as first entry. Constraints must follow complete formulas even if input point `P_0` is guaranteed not to be point of infinity. So we will use an auxiliary point `AuxInit` which is fed with public inputs in order to avoid using complete formulas. Then selection table is now `[AuxInit, AuxInit + P_0]` rather than `[infinity, P_0]` ```python= AuxInit AuxFin = AuxInit * ((1 << n) -1) def mul(P_0, e): bits = decompose(e) table = [AuxInit, P_0 + AuxInit] Acc = select(bits[0], table) for b in bits[1:]: Acc = double_incomplete(Acc) to_add = select(b, table[0], table[1]) Acc = add_incomplete(Acc, to_add) # or more in optimal way # Acc = ladder_incomplete(Acc, select(b, table[0], table[1])) Acc = Acc - AuxFin return Acc ``` So we not only achieved non infinity point initialization but also guaranteed operands in addition will not be equal! It means we don't have to branch for infinity points in the circuit. This claim must hold only if prover doesn't have an access to `AuxInit` point before creating the proof. ## Sliding window So we can just precompute (or preconstrain) a wider table to reduce number of iterations in the double-and-add algorithm. While this step introduce more selection steps it will reduce number of additions. For example where`window_size = 2` a scalar `e` is decomposed as: `bits = [b_0, b_1, ...]` and we window those bits as `windows = [[b_0, b_1], [b_2,b_3], ...]` So selection table will be `table = [0, P_0, 2*P_0, 3*P_0]` Or with auxiliary point `table = [Aux, P_0 + Aux, 2*P_0 + Aux, 3*P_0 + Aux]` * Number of selection size will grow by `window_size` times. * Number of addition will be reduced by `1/window_size`times. * And main trade-off is between number of iteration and precomputation cost that grows by `2^window_size`. So a sweet window size can be found. Sliding window technique is cheaper because selection operation is much cheaper than addition operation (even if incomplete addition). ## Multi Multiplication Multi multiplication mostly covers linear combination of points and has some application area for example can be used in recursion circuits or polynomial commitment inside of a circuit. So we can generalize simple double-and-add algorithm to share the same doubling step across point scalar pairs. We will also use sliding window and auxiliary initial value technique. `pairs = [(P_0, e_0), (P_1, e_1), (P_2, e_2)]` Scalar values decomposed as: `e_0 = [b_0, b_1, ...]` `e_1 = [b_0, b_1, ...]` `e_2 = [...]` Let's window scalars: `w_0 = [[b_0, b_1], [b_2,b_3], ...]` `w_1 = [[b_0, b_1], [b_2,b_3], ...]` `w_2 = [...]` `AuxGen` is random point where DL is unknown that generates aux values for each pair. We should calculate an aux per pair and we have to make it linear independent to use incomplete formulas ie. to avoid `a=b` in `add(a,b)` operation. Each pair could have their own independent aux points however we expect this aux point from public input and we also don't want to bloat public input size. So we can still a generator point to make tables independent. `A_0 = AuxGen * 2^0` `A_1 = AuxGen * 2^1` `A_2 = AuxGen * 2^2` Then we will be able to construct tables as: `table_0 = [A_0, A_0 + P_0, A_0 + 2 * P_0, A_0 + 3 * P_0]` `table_1 = [A_1, A_1 + P_1, A_1 + 2 * P_1, A_1 + 3 * P_1]` `table_2 = [...]`

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