ECDSA VS Schnorr signature VS BLS signature

1. ECDSA

ECDSA,全稱爲Elliptic curve Digital Signature Algorithm,採用Elliptic curve cryptography來實現的數字簽名算法。

目前Bitcoin採用的是ECDSA簽名方案。

公私鑰對(pk,P)(pk,P),其中公鑰P=pk×GP=pk\times GGG爲所選橢圓曲線的base point。(elliptic curve base point: a point on the curve that generates a subgroup of large prime order nnn×G=On\times G=\mathcal{O}, O\mathcal{O} is the identity element。)

1.1 ECDSA簽名

ECDSA對消息mm的簽名流程爲:

  • 1)計算消息mm的hash值:e=hash(m)e=hash(m)。(hash函數可爲SHA-2,輸出轉換爲數值。)
  • 2)若group order nn的bit length爲LnL_n,則取ee值最左側的LnL_n bits賦值給zz。(注意,zz值可以比nn大,但bit length不能比nn的長。)
  • 3)選擇隨機數kR[1,n1]k\in_R [1,n-1]。(注意,不信任一般的隨機數生成器,因爲不好的RNG有太多的failures和vulnerabilities,可採用RFC6979 根據pkpkmm來計算deterministic kk。)(如:2013年8月,安卓Bitcoin錢包因使用了錯誤的隨機數生成器,引起私鑰泄露,導致資金損失;2010年12月,索尼PS3遊戲機因錯誤的使用了靜態而不是隨機的kk值,導致其ECDSA私鑰泄露。)
  • 4)計算curve point (x1,y1)=k×G(x_1,y_1)=k\times G
  • 5)計算r=x1mod  nr=x_1\mod n,若r=0r=0,則跳轉繼續執行步驟3)。
  • 6)計算s=(z+rpk)/kmod  ns=(z+r\cdot pk)/k \mod n,若r=0r=0,則跳轉繼續執行步驟3)。
  • 7)最終的簽名爲(r,s)(r,s)。(注意,(r,smod  n)(r,-s\mod n)也爲有效簽名。)

整個ECDSA簽名流程中,要求:

  • kk值應爲secret。
  • 不同的簽名應選擇不同的kk值,否則會泄露私鑰pkpk
    在這裏插入圖片描述

1.2 ECDSA驗籤

對收到的簽名(r,s)(r,s),採用公鑰PP進行驗籤的流程爲:

  • 1)驗證公鑰PP不等於identity element O\mathcal{O},且爲其座標爲valid。
  • 2)驗證公鑰PP lies on the curve。
  • 3)驗證公鑰PP的order爲nn,即n×P=On\times P=\mathcal{O}
  • 4)驗證簽名(r,s)(r,s)有效,即滿足r[1,n1],s[1,n1]r\in [1,n-1],s\in [1,n-1]
  • 5)計算消息mm的hash值,所採用的hash函數應與簽名時一致。e=hash(m)e=hash(m)
  • 6)取ee的最左側LnL_n bits賦值給zz
  • 7)計算u1=z/smod  n,u2=r/smod  nu_1=z/s\mod n,u_2=r/s\mod n
  • 8)計算curve point (x1,y1)=u1×G+u2×P(x_1,y_1)=u_1\times G+u_2\times P。若(x1,y1)=O(x_1,y_1)=\mathcal{O},則簽名無效。
  • 9)若rx1(mod  n)r\equiv x_1(\mod n)成立,則簽名有效,否則簽名無效。

注意,以上ECDSA驗籤算法可做如下改進:

  • 只計算一次1/smod  n1/s\mod n
  • 使用Shamir’s trick,a sum of two scalar multiplication u1×G+u2×Pu_1\times G+u_2\times P can be calculated faster than two scalar multiplications done independently。(參考2014年論文《The Double-Base Number System in Elliptic Curve Cryptograhy》)

ECDSA總的簽名和驗籤流程可以如下圖示意:
在這裏插入圖片描述

1.3 ECDSA的public key recovery

