Implementation of the Barreto-Naehrig (BN) curve construction from
[BCTV2015] to provide two cyclic groups
Let
This bilinearity property is what makes pairings such a powerful primitive in cryptography. It satisfies:
$e(g_1+g_2,h) = e(g_1,h) e(g_2, h)$ $e(g,h_1+h_2) = e(g, h_1) e(g, h_2)$
The non-degeneracy property guarantees non-trivial pairings for non-trivial arguments. In other words, being non-degenerate means that:
-
$\forall g \neq 1, \exists h_i \in \mathbb{G}_2$ such that$e(g,h_i) \neq 1$ -
$\forall h \neq 1, \exists g_i \in \mathbb{G}_1$ such that$e(g_i,h) \neq 1$
An example of a pairing would be the scalar product on euclidean space
A simple example of calculating the optimal ate pairing given two points in
import Protolude
import Data.Group (pow)
import Data.Curve.Weierstrass (Point(A), mul')
import Data.Pairing.BN254 (BN254, G1, G2, pairing)
p :: G1 BN254
p = A
1368015179489954701390400359078579693043519447331113978918064868415326638035
9918110051302171585080402603319702774565515993150576347155970296011118125764
q :: G2 BN254
q = A
[2725019753478801796453339367788033689375851816420509565303521482350756874229
,7273165102799931111715871471550377909735733521218303035754523677688038059653
]
[2512659008974376214222774206987427162027254181373325676825515531566330959255
,957874124722006818841961785324909313781880061366718538693995380805373202866
]
main :: IO ()
main = do
putText "P:"
print p
putText "Q:"
print q
putText "e(P, Q):"
print (pairing p q)
putText "e(P, Q) is bilinear:"
print (pairing (mul' p a) (mul' q b) == pow (pairing p q) (a * b))
where
a = 2 :: Int
b = 3 :: Int
Pairings are used in encryption algorithms, such as identity-based encryption (IBE), attribute-based encryption (ABE), (inner-product) predicate encryption, short broadcast encryption and searchable encryption, among others. It allows strong encryption with small signature sizes.
A pairing
The embedding degree
- It's the value that makes
$\mathbb{F}_{q^k}$ be the smallest extension of $\mathbb{F}q$ such that $E(\mathbb{F}{q^k})$ captures more points of order$r$ . - It's the minimal value that holds
$r | (q^k - 1)$ . - It's the smallest positive integer such that
$E[r] \subset E(\mathbb{F}_{q^k})$ .
There are subtle but relevant differences in
The Tate pairing is a map:
$$ \text{tr} : E(\mathbb{F}{q^k})[r] \times E(\mathbb{F}{q^k}) / r E(\mathbb{F}{q^k}) \rightarrow \mathbb{F}^{\star}{q^k} / (\mathbb{F}^{\star}_{q^k})^r $$
defined as:
where $P \in E(\mathbb{F}{q^k})[r]$, $Q$ is any representative in a equivalence
class in $E(\mathbb{F}{q^k}) / rE(\mathbb{F}{q^k})$ and $\mathbb{F}{q^k}^{\ast} / (\mathbb{F}{q^k}^{\ast})^r$ is the set of
equivalence classes of $\mathbb{F}{q^k}^{\ast}$ under the
equivalence relation
The reduced Tate pairing solves this undesirable property by exponentiating elements in $\mathbb{F}{q^k}^{\ast} / (\mathbb{F}{q^k}^{\ast})^r$ to the power of
$$ \text{Tr}(P, Q) = \text{tr}(P, Q)^{#\mathbb{F}{q^k / r}} = f{r,P}(D_Q)^{(q^k - 1) / r} $$
When we say Tate pairing, we will mean the reduced Tate pairing.
Tate pairings use Miller's algorithm, which is essentially the double-and-add algorithm for elliptic curve point multiplication combined with evaluation of the functions used in the addition process. Miller's algorithm remains the fastest algorithm for computing pairings to date.
Both
Most operations in pairings happen in the extension field $\mathbb{F}{q^k}$. The larger $k$ gets, the more complex $\mathbb{F}{q^k}$ becomes and the more computationally expensive the pairing becomes. The complexity of Miller's algorithm heavily depends on the complexity of the associated $\mathbb{F}{q^k}$-arithmetic. Therefore, the aim is to minimize the cost of arithmetic in $\mathbb{F}{q^k}$.
It is possible to construct an extension of a field $\mathbb{F}{q^k}$ by successively towering up intermediate fields $\mathbb{F}{q^a}$ and $\mathbb{F}{q^b}$ such that $k = a^i b^j$, where $a$ and $b$ are usually 2 and 3. One of the reasons tower extensions work is that quadratic and cubic extensions ($\mathbb{F}{q^2}$ and
Miller's algorithm in the Tate pairing iterates as far as the prime group order
We have implemented a polymorphic optimal ate pairing over the following pairing-friendly elliptic curves:
- Barreto-Lynn-Scott degree 12 curves
- Barreto-Naehrig curves
A more detailed documentation on their domain parameters can be found in our elliptic curve library.
This is experimental code meant for research-grade projects only. Please do not use this code in production until it has matured significantly.
Copyright (c) 2018-2020 Adjoint Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.