Logo
    🧮

    DKG Problems & Solutions

    • Notation
    • Curves Recap
    • Cycle of Curves
    • 2chain of pairing based curves
    • Embedded curve
    • DKG operations
    • In a SNARK
    • Solution 1: Do Non Native Field Arithmetic:
    • Solution 2: We use a 2-chain set of curves w/ 2 proofs
    • Solution 3: Use a full cycle of curves
    • List of curves compatibility
    • Proof System & Curves Landscape
    • Curves & Proof system
    • Status Quo: NI DKG BLS12-377/BW6 with Groth16
    • Cool & Futuristic: NI DKG Secp (Bitcoin) curves with Nova
    • Hammer way: NI DKG BLS12-381 / BN254
    • Interactive DKG
    • Platform, L1 L2
    • Starkware
    • Arbitrum
    • Aztec
    • Aleo
    • Ethereum
    • Cost of storing onchain
    • Ethereum (TODO)
    • Economics Model

    Notation

    A curve E(Fq)E(F_q)E(Fq​) of order rrr A point is (x,y)∈Fq2(x,y) \in F_q^2(x,y)∈Fq2​ A scalar is x∈Frx \in F_rx∈Fr​ Scalar multiplication xGxGxG

    DKG requires operation both on FrF_rFr​ and E(Fq)E(F_q)E(Fq​)

    1. Add, Mul, Inv on FrF_rFr​ -> this for evaluating polynomials f(1),f(2)...f(1),f(2)...f(1),f(2)...
    2. Add, Sub, Scalar Multiplication on E(Fq)E(F_q)E(Fq​)

    Curves Recap

    Cycle of Curves

    Two curves “connected” with each other: E1(Fq)E_1(F_q)E1​(Fq​) of order rrr -> can write circuits on FrF_rFr​ E2(Fr)E_2(F_r)E2​(Fr​) of order qqq -> can write circuits on FqF_qFq​

    Required for Halo2, Nova, Non Succinct Argument... Why ? Because we need to implement a verifier of the previous proof inside a circuit. Verifier needs to do Group operations -> circuit in FrF_rFr​, verifier needs to do operation in circuit in FqF_qFq​

    List: Secp (Bitcoin curves), Pasta curves & many others (”easy” to find a cycle).

    2chain of pairing based curves

    2 pairing based curves where one is defined on top of the other. Typically used to have a circuit that can verify another pairing based proof.

    We have two proofs, one that deals with FqF_qFq​ circuit and one that deals with FrF_rFr​ circuit and the former proof verifies the latter inside its circuit.

    • Outer curve E1(Fw)E_1(F_w)E1​(Fw​)of order qqq -> circuits can be written on FqF_qFq​
      • Allows to write point operations
    • Write a circuit that verifies a proof done on the inner curve i.e. verify a Groth16 made on E2(Fq)E_2(F_q)E2​(Fq​)
    • Inner curve E2(Fq)E_2(F_q)E2​(Fq​) of order rrr -> circuits can be written on FrF_rFr​ -> Allows to write scalar operations

    Note: There also exists cycle of pairing based curves but these are very costly so it’s not considered here

    Embedded curve

    Similar to 2chain but the inner curve is a regular DLOG curve.

    Take a pairing equipped curve E(Fq)E(F_q)E(Fq​) of order rrr I can also define another DLOG EC Ed(Fr)E_d(F_r)Ed​(Fr​) of order ttt -> I can write circuits about points in Ed(Fr)E_d(F_r)Ed​(Fr​) -> Useful verify easily ECDSA signatures in SNARK -> Can NOT write circuits about scalars in FtF_tFt​

    List: Bandersnatch (on BLS12-381), Jubjub (on BLS12-381), Baby JubJub (on BN254)

    DKG operations

    t=n/2+1t = n/2 + 1t=n/2+1

    1. Create random polynomial f(x)=a1+...+at∗xtf(x) = a_1 + ... + a_t*x^tf(x)=a1​+...+at​∗xt of degree ttt
    2. Evaluate shares f(1),f(2)...f(n)f(1),f(2)...f(n)f(1),f(2)...f(n) -> operations in FrF_rFr​ -> O(n*t) work on field operation -> Right now, doing Horner's rule (-> Can we use PCS opening proofs to batch verify f(1),...f(1),...f(1),... like in Alin’s post? Is it worthwhile ?)
    3. Encrypt shares Enc(f(1)),...,Enc(f(1)),...,Enc(f(1)),..., -> Hashed El Gamal {rG,H(rPKi)+si}\{rG, H(rPK_i) + s_i\}{rG,H(rPKi​)+si​} or ECIES -> operations in FrF_rFr​ and FqF_qFq​
    4. Commit to coefficients A1=a1G,...A_1 = a_1G, ...A1​=a1​G,... -> operations in FqF_qFq​

    In a SNARK

    → How to do these operations in a SNARK ?

    Within a SNARK, circuit is described in terms of elements of a field FpF_pFp​

    • Let's take Groth16: FpF_pFp​ is the order of the pairng curve that we use to make the proof E(Fw)E(F_w)E(Fw​)

    Operations:

    • To do 1., we need r=pr = pr=p so it's natural to write the scalar operations
    • To do 2., we need q=pq = pq=p so it's natural to write the point operations

    Problem: We can't have both r=pr = pr=p AND q=pq = pq=p

    Solution 1: Do Non Native Field Arithmetic:

    This basically emulate FqF_qFq​ operations within FrF_rFr​ . This solution is quite costly because the modulo reduction after each operation (+ * etc) is costly to do in a different field ! Expect 1-2 orders of magnitude more than native.

    Solution 2: We use a 2-chain set of curves w/ 2 proofs

    Solution 3: Use a full cycle of curves

    List of curves compatibility

    We say a curve is compatible if there is a precompile operations on miners/smart contract that can execute the operations (scalar multiplication, group operation etc).

    Note that it’s difficult in Eth to have a lot of compatibility because of sheer size of network, parties involved etc makes any change much harder. But Rollups are changing the game, have the power to improve things much faster on their side.

    Curve
    Type
    Property
    Compatibility
    Secp256k1
    dlog
    Cycle, no FFT
    Eth, BTC, Fil...
    Pasta curves
    dlog
    Cycle, FFT
    Zcash, ETH (with VDF?)
    BN254
    pairing
    Embedded curve
    Eth (EVM)
    BLS12-381
    pairing
    Embedded curve
    Eth (Q4 2022), FIL, many are coming to it
    BLS12-377
    pairing
    2chain, embedded
    Celo, ....

    Proof System & Curves Landscape

    Curves & Proof system

    NI DKG = Non Interactive DKG, i.e. in a SNARK

    Status Quo: NI DKG BLS12-377/BW6 with Groth16

    • Pros: less constraints, "straightforward" implementation
    • Cons: Not compatible with mainstream

    Cool & Futuristic: NI DKG Secp (Bitcoin) curves with Nova

    • Pros: Compatible everywhere
    • Cons: DLOG only (no BLS etc), Nova not ready yet (Q3 2022 ?)

    Hammer way: NI DKG BLS12-381 / BN254

    Either code non native field arithmetic for the point operations (extremely costly) OR use the embedded DLOG curve as the DKG curve (JubJub or Baby JubJub or Bandersnatch)

    • Pros: compatible everywhere, pairing
    • Cons: NNA is expensive and Jubjub is not well recognized

    Interactive DKG

    Regular interactive (3 rounds) DKG using blockchain as broadcast channel Compatibility with: BLS12-381,BN254,Secp !

    Platform, L1 L2

    We’re here considering the usage of L2s as the broadcast layer given the frequency and relatively cheap operations. However that opens now the problem of moving information from L2 to L1 given we want to be “cross chain compatible” or at the very least “eth” reachable.

    Starkware

    Write the DKG as a Cairo program with secret inputs and public output: there will be a central smart contract that gets these outputs. Compatible with:

    • Interative DKG, on Secp (Bitcoin - Cairo library) and BN254 (Cairo library)

    Incompatible with:

    • NI DKG (proof systems) since there is no privacy unlike Aleo, so the private polynomial in DKG is revealed to the Starkware prover

    Pros: Fast resolution from L2→L1 since it’s zkRollup

    Cons: Specialized platform (Cairo), can’t re-use future work on other L2 or need to be careful about transpiling from Solidity → Cairo

    Arbitrum

    Similar to Starkware Compatible with:

    • Interactive DKG with Secp, BLS12-381, (BN254?)

    Incompatible with:

    • NI DKG (proof systems) since there is no privacy

    Pros: Compatible natively with EVM smart contracts, so very easy to deploy / change and map from chains

    Cons: L2->L1 have to wait for dispute period

    Aztec

    Not possible now but later down with Noir lang, will be able to build private smart contract on their L2. Compatible with: NI DKG on Baby Jubjub ?

    Aleo

    Private smart contract, with Noir lang. Compatible with: BLS12-377 !

    Incompatible with: Ethereum since it doesn’t support this curve yet (and no plan of doing so)

    • Can we do an “oracle

    Ethereum

    Compatible with:

    • Interactive DKG with Secp
    • Interactive DKG with BN254/BabyJubjub , JubJub with BLS12-381 (Q4 2022)

    Incompatible with:

    • NI DKG with BLS12-377 → BUT there is an EIP https://eips.ethereum.org/EIPS/eip-2539 !

    Pros: Direct mainstream adoption

    Cons: May be expensive ?

    Cost of storing onchain

    General formula to get number of kB that each participant must submit to the DKG using 32bytes scalar and points representation (i.e. Secp):

    // signature + rG (encryption) + shares for all + coefficients
    (32*2 + 32 + 32*1000 + 32*(n/2+1))/1024
    

    Ethereum (TODO)

    Storing onchain: According to this table, it costs:

    According to this post:

    • 20'000 gas / 32byte to write
    • > we have 640000 gas for writing 1kB -> for n=1000 961280000 gas, 1gwei, 1$ (32 + 32*1000 + 32*(n/2+1))*20000/1e9

    Storing in transaction set only: which is what we need in the end is much less costly

    • TODO

    Economics Model

    We need to think of the way to get crypto economics right within the DKG protocol:

    • How do we choose participants ?
    • If according to stake, it's not trivial:
      • We need n phyiscal participants
      • Each participant has more weights than the other
      • Are we setting up the threshold in terms of weight or in terms of physical participation ?
      • The latter is easier but the former makes more sense

    CryptoNet is a Protocol Labs initiative.