ECDSA也支持public key recovery算法,前提是提前知道簽名方的公鑰或者公鑰hash值,否則有可能恢復出錯誤的公鑰信息。
在這裏插入圖片描述

1.4 ECDSA的弊端

Bitcoin中採用ECDSA的弊端主要有:

  • 1)ECDSA的驗簽過程中,需要進行求倒數和scalar multiplication運算,這些運算操作都是computationally heavy的。
    在Bitcoin中,每個節點都需要驗證所有的交易,當你廣播一條交易時,數以千記的計算機都需要驗證你的簽名。因此,Making verification process simpler will be very beneficial even if signing process is harder。

  • 2)每個節點需要分別驗證每個簽名。對於m-of-n multisig transaction,節點甚至需要對同一簽名進行多次驗證。如具有7-of-11 multisig input的transaction,將包含7個簽名,同時需要網絡中的每個節點驗證7到11個簽名信息。同時,這樣的transaction將佔據區塊中大量的空間,需要pay larger fees for that。

1.5 ECDSA支持2-of-2 multisignature

觀察ECDSA的簽名(r,s=(z+rpk)/kmod  n)(r,s=(z+r\cdot pk)/k \mod n)(其中z=hash(m)z=hash(m)kk爲隨機數,R=k×GR=k\times G,r爲random point RRxx座標),儘管其沒有Schnorr和BLS簽名的linearity,無法通過對公鑰和簽名的addition來進行key aggregation,但是multiplication可以。

aggregated public key可爲:
P=pk1pk2×GP=pk_1\cdot pk_2\times G
通過Diffie Helman key exchange即可實現——every party takes the public key of another party and multiplies it by his private key, then both parties know the common public key without exposing anything about their private keys。

R1=k1×GR_1=k_1\times G
R2=k2×GR_2=k_2\times G
aggregated random point爲:
R=k1k2×GR=k_1\cdot k_2\times G
相應的aggregated rr爲aggregated random point RRxx 座標。

接下來的目標是構建s=(z+rpk1pk2)/k1/k2s=(z+r\cdot pk_1\cdot pk_2)/{k_1}/k_2,但是要求private key和random number of one party stay unknown to another。可利用同態屬性來實現。
具體流程如下圖所示:(其中紅色字體代表的是private data, 藍色字體代表的是public data,橙色的字體代表的是homomorphic encryption and decryption。)
在這裏插入圖片描述
上圖中的e()同態加密算法和d()同態解密算法可以藉助Paillier scheme類似的思路來實現。
詳細爲:

  • 選擇兩個長度一樣的large prime numbers p,qp,q
    n=pqn=p\cdot qg=n+1g=n+1(n,g)(n,g)爲public,用於加密。
    λ=lcm(p1,q1)\lambda=lcm(p-1,q-1)lcm表示最小公倍數。)λ\lambda具有Carmichael function 有趣的特性,滿足:任意的rr值,rλ1mod  n,rλn1mod  n2,r1rλ1mod  nr^{\lambda}\equiv 1 \mod n,r^{\lambda\cdot n}\equiv 1\mod n^2,r^{-1}\equiv r^{\lambda -1}\mod n,當r=λr=\lambda時,仍然成立。於是有:μ=λ1=λλ1mod  n\mu=\lambda^{-1}=\lambda^{\lambda-1}\mod n(λ,μ)(\lambda,\mu)爲secret,用於解密。

  • 對secret number xx進行加密的流程爲:
    選擇隨機的rre(x)=gxrnmod  n2e(x)=g^x\cdot r^n\mod n^2
    e(x)ga=gx+arnmod  n2=e(x+a)e(x)\cdot g^a=g^{x+a}\cdot r^n\mod n^2=e(x+a),具有加法同態屬性。
    e(x)b=g(xb)(rb)nmod  n2=e(xb)e(x)^b=g^{(x\cdot b)}\cdot (r^b)^n\mod n^2=e(x\cdot b),具有乘法同態屬性。(The random number changes from rr to rbr^b, but we don’t really care. It’s just a different random number. )

  • 對secret number xx的解密流程爲:
    x=(e(x)λmod  n21)/nμmod  nx=(e(x)^{\lambda}\mod n^2-1)/n\cdot \mu\mod n
    具體爲:
    e(x)λmod  n2=g(xλ)r(nλ)mod  n2=g(xλ)mod  n2e(x)^{\lambda}\mod n^2=g^{(x\cdot \lambda)}\cdot r^{(n\cdot \lambda)}\mod n^2=g^{(x\cdot \lambda)}\mod n^2
    注意之前有g=n+1g=n+1,利用 binomial theorem
    在這裏插入圖片描述
    gxmod  n2=(n+1)xmod  n2=(1+xn+x(x1)/2n2+)mod  n2=(1+xn)g^x\mod n^2=(n+1)^x\mod n^2=(1+x\cdot n+x\cdot (x-1)/2\cdot n^2+\cdots)\mod n^2=(1+x\cdot n)
    於是令x=λxx=\lambda x有:g(xλ)mod  n2=1+λxng^{(x\cdot \lambda)}\mod n^2=1+\lambda x\cdot n
    於是e(x)λmod  n21)/nμmod  n=(1+λxn1)/nμ=xe(x)^{\lambda}\mod n^2-1)/n\cdot \mu\mod n=(1+\lambda x\cdot n -1)/n\cdot \mu=x成立。

