-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi-scalar-mul for TwistedEdwards (#297)
* generalize MSM to any curve short weierstrass + twisted edwards * Better cacheline prefetching * Generalize MSM to TwistedEdwards curves including Bandersnatch and Banderwagon
- Loading branch information
Showing
27 changed files
with
744 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Constantine | ||
# Copyright (c) 2018-2019 Status Research & Development GmbH | ||
# Copyright (c) 2020-Present Mamy André-Ratsimbazafy | ||
# Licensed and distributed under either of | ||
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). | ||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). | ||
# at your option. This file may not be copied, modified, or distributed except according to those terms. | ||
|
||
import | ||
# Internals | ||
../constantine/math/config/curves, | ||
../constantine/math/arithmetic, | ||
../constantine/math/elliptic/ec_twistededwards_projective, | ||
# Helpers | ||
../helpers/prng_unsafe, | ||
./bench_elliptic_parallel_template | ||
|
||
# ############################################################ | ||
# | ||
# Benchmark of the G1 group of | ||
# Short Weierstrass elliptic curves | ||
# in (homogeneous) projective coordinates | ||
# | ||
# ############################################################ | ||
|
||
|
||
const Iters = 10_000 | ||
const AvailableCurves = [ | ||
Bandersnatch | ||
] | ||
|
||
# const testNumPoints = [10, 100, 1000, 10000, 100000] | ||
# const testNumPoints = [64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072] | ||
const testNumPoints = [1 shl 8, 1 shl 9, 1 shl 10, 1 shl 11, 1 shl 12, 1 shl 13, 1 shl 14, 1 shl 15, 1 shl 16, 1 shl 17, 1 shl 22] | ||
|
||
proc main() = | ||
separator() | ||
staticFor i, 0, AvailableCurves.len: | ||
const curve = AvailableCurves[i] | ||
var ctx = createBenchMsmContext(ECP_TwEdwards_Prj[Fp[curve]], testNumPoints) | ||
separator() | ||
for numPoints in testNumPoints: | ||
let batchIters = max(1, Iters div numPoints) | ||
ctx.msmParallelBench(numPoints, batchIters) | ||
separator() | ||
separator() | ||
|
||
main() | ||
notes() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--threads:on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Constantine | ||
# Copyright (c) 2018-2019 Status Research & Development GmbH | ||
# Copyright (c) 2020-Present Mamy André-Ratsimbazafy | ||
# Licensed and distributed under either of | ||
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). | ||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). | ||
# at your option. This file may not be copied, modified, or distributed except according to those terms. | ||
|
||
import | ||
# Internals | ||
../config/curves, | ||
../arithmetic, | ||
../elliptic/ec_twistededwards_projective | ||
|
||
# ############################################################ | ||
# | ||
# Clear Cofactor | ||
# | ||
# ############################################################ | ||
|
||
func clearCofactorReference*(P: var ECP_TwEdwards_Prj[Fp[Bandersnatch]]) {.inline.} = | ||
## Clear the cofactor of Bandersnatch | ||
# https://hackmd.io/@6iQDuIePQjyYBqDChYw_jg/BJBNcv9fq#Bandersnatch-Subgroup | ||
# | ||
# Bandersnatch Subgroup | ||
|
||
# The group structure of bandersnatch is ℤ₂ x ℤ₂ x p, where p is a prime | ||
# | ||
# The non-cyclic subgroup which we may refer to as the 2 torsion subgroup is: | ||
# E[2] = {(0, 1), D₀, D₁, D₂} | ||
# | ||
# Remark: All of these points have order 2 or 1, so it is sufficient to double any point in the bandersnatch group to clear the cofactor. ie one does not need to multiply by the cofactor; 4. | ||
# Remark: We may also refer to the 2 torsion subgroup as the small order subgroup. | ||
P.double() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.