template class xf::security::bls

#include "bls.hpp"

Overview

BLS curve pairing. This class template provide basic operators in BLS processing.

Parameters:

W Bit length of curve parameters. Parameters should all be smaller than 2^W.
template <int W>
class bls

// fields

ap_uint <W> a
ap_uint <W> b
ap_uint <W> p

Fields

ap_uint <W> a

curve definition parameter for y^2 = x^3 + ax + b in GF(p)

ap_uint <W> b

curve definition parameter for y^2 = x^3 + ax + b in GF(p)

ap_uint <W> p

curve definition parameter for y^2 = x^3 + ax + b in GF(p)

Methods

add

void add (
    ap_uint <W> Px,
    ap_uint <W> Py,
    ap_uint <W> Qx,
    ap_uint <W> Qy,
    ap_uint <W>& Rx,
    ap_uint <W>& Ry
    )

perform point addition in BLS curve ( R = P + Q)

Parameters:

Px X coordinate of point P. Should be smaller than p.
Py Y coordinate of point P. Should be smaller than p.
Qx X coordinate of point Q. Should be smaller than p.
Qy Y coordinate of point Q. Should be smaller than p.
Rx X coordinate of point R. Should be smaller than p.
Ry Y coordinate of point R. Should be smaller than p.

dotProduct

void dotProduct (
    ap_uint <W> Px,
    ap_uint <W> Py,
    ap_uint <W> k,
    ap_uint <W>& Rx,
    ap_uint <W>& Ry
    )

perform point multiply scalar in curve ( R = P * k)

Parameters:

Px X coordinate of point P. Should be smaller than p.
Py Y coordinate of point P. Should be smaller than p.
k A scalar in GF(p). Should be smaller than p.
Rx X coordinate of point R. Should be smaller than p.
Ry Y coordinate of point R. Should be smaller than p.

generatePublicKey

void generatePublicKey (
    ap_uint <W> Gx,
    ap_uint <W> Gy,
    ap_uint <W> privateKey,
    ap_uint <W>& Px,
    ap_uint <W>& Py
    )

Generate Public Key point P from Generation point G and private key.

Parameters:

Gx X coordinate of point G. Should be smaller than p.
Gy Y coordinate of point G. Should be smaller than p.
privateKey Private Key. Should be smaller than p.
Px X coordinate of point P. Should be smaller than p.
Py Y coordinate of point P. Should be smaller than p.

init

void init (
    ap_uint <W> inputA,
    ap_uint <W> inputB,
    ap_uint <W> inputP
    )

Setup parameters for curve of y^2 = x^3 + ax + b in GF(p)

Parameters:

inputA Parameter a for y^2 = x^3 + ax + b in GF(p)
inputB Parameter b for y^2 = x^3 + ax + b in GF(p)
inputP Parameter p for y^2 = x^3 + ax + b in GF(p)

encrypt

void encrypt (
    ap_uint <W> Gx,
    ap_uint <W> Gy,
    ap_uint <W> Px,
    ap_uint <W> Py,
    ap_uint <W> randomKey,
    ap_uint <W> PMx,
    ap_uint <W> PMy,
    ap_uint <W>& C1x,
    ap_uint <W>& C1y,
    ap_uint <W>& C2x,
    ap_uint <W>& C2y
    )

Encrypt a message point PM, using public key point P, generation point of Curve G and a random Key. It will produce point pair {C1, C2} as encrypted message.

Parameters:

Gx X coordinate of Curve Generation Point G. Should be smaller than p.
Gy Y coordinate of Curve Generation Point G. Should be smaller than p.
Px X coordinate of Public Key P. Should be smaller than p.
Py Y coordinate of Public Key P. Should be smaller than p.
randomKey random key for encryption. Should be smaller than p.
PMx X coordinate of Plain message. Should be smaller than p.
PMy Y coordinate of Plain message. Should be smaller than p.
C1x X coordinate of Point C1 in encrypted message point pair. Should be smaller than p.
C1y Y coordinate of Point C1 in encrypted message point pair. Should be smaller than p.
C2x X coordinate of Point C2 in encrypted message point pair. Should be smaller than p.
C2y Y coordinate of Point C2 in encrypted message point pair. Should be smaller than p.

genkey

void genkey (
    ap_uint <W> C1x,
    ap_uint <W> C1y,
    ap_uint <W> C2x,
    ap_uint <W> C2y,
    ap_uint <W> privateKey,
    ap_uint <W>& PMx,
    ap_uint <W>& PMy
    )

genkey an encrypted message point pair {C1, C2} with privateKey It will produce plain message point PM.

Parameters:

C1x X coordinate of Point C1 in encrypted message point pair. Should be smaller than p.
C1y Y coordinate of Point C1 in encrypted message point pair. Should be smaller than p.
C2x X coordinate of Point C2 in encrypted message point pair. Should be smaller than p.
C2y Y coordinate of Point C2 in encrypted message point pair. Should be smaller than p.
privateKey Private Key.
PMx X coordinate of Plain message. Should be smaller than p.
PMy Y coordinate of Plain message. Should be smaller than p.