前序博客有:
私钥pkpkpk,对应的公钥为P=pk×GP=pk\times GP=pk×G。待签名消息mmm。
BLS signature的签名流程为:
BLS signature is just one single point on the curve that takes only 33bytes in compressed serialization format。
具体如下图示意:
BLS的验签流程为:
具有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)e(P,H(m))=e(pk×G,H(m))=e(G,pk×H(m))=e(G,S)
具体如下图示意:
整个BLS signature非常简洁优美。
整个BLS签名算法中,有两个关键点是:
1)Hashing to the curve:
ECDSA和Schnorr 签名过程中,需要使用hash函数将消息mmm映射为a number。
而BLS signature中需要调整hash算法,将消息mmm hashes directly to the elliptic curve。
最简单的方式是,仍然将消息mmm通过hash函数映射为a number,然后将该number作为elliptic curve 上point的x坐标。
Elliptic curves通常有22562^{256}2256个points,采用SHA-256
算法可以生成256-bit result。
但是对于y2=x3+ax+by^2=x^3+ax+by2=x3+ax+b形式的eclliptic curve,相同的x坐标,存在(x,y)和(x,−y)(x,y)和(x,-y)(x,y)和(x,−y)两个point均在curve上的情况。这就意味着借助SHA-256
有约50%的概率能找到two points for some xxx,有50%的概率找到point on the curve。
为了保证对任意的消息mmm均能hashing to the curve,可以在消息mmm后面追加数字,依次尝试直到能找到相应的curve point。如若hash(m∣∣0)hash(m||0)hash(m∣∣0)不能find a point,则依次试hash(m∣∣1),hash(m∣∣2)hash(m||1),hash(m||2)hash(m∣∣1),hash(m∣∣2),直到找到point on the curve。【对于(x,y)和(x,−y)(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 ne(P,Q)↦n
同时,应满足如下属性:(使得secret number xxx unreveal。)
e(x×P,Q)=e(P,x×Q)e(x\times P,Q)=e(P,x\times Q)e(x×P,Q)=e(P,x×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)}e(a×P,b×Q)=e(P,ab×Q)=e(ab×P,Q)=e(P,Q)(ab)
Hashing to curve函数HHH需为:
令Fq\mathbb{F}_qFq为某有限域,Eb:y2=x3+bE_b: y^2=x^3+bEb:y2=x3+b为某ordinary椭圆曲线(即,non-supersingular椭圆曲线),其jjj-invariant为0,同时满足b∈Fq\sqrt{b}\in\mathbb{F}_qb∈Fq以及q≢1(mod27)q\not\equiv 1(\mod 27)q≡1(mod27)。
当前最快的constant-time indifferentiable hashing to Eb(Fq)E_b(\mathbb{F}_q)Eb(Fq)算法需要:
在Dmitrii Koshelev 2021年论文 Indifferentiable hashing to ordinary elliptic Fq\mathbb{F}_qFq-curves of j=0j = 0j=0 with the cost of one exponentiation in Fq\mathbb{F}_qFq 论文中,所实现的constant-time indifferentiable hashing to Eb(Fq)E_b(\mathbb{F}_q)Eb(Fq)算法:
开源实现见: