From 71a1dc6375fd58f9a1526fdb2c767f572b22e86a Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Tue, 24 May 2022 14:27:32 +0200 Subject: [PATCH] por: select backend and curve using defines The implementation supports two backends: - BLST (default) - Constantine (-d:por_backend_constantine) The implementation supports PoR over the following curves: - BLS12-381 (default) - BN254_Starks (use -d:por_backend_constantine -d:por_curve_bn254) Signed-off-by: Csaba Kiraly --- dagger/por/backends/backend_constantine.nim | 9 +++++++-- dagger/por/por.nim | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/dagger/por/backends/backend_constantine.nim b/dagger/por/backends/backend_constantine.nim index 6cffd0bf..f3daefb5 100644 --- a/dagger/por/backends/backend_constantine.nim +++ b/dagger/por/backends/backend_constantine.nim @@ -11,6 +11,9 @@ # Shacham H., Waters B., "Compact Proofs of Retrievability" # using pairing over BLS12-381 ECC +# use BLS12_381 curve by default. +# Specify -d:por_curve_bn254 to use BN254_Snarks + import constantine, # constantine/platforms/abstractions, @@ -38,8 +41,10 @@ when defined(debugConstantine): export `$` #set up curve and G1/G2 -#const C = BN254_Snarks -const C = BLS12_381 +when defined(por_curve_bn254): + const C = BN254_Snarks +else: + const C = BLS12_381 type ec_SecretKey* = SecretKey diff --git a/dagger/por/por.nim b/dagger/por/por.nim index 2b71aa69..01a0b984 100644 --- a/dagger/por/por.nim +++ b/dagger/por/por.nim @@ -9,7 +9,15 @@ # Implementation of the BLS-based public PoS scheme from # Shacham H., Waters B., "Compact Proofs of Retrievability" -# using pairing over BLS12-381 ECC +# using pairing over the BLS12-381 ECC or BN254_Starks +# +# The implementation supports two backends: +# - BLST (default) +# - Constantine (-d:por_backend_constantine) +# +# The implementation supports PoR over the following curves: +# - BLS12-381 (default) +# - BN254_Starks (use -d:por_backend_constantine -d:por_curve_bn254) # # Notation from the paper # In Z: @@ -82,8 +90,10 @@ # - blst supports only the BLS12-381 curve # - constantine is more experimental, supports BLS and BN curves as well # As of now configuration of backends is in the backend_* file itself -import ./backends/backend_blst -#import ./backends/backend_constantine +when defined(por_backend_constantine): + import ./backends/backend_constantine +else: + import ./backends/backend_blst import ../rng import endians