同時,以上流程圖setup 階段,Party 1在發送e(pk1)e(pk_1)的同時,應該再發送proof證明密文e(pk1)e(pk_1)確實是public key P1P_1的祕鑰。Party 2驗證通過後,則setup phase結束。

詳細的協議實現參看 Yehuda Lindell 2017年論文《Fast Secure Two-Party ECDSA Signing》:
在這裏插入圖片描述

2. Schnorr signature

2.1 Schnorr簽名、驗籤

Schnorr signature與ECDSA比,僅有輕微的差異:

  • ECDSA的簽名信息(r,s)(r,s)爲2個scalar,而Schnorr的簽名信息(R,s)(R,s)爲1個point RR和1個scalar ssR=k×GR=k\times G爲a random point on elliptic curve。
  • Shnorr簽名中的ss計算方式不同,s=k+hash(P,R,m)pks=k+hash(P,R,m)\cdot pk,其中pkpk爲私鑰,P=pk×GP=pk\times G爲公鑰,mm爲待簽名消息。
  • Schnorr的驗簽過程,驗證s×G=R+hash(P,R,m)×Ps\times G=R+hash(P,R,m)\times P是否成立。

Schnorr的簽名驗籤總體流程示意圖如下:
在這裏插入圖片描述

2.2 Schnorr signature的優勢

Schnorr signature驗簽過程中使用的方程式s×G=R+hash(P,R,m)×Ps\times G=R+hash(P,R,m)\times P爲線性的。因此有一些很好的特性。如:

2.2.1 Schnorr signature支持 batch validation

在Bitcoin中,需要首先驗證區塊內的所有簽名均有效,若其中某一簽名無效,不用關心具體是哪一個,直接拒絕整個區塊。
若採用ECDSA,需要對每個簽名都分別進行驗證,若區塊內有1000個簽名,則需要進行1000次倒數運算和2000次point multiplication運算,總的有大約3000次heavy operations。
若採用Schnorr signature,則僅需將所有的驗籤方式累加一塊進行驗證,可節約計算資源。若區塊內有1000個簽名,僅需驗證:
(s1+s2++s1000)×G=(R1++R1000)+(hash(P1,R1,m1)×P1++(hash(P1000+R1000+m1000))×P1000)(s_1+s_2+\cdots+s_{1000})\times G=(R_1+\cdots+R_{1000})+(hash(P_1,R_1,m_1)\times P_1+\cdots+(hash(P_{1000}+R_{1000}+m_{1000}))\times P_{1000})
對應有一些point additions(幾乎可忽略相應的計算開銷)和1001次point multiplication,相對於ECDSA方案驗籤速度幾乎提升了3倍。相當於對one heavy operation per signature。

總體示意如下圖所示:
在這裏插入圖片描述

