# Technical Background

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 href="#toc106200554" id="toc106200554"></a>

A cryptographic hash function $$H: {0,1}^\* \rightarrow {0,1}^k$$ takes an arbitrary-length message and outputs a fixed-length output. A hash function has the following basic properties:

&#x20;

· **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** <a href="#toc106200555" id="toc106200555"></a>

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:**&#x20;

1\. Select a random number $$d$$ in the interval $$\[ 1,n-1]$$.

2\. Compute $$Q=dG$$&#x20;

3\. Public key is $$Q$$, private key is $$d$$.

**Signature generation:**&#x20;

1\. Select a random integer $$k$$, $$1≤k≤n$$.

2\. Compute  $$kG = (x\_1,y\_1)$$ and convert $$x\_1$$  to an integer  $$\widehat{x}\_1$$.

3\. Compute $$r=x\_1\ 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:**&#x20;

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 $$u\_1 = ew\ mod\ n$$ and $$u\_2 = rw\ mod\ n$$.

5\. Compute $$X = u\_1G+u\_2Q$$.&#x20;

6\. If $$X=\theta$$ then reject the signature. Otherwise, convert the $$x$$-coordinate $$x\_1$$ of $$X$$ to an integer $$\widehat{x}\_1$$, and compute $$v=\widehat{x}\_1\ mod\ n$$.

## **Aggregated Signatures** <a href="#toc106200556" id="toc106200556"></a>

### **BLS 12381** <a href="#toc106200557" id="toc106200557"></a>

BLS (Boneh, Lynn, Shacham) is another digital signature introduced in 2001 and has an aggregated structure. Let $$e: \mathbb{G}\_1 \times  \mathbb{G}\_2 \rightarrow \mathbb{G}\_3$$ be a pairing where $$\mathbb{G\_1},\ \mathbb{G\_2}$$ are additive groups and $$\mathbb{G\_3}$$ is a multiplicative group. Also, let $$G\_1, G\_2$$ and $$G\_3$$ are base elements of $$\mathbb{G\_1},\ \mathbb{G\_2}$$ and $$\mathbb{G\_3}$$ respectively.

&#x20;

**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]G\_1$$.

**Signing:**

· To sign a message $$m$$ we first need to map $$m$$ onto a point in group $$\mathbb{G\_2}$$. Let’s assume this mapping results in a $$\mathbb{G}\_2$$ point $$H(m)$$.

· We sign the message by calculating the signature $$\sigma=skH(m)$$.

**Verification:**

Given a message $$m$$, a signature $$\sigma$$, 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(G\_1,\sigma) = e(pk,H(m))$$.

**Aggregation**

One of the most important properties of BLS signatures is that they can be [aggregated](https://eprint.iacr.org/2018/483.pdf)

· To aggregate signatures, we just must add up the $$\mathbb{G}*2$$ points they correspond to: $$\sigma*{aggregated} = \sigma\_1 + \sigma\_2 + ...+ \sigma\_n$$.

· We also aggregate the corresponding $$G\_1$$ public key point

&#x20;$$pk\_{aggregated}=pk\_1+pk\_2+...+pk\_n$$.

· Verify that $$e(G\_1,\sigma\_{aggregated})=e(pk\_{aggregated}, H(m))$$ to verify all the signatures together with just two pairings.

### **BN256 Curves** <a href="#toc106200558" id="toc106200558"></a>

BN256 is basically the size of the prime number of the underlying field in $$\mathbb{G}\_1,\ \mathbb{G}\_2$$ and $$\mathbb{G}\_3$$. In a BN256 curve, $$\mathbb{G}\_2$$ is basically$$E(GF(p)),\ \mathbb{G}\_2$$ is a subgroup of $$E(GF(p^{12}))$$ and  $$\mathbb{G}\_3$$ is a subgroup of $$GF(p^{12})$$. Elements of $$\mathbb{G}\_1$$ 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 $$\mathbb{G}\_2$$ 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 $$p^{\frac{12}{6}} = p^2$$.
