or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
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.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
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 simplerP_2 = P_0 + P_1 + P_0
formula. Below we can calculate the result skipping calculation ofy
coordinate of intermediate result.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:
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
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
.Below conditions are ideally what we would like to have that operands satisfies to make formulas much shorter.
P_0 != 0
andP_1 != 0
to skip infinity checksP_0 != P_1
to just constrain additionP_0 != -P_1
to avoid result goes to infinity.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 withP_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
wheree
is a scalar and can be decomposed as[b_0, b_1, ...]
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]
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 scalare
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]
window_size
times.1/window_size
times.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 avoida=b
inadd(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 = [...]