2.2.2 Schnorr signature支持Key aggregation

爲保證比特幣安全,用戶通常會有至少2個不同的私鑰用於控制其所擁有的比特幣。如1個私鑰用於筆記本上的熱錢包,1個私鑰用於硬件錢包或者冷錢包。當某一個私鑰泄露了,要求仍然可以控制比特幣賬戶的安全。

目前採用的方案是使用2-of-2 multisig script,即要求在交易中包含2個不同的簽名。

Naive方案:
採用Schnorr signature,使用2個私鑰(pk1,pk2)(pk_1,pk_2)生成shared public key P=P1+P2=pk1×G+pk2×GP=P_1+P_2=pk_1\times G+pk_2\times G。生成隨機數(k1,k2)(k_1,k_2),對應的隨機point (R1=k1×G,R2=k2×G)(R_1=k_1\times G,R_2=k_2\times G)R=R1+R2R=R_1+R_2計算通用hash(P,R,m)hash(P,R,m),計算s1=k1+hash(hash,R,m)pk1,s2=k2+hash(hash,R,m)pk2s_1=k_1+hash(hash,R,m)\cdot pk_1, s_2=k_2+hash(hash,R,m)\cdot pk_2。基於shared public key P=P1+P2=pk1×G+pk2×GP=P_1+P_2=pk_1\times G+pk_2\times G生成的shared signature爲:(R,s)=(R1+R2,s1+s2)(R,s)=(R_1+R_2,s_1+s_2)
這種直觀naive的簽名方案存在以下幾個問題:

  • 1)要求私鑰方相互間能夠interact。
    在這裏插入圖片描述
    且當有>2>2個以上的私鑰需要進行key aggregation時,整個交互流程將更復雜。
    而事實上上圖流程還需要額外增加一個環節:
    在發送RiR_i之前,應將其hash值ti=hash(Ri)t_i=hash(R_i),這樣每個人才能be sure that you will not change your mind after learning other’s random numbers。

  • 2)存在Rogue key attack流氓密鑰攻擊問題。
    Alice公私鑰對爲(pk1,P1)(pk_1,P_1),同時知道Bob的公鑰(pk2,P2)(pk_2,P_2),Bob可以僞造聲稱其公鑰爲P=P2P1P’=P_2-P1,其他人會認爲P=P1+PP= P_1+P’爲Alice和Bob的aggregated key,但事實上其PP僅包含Bob的公鑰,Bob可以自己進行簽名然後聲稱其爲與Alice的聯合簽名。這就是流氓密鑰攻擊。
    在這裏插入圖片描述
    避免流氓密鑰攻擊的方法之一是要求Alice和Bob都能證明其actually possess the private keys corresponding to their claimed public keys。即each participant would need to prove to others, that their Public Key is valid according to Signature produced by its corresponding Private Key。這種方案,將把問題帶回到on-chain proof for each participant generating a Signature to validate the authenticity of a Public Key, 從而失去了scaling和efficiency benefits。
    需要構建a scheme whose security does not rely on out-of-band verification of the keys。

  • 3)在簽名過程中,無法使用deterministic kk。假設私鑰pk1pk_1被黑客攻擊控制,理論上認爲,仍然可以使用(pk1,pk2)(pk_1,pk_2)聯合簽名保證賬戶資金安全。但是,如下圖所示,私鑰pk2=(s2s2)/(hash(P,R1+R2,m)hash(P,R1+R2,m))pk_2=(s_2-s_2’)/(hash(P,R_1+R_2,m)-hash(P,R_1’+R_2,m))也被泄露。因此,在key aggregation時,需要使用good random number generators everywhere。
    在這裏插入圖片描述

2.2.3 Musig方案

