miracl / MIRACL

MIRACL Cryptographic SDK: Multiprecision Integer and Rational Arithmetic Cryptographic Library is a C software library that is widely regarded by developers as the gold standard open source SDK for elliptic curve cryptography (ECC).
https://miracl.com
654 stars 242 forks source link

Pairing of two null elements (minor issue - special case) #29

Open baz1 opened 8 years ago

baz1 commented 8 years ago

Hello,

I recently found one more behavior that I believe is not the one that is expected of a bilinear map: when computing a pairing between two null elements, we get a null element in GT instead of a unity element that would be neutral for multiplication.

#include <iostream>

#define MR_PAIRING_BN
#include "pairing_3.h"

using namespace std;

int main() {
    PFC pfc(192);
    G1 rnd1; pfc.random(rnd1);
    G2 rnd2; pfc.random(rnd2);
    GT test, rndT;

    rndT = pfc.pairing(rnd2, rnd1);

    test = pfc.pairing(G2(), G1());

    cout << (test.g.isunity() ? "unity" : "non-unity") << endl; // displays "non-unity"
    cout << ((rndT == test * rndT) ? "equal" : "non-equal") << endl; // displays "non-equal"
    return 0;
}

Best,

Rémi