In B2 Sidechain, all transactions are being signed by the ECDSA signature algorithm which is described in following subsection. The raw transaction is first digested by the hash function (Keccak), and then the hash value is signed by the senderβs private key through ECDSA. The current version of Parlia consensus does not provide fast finality because one validator produces a block, and to make sure of the correctness of these operations, one has to wait for the long confirmation time, usually it is
2/3βN+1
where
N
enotes the active validators. Aggregated signature mechanism with Parliaβs fast-finality can solve this problem because one can collect and convert many signatures into one aggregated signature and send only this aggregated signature to the chain. For the aggregated signature, some special elliptic curves such as BLS12381 or BN256 will be used.
Cryptographic Hash functions
A cryptographic hash function
H:{0,1}ββ{0,1}k
takes an arbitrary-length message and outputs a fixed-length output. A hash function has the following basic properties:
Β· Deterministic: Given
m
, we always have
x=H(m)
(the same input
m
always results in the same output
x
).
Β· Efficient: it is very fast to compute the hash value for any given message.
Β· Pre-image resistance (one-wayness): For essentially all pre-specified outputs, it is computationally infeasible to find any input which hashed to that output.
Β· Second pre-image resistance It is computationally infeasible to find a second message that produces the same hash value.
Β· Collision resistant: It is also hard to find two arbitrary inputs
x
and
y
that hash to the same value, i.e.,
H(x)=H(y)
.
Digital Signatures: ECDSA Signing Algorithm
Letβs assume that
n
is order point,
P
and
Q
are two points on an elliptic curve, and
G
is a base point. The ECDSA signature algorithm can be described as follows:
Key generation:
1. Select a random number
d
in the interval
[1,nβ1]
.
2. Compute
Q=dG
3. Public key is
Q
, private key is
d
.
Signature generation:
1. Select a random integer
k
,
1β€kβ€n
.
2. Compute
kG=(x1β,y1β)
and convert
x1β
to an integer
x1β
.
3. Compute
r=x1βΒ modΒ n
. If
r=0
then go to step 1.
4. Compute
kβ1Β modΒ n
.
5. Compute
Hash(m)
and convert this bit string to an integer
e
.
6. Compute
s=kβ1(e+dr)Β modΒ n
. If
s=0
then go to step 1.
7. Signature for the message
m
is
(r,s)
.
Signature verification:
1. Verify that
r
and
s
are integers in the interval
[1,nβ1]
.
2. Compute
Hash(m)
and convert this bit string to an integer
e
.
3. Compute
w=sβ1Β modΒ n
.
4. Compute
u1β=ewΒ modΒ n
and
u2β=rwΒ modΒ n
.
5. Compute
X=u1βG+u2βQ
.
6. If
X=ΞΈ
then reject the signature. Otherwise, convert the
x
-coordinate
x1β
of
X
to an integer
x1β
, and compute
v=x1βΒ modΒ n
.
Aggregated Signatures
BLS 12381
BLS (Boneh, Lynn, Shacham) is another digital signature introduced in 2001 and has an aggregated structure. Let
e:G1βΓG2ββG3β
be a pairing where
G1β,Β G2β
are additive groups and
G3β
is a multiplicative group. Also, let
G1β,G2β
and
G3β
are base elements of
G1β,Β G2β
and
G3β
respectively.
Public and Private Key Pair
(pk,sk)
:
Β· The private key
sk
to be used for signing is just a randomly chosen number between
[1,rβ1]
.
Β· The corresponding public key is
pk=[sk]G1β
.
Signing:
Β· To sign a message
m
we first need to map
m
onto a point in group
G2β
. Letβs assume this mapping results in a
G2β
point
H(m)
.
Β· We sign the message by calculating the signature
Ο=skH(m)
.
Verification:
Given a message
m
, a signature
Ο
, and a public key
pk
, we want to verify that it was signed with the
sk
.
Β· The signature is valid if, and only if,
e(G1β,Ο)=e(pk,H(m))
.
Aggregation
One of the most important properties of BLS signatures is that they can be aggregatedβ
Β· To aggregate signatures, we just must add up the
G2β
points they correspond to:
Οaggregatedβ=Ο1β+Ο2β+...+Οnβ
.
Β· We also aggregate the corresponding
G1β
public key point
pkaggregatedβ=pk1β+pk2β+...+pknβ
.
Β· Verify that
e(G1β,Οaggregatedβ)=e(pkaggregatedβ,H(m))
to verify all the signatures together with just two pairings.
BN256 Curves
BN256 is basically the size of the prime number of the underlying field in
G1β,Β G2β
and
G3β
. In a BN256 curve,
G2β
is basically
E(GF(p)),Β G2β
is a subgroup of
E(GF(p12))
and
G3β
is a subgroup of
GF(p12)
. Elements of
G1β
requires the same number of bits as
p
for each elliptic curve point. We would like to highlight that not all prime-friendly curves support cofactor 1. This means that we may need a larger prime for a particular group order in some cases. Elements of
G2β
require the same as
pk
for each elliptic curve point coordinate, where
k
is the embedding degree of the curve. When using twisted curves, we can reduce this by 2, 3, 4, or 6 depending on the curve. BN curves have embedding degree 12 and support twists, therefore we can use elements with the same size as