鑑於naïve Schnorr multi-signatures存在以上問題,Blockstream團隊Maxwell等人2018年論文《Simple Schnorr Multi-Signatures with Applications to Bitcoin》中提出了MuSig方案,可有效解決流氓密鑰攻擊問題。
Musig方案的目的是aggregate signatures and public keys from several parties/devices to a single one but without proving that you have a private key corresponding to the public key。
The aggregated signature corresponds to the aggregated public key.
與naïve方案中將所有簽名方公鑰直接相加不同,Musig方案中的aggregated public key生成方式爲:
P=hash(L,P1)×P1++hash(L,Pn)×PnP=hash(L,P_1)\times P_1+\cdots+hash(L,P_n)\times P_n
其中L=hash(P1,,Pn)L=hash(P_1,\cdots,P_n),爲a common number depending on all public keys。
這種非線性可有效防止流氓密鑰攻擊。
Musig的簽名流程爲:

  • 1)每個簽名方都選擇自己的隨機數kik_i,對所有其它方分發Ri(=ki×G)R_i(=k_i\times G)。【各簽名方存在多輪信息交互。】
  • 2)每個簽名方收集好所有其它方發送的RiR_i後,自己計算R=R1++RnR=R_1+\cdots+R_n,然後生成自己的簽名si=ki+hash(P,R,m)hash(L,Pi)pkis_i=k_i+hash(P,R,m)\cdot hash(L,P_i)\cdot pk_i,發送sis_i
  • 3)最終的的aggregated signature爲(R,s)=(R1++Rn,s1++sn)(R,s)=(R_1+\cdots+R_n, s_1+\cdots +s_n)
  • 4)驗簽過程爲,驗證s×G=R+hash(P,R,m)×Ps\times G=R+hash(P,R,m)\times P

2.2.4 Schnorr支持m-of-n multisig

採用的是Merkle Multisig方案。
MuSig和key aggregation要求的是所有簽名方對同一交易進行簽名。當需要2-of-3 multisig with public keys P1,P2,P3P_1,P_2,P_3時,需要construct a Merkle tree of aggregated public keys for所有可能的組合:(P1,P2),(P2,P3),(P1,P3)(P_1,P_2),(P_2,P_3),(P_1,P_3),and put the root in the locking script。當需要spend bitcoins時,需要提供a signature and a proof that our public key is in the tree。

當需要7-of-11 multisig時,涉及的組合可能有11!/7!/4!=33011!/7!/4!=330種,相應的proof將需要8個elements。且對於m-of-n multisig,the number of elements in the proof scales almost linear with the number of keys in multisig (log2(n!/m!/(nm)!)\log_{}2(n!/m!/(n-m)!))。

3. BLS signature

BLS signature 來自於Boneh,Lynn和Shacham 2001年論文《Short signatures from the Weil pairing》。
如Boneh 2018年論文《Compact Multi-Signatures for Smaller Blockchains》中指出,BLS signature具有一些Schnorr簽名所沒有的extremely nice features。

ECDSA 存在的問題是can’t combine signatures or keys and every signature has to be verified independently。對於多重簽名的交易,採用ECDSA的化需要逐個驗證所有公鑰和簽名,浪費區塊空間和交易費用。
Schnorr signature如果設計好的話,支持combine all signatures and public keys in the transaction to a single key and a signature,而且nobody will find out that they correspond to multiple keys。因爲可以一次對所有簽名進行驗證,區塊驗證速度更快。
Schnorr multisig方案存在以下問題:

  • 1)各簽名方需要several communication rounds。當涉及冷錢包密鑰時將很麻煩。
  • 2)signature aggregation時需要依賴random number generator,無法像ECDSA中那樣選擇random point RR deterministically。
  • 3)構建m-of-n multisig需要藉助merkle tree of public keys,相應的proof將get pretty large for large m and n。
  • 4)因爲針對的是同一交易的簽名聚合,無法實現combine all signatures in the block to a single signature。

BLS signature可有效解決以上問題:

  • 1)BLS signature中壓根不需要隨機數。
  • 2)BLS signature支持將區塊內的所有簽名combine to a single signature。
  • 3)BLS signature很容易實現m-of-n multisig。
  • 4)BLS signature不需要serveral communication rounds between signers。
  • 5)BLS signature的簽名長度要比ECDSA和Schnorr短2倍,僅需要a single curve point就可以代表其簽名。

