Two gold bitcoins of different sides with trading figures on background

Bilinear pairings on Bitcoin—Pairing-based cryptography: Part 1

This post was first published on Medium.

Pairing-based cryptography is a variant of elliptic curve cryptography, which Bitcoin ECDSA signatures are based on. Thanks to the characteristics of pairing, new cryptographic algorithms and protocols can achieve functions or efficiency which cannot be realized otherwise, such as identity-based encryption (IBE), attribute-based encryption (ABE), authenticated key exchange (AKE), and short signatures.

<span style="font-size: 10pt;">Bilinear Pairing
Bilinear Pairing

Several applications of Pairing-based cryptography have been in practical use in many blockchains.

  1. Zcash implements a zero-knowledge proof algorithm named zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge)
  2. Ethereum supports pairing check to perform zkSNARK verification
  3. DFINITY (now called The Internet Computer) constructed a BLS signature-based scheme, shorter than ECDSA signatures.

We demonstrate pairings can be implemented directly on Bitcoin and thus enable all kinds of pairing-based cryptography applications previously thought impossible on Bitcoin.

Bilinear pairings

A pairing e is simply a function that takes two inputs¹ and returns one output as below.

Pairing

Pairing

A bilinear pairing has the following property:

: Bilinear map equations
Bilinear map equations

That is, it is linear in each of its inputs separately. It is easy to see the following holds.linear equation

Intuitively, one can swap the scalar n between its inputs and take it out as an exponent.

A Toy Example

Let us look at the following pairing function.

pairing function

It is bilinear because it satisfies the two equations above. For instance,

linear equations

Bilinear pairings on elliptic curves

In practice, the pairing above is not secure for cryptographic use. Instead, we use pairings over elliptic curves. The inputs are points on an elliptic curve and the output is a number². There are multiple ways to construct pairings over elliptic curves, such as WeilTate, and Ate pairings.

Miller’s Algorithm

Miller’s algorithm is used to efficiently compute pairings. It consists of two parts:

  1. main loop: Line 3 to 10. It is structurally akin to the double-and-add algorithm when calculating scalar point multiplication.
  2. final exponentiation at Line 11.

p, k, and r are parameters of the elliptic curve used³.

Miller’s algorithm to compute the Tate pairing e(P, Q)

Miller’s algorithm to compute the Tate pairing e(P, Q)

Implementation

We have implemented the Miller’s algorithm to compute Tate pairings below, based on our elliptic curve arithmetic library.

Implementing Tate pairing e(P, Q)

linefunc(P, Q, R) is a line function that passes through P and Q and is evaluated at R.

***

NOTES:

[1] Thus the name pairing.

[2] Strictly speaking, it is an element in a multiplicative group. Since this serves as an introduction on pairings, we choose readability over mathematical rigor throughout the article.

[3] Not all elliptic curves can be used for pairings. Only ones where pairings are efficiently computable are used in practice. They are called pairing-friendly curves, of which Barreto-Naehrig (BN) or Boneh–Lynn–Shacham (BLS) curves are notable examples.

Watch: Dr. Craig Wright’s Keynote speech: Cloud Security, Overlays & Blockchain at the BSV Global Blockchain Convention

YouTube video

New to blockchain? Check out CoinGeek’s Blockchain for Beginners section, the ultimate resource guide to learn more about blockchain technology.