0xPolygonHermez / zkevm-rom

This repo contains the zkasm source code of the zkEVM
Other
124 stars 49 forks source link

Optimizing scalar multiplication and exponentiation like algorithms #314

Open hecmas opened 9 months ago

hecmas commented 9 months ago

Description

Say that we are in a group $(\mathbb{G}, +)$ or prime order $r$. We are given an element $Q \in_R \mathbb{G}$ and we are asked to compute $k\cdot Q$ for some $k_R \in [1, r-1]$.

There are many methods we can use to optimize this operation:

Numbers

Test 1/3:
    Double-and-add style: total time is 14m11.334s
    wNAF method for scalar multiplication with w = 3: total time is 11m59.115s
    GLV method with wNAF double scalar multiplication with w = 3: total time is 13m13.886s

Test 2/3:
    Double-and-add style: total time is 14m10.720s
    wNAF method for scalar multiplication with w = 4: total time is 11m33.297s
    GLV method with wNAF double scalar multiplication with w = 4: total time is 12m35.619s

Test 3/3:
    Double-and-add style: total time is 14m8.215s
    wNAF method for scalar multiplication with w = 5: total time is 11m21.073s
    GLV method with wNAF double scalar multiplication with w = 5: total time is 12m31.586s
ignasirv commented 9 months ago

The post access is restricted :)

hecmas commented 9 months ago

The post access is restricted :)

Fixed :)

Warning: Math Heavy