BLS signautre爲completely deterministic signature algorithm。

BLS signature中需要用的兩個關鍵點是:

  • 1)Hashing to the curve:
    ECDSA和Schnorr 簽名過程中,需要使用hash函數將消息mm映射爲a number。
    而BLS signature中需要調整hash算法,將消息mm hashes directly to the elliptic curve。
    最簡單的方式是,仍然將消息mm通過hash函數映射爲a number,然後將該number作爲elliptic curve 上point的x座標。
    Elliptic curves通常有22562^{256}個points,採用SHA-256 算法可以生成256-bit result。
    但是對於y2=x3+ax+by^2=x^3+ax+b形式的eclliptic curve,相同的x座標,存在(x,y)(x,y)(x,y)和(x,-y)兩個point均在curve上的情況。這就意味着藉助SHA-256有約50%的概率能找到two points for some xx,有50%的概率找到point on the curve。
    在這裏插入圖片描述
    爲了保證對任意的消息mm均能hashing to the curve,可以在消息mm後面追加數字,依次嘗試直到能找到相應的curve point。如若hash(m0)hash(m||0)不能find a point,則依次試hash(m1),hash(m2)hash(m||1),hash(m||2),直到找到point on the curve。【對於(x,y)(x,y)(x,y)和(x,-y)兩個point,實際選擇y座標值更小的那個point。】(如上圖所示)

  • 2)curve pairing
    BLS signautre要求能夠將(相同或者不同)curve上的P和Q兩個點映射a number:
    e(P,Q)ne(P,Q)\mapsto n
    同時,應滿足如下屬性:(使得secret number xx unreveal。)
    e(x×P,Q)=e(P,x×Q)e(x\times P,Q)=e(P,x\times Q)
    更通用的表達爲應具有如下屬性:
    e(a×P,b×Q)=e(P,ab×Q)=e(ab×P,Q)=e(P,Q)(ab)e(a\times P,b\times Q)=e(P,ab\times Q)=e(ab\times P,Q)=e(P,Q)^{(ab)}

Bitcoin 的secp256k1不具有pairing屬性,不滿足以上條件。需要使用pairing-friendly curve。

私鑰pkpk,對應的公鑰爲P=pk×GP=pk\times G。待簽名消息mm

3.1 BLS 簽名

BLS signature的簽名流程爲:

  • 1)通過H(m)H(m)將消息mm映射爲point on the curve,Gm=H(m)G_m=H(m)
  • 2)將私鑰與H(m)H(m)相乘,S=pk×H(m)S=pk\times H(m)SS即爲相應的簽名。

BLS signature is just one single point on the curve that takes only 33bytes in compressed serialization format。
具體如下圖示意:
在這裏插入圖片描述

3.2 BLS 驗籤

BLS的驗籤流程爲:

  • 1)通過H(m)H(m)將消息mm映射爲point on the curve,Gm=H(m)G_m=H(m)
  • 2)驗證e(P,H(M))=e(G,S)e(P,H(M))=e(G,S)成立即可。

具有pairing屬性,以上驗籤等式恆成立:
e(P,H(m))=e(pk×G,H(m))=e(G,pk×H(m))=e(G,S)e(P,H(m))=e(pk\times G,H(m))=e(G,pk\times H(m))=e(G,S)
具體如下圖示意:
在這裏插入圖片描述
整個BLS signature非常簡潔優美。

3.3 BLS signature的優勢

3.3.1 BLS支持signature aggregation

與Schnorr aggregation僅支持對同一message mm進行聚合簽名不同,BLS signature支持對不同消息mim_i的不同簽名的聚合,即支持combine all signatures in the block。

假設區塊中有1000筆交易,每筆交易包含簽名SiS_i、公鑰PiP_i及所簽名的消息mim_i
Aggregated signature僅需要對所有的簽名進行累加即可:
S=S1+S2++S1000S=S_1+S_2+\cdots+S_1000

驗籤僅需要驗證以下等式成立即可:
e(G,S)=e(P1,H(m1))e(P2,H(m2))e(P1000,H(m1000))e(G,S)=e(P_1,H(m_1))\cdot e(P_2,H(m_2))\cdots e(P_{1000},H(m_{1000}))

以上等式恆成立,因爲:
e(G,S)=e(G,S1+S2++S1000)=e(G,S1)e(G,S2)e(G,S1000)=e(G,pk1×H(m1))e(G,pk2×H(m2))e(G,pk1000×H(m1000))=e(P1,H(m1))e(P2,H(m2))e(P1000,H(m1000))e(G,S)=e(G,S_1+S_2+\cdots +S_{1000})=e(G,S_1)\cdot e(G,S_2)\cdots e(G,S_{1000})= e(G,pk_1\times H(m_1))\cdot e(G,pk_2\times H(m_2))\cdots e(G,pk_{1000}\times H(m_{1000}))= e(P_1,H(m_1))\cdot e(P_2,H(m_2))\cdots e(P_{1000},H(m_{1000}))
整個signature aggregation仍然需要知道所有的public keys P1,P2,,P1000P_1,P_2,\cdots,P_{1000},需要進行1001次pairing計算,但是可以將區塊內的所有簽名壓縮爲33bytes。而且signature aggregation can be done by a miner and save a lot of space in the block。

3.3.2 BLS支持key aggregation and n-of-n multisignature

對於multisignature,需要sign the same transaction with different keys。BLS可實現與Schnorr類似的key aggregation——combine all signatures and all keys to a single pair of a key and a signature。

Naïve方案爲:
S=S1+S2+S3S=S_1+S_2+S_3
P=P1+P2+P3P=P_1+P_2+P_3
驗籤等式爲:
e(G,S)=e(P,H(m))e(G,S)=e(P,H(m))

以上等式恆成立,因爲:
e(G,S)=e(G,S1+S2+S3)=e(G,(pk1+pk2+pk3)×H(m))=e((pk1+pk2+pk3)×G,H(m))=e(P1+P2+P3,H(m))=e(P,H(m))e(G,S)=e(G,S_1+S_2+S_3)=e(G,(pk_1+pk_2+pk_3)\times H(m))=e((pk_1+pk_2+pk_3)\times G,H(m))=e(P_1+P_2+P_3,H(m))=e(P,H(m))

與Schnorr naïve方案類似,需要能抵抗rogue key attack流氓密鑰攻擊,方式可爲:

  • 要求每個簽名方都證明其擁有與其公鑰對應的私鑰;【會失去scaling和efficiency benefits。】
  • 爲與Musig方案類似,採用nonlinear方式構建SS

具體爲:
S=a1×S1+a2×S2+a3×S3S=a_1\times S_1+a_2\times S_2+a_3\times S_3
P=a1×P1+a2×P2+a3×P3P=a_1\times P_1+a_2\times P_2+a_3\times P_3
其中ai=hash(Pi,P1,P2,P3)a_i=hash(P_i,{P_1,P_2,P_3}),或者實際操作時將這些公鑰拼接在一起再hash,如ai=hash(PiP1P2P3)a_i=hash(P_i||P_1||P_2||P_3)
驗籤等式e(G,S)=e(P,H(m))e(G,S)=e(P,H(m))仍然恆成立。

與Schnorr方案相比,各簽名方不需要進行多輪communication。

3.3.3 BLS支持m-of-n multisig (subgroup multisignature scheme)

爲了支持m-of-n multisig,Schnorr需要藉助merkle tree of public keys。存在的問題是當n,mn,m值增大時,merkle tree size blows up exponentially。

BLS爲了支持m-of-n multisig,需要用到:

  • 1)正常的hash函數,輸出爲a number,hash(x)hash(x)
  • 2)a hash to the curve,輸出爲curve上的point,H(x)H(x)
  • 3)需要有“setup” phase,setup後不再需要communicate,可以用來sign any amount of transactions。

以下以2-of-3 multisig scheme with keys stored on 3 different devices爲例:(可擴展至任意的m,nm,n值。)

  • 1)Setup phase:【要求每個簽名方維護相同的序號1,2,31,2,3,即依次爲簽名方1,簽名方2,簽名方3.。。。】
    P=a1×P1+a2×P2+a3×P3P=a_1\times P_1+a_2\times P_2+a_3\times P_3,其中ai=hash(Pi,P1,P2,P3)a_i=hash(P_i,{P_1,P_2,P_3})
    所有簽名方對數字ii(其值必須在序號範圍內)進行簽名然後key aggregation,每個簽名方ii存儲與其序號一致的key aggregation信息:
    MKi=(a1)×(pk1×H(P,i))+(a2)×(pk2×H(P,i))+(a3)×(pk3×H(P,i))=(a1pk1)×H(P,i)+(a2pk2)×H(P,i)+(a3pk3)×H(P,i)MK_i=(a_1)\times (pk_1\times H(P,i))+ (a_2)\times (pk_2\times H(P,i))+ (a_3)\times (pk_3\times H(P,i))=(a_1\cdot pk_1)\times H(P,i)+ (a_2\cdot pk_2)\times H(P,i)+ (a_3\cdot pk_3)\times H(P,i)
    Setup phase的主要目的就是爲了構建membership key MKiMK_i,用於證明we are valid participants of the multisignature scheme。
    其實MKiMK_i可理解爲對消息H(P,i)H(P,i)的n-of-n signature,滿足:
    e(G,MKi)=e(P,H(P,i))e(G,MK_i)=e(P,H(P,i))

  • 2)簽名階段:
    如使用pk1pk3pk_1和pk_3進行簽名:
    S1=pk1×H(P,m)+MK1,S3=pk3×H(P,m)+MK3S_1=pk_1\times H(P,m)+MK_1,S_3=pk_3\times H(P,m)+MK_3
    直接累加有:
    (S,P)=(S1+S3,P1+P3)(S’,P’)=(S_1+S_3,P_1+P_3)
    其中PP’爲aggregated public key of participating signers。

  • 3)驗籤階段:
    驗證2-of-3 signature,僅需驗證:【驗籤階段,除了P,SP’,S’之外,還需要知道indexes of participating signers,如本例indexes爲數字1和3。】
    e(G,S)=e(P,H(P,m))e(P,H(P,1)+H(P,3))e(G,S’)=e(P’,H(P,m))\cdot e(P,H(P,1)+H(P,3))
    以上等式恆成立。因爲membership keys e(G,S)=e(G,S1+S3)=e(G,pk1×H(P,m)+MK1+pk3×H(P,m)+MK3)=e(P,H(P,m))e(P,H(P,1)+H(P,3))e(G,S’)=e(G,S_1+S_3)=e(G, pk_1\times H(P,m)+MK_1+ pk_3\times H(P,m)+MK_3)= e(P’,H(P,m))\cdot e(P,H(P,1)+H(P,3))

3.4 BLS signature的弊端

BLS signature的弊端主要有:

  • 1)依賴pairing運算,計算效率不高。BLS signature的驗簽過程要比ECDSA要難很多。主要優勢是能將同一區塊內的所有簽名aggregated to almost 32 bytes。Schnorr簽名的aggregated後的驗籤效率要比ECDSA約提高3倍。
  • 2)pairing的安全性證明不易論證。一方面我們希望pairing to be efficient to verify signatures faster,另一方面又不希望reveal any information about our secret key。在選擇paring-friendly curve時要格外小心。

事實上已經存在針對elliptic curve crypto system的MOV attack

參考資料:

[1] https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm
[2] Stepan medium博客 How Schnorr signatures may improve Bitcoin
[3] Stepan medium博客BLS signatures: better than Schnorr
[4] Stepan medium博客 ECDSA is not that bad: two-party signing without Schnorr or BLS
[5] Chris Coverdale bitcointalk博客 Scaling Bitcoin: Schnorr Signatures
[6] Blockstream 博客 Key Aggregation for Schnorr Signatures
[7] Blockstream團隊Maxwell等人2018年論文《Simple Schnorr Multi-Signatures with Applications to Bitcoin

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章