Skip to main content
. 2021 Apr 19;21(8):2859. doi: 10.3390/s21082859
Algorithm 1 Optimal Ate pairing on the BN curve.
Input:  s=6t+2, m= the bit length of s, P∈G1, Q∈G2
Output:  e(P,Q)
  • 1:

    Write s in signed binary form, s=∑i=0m−1s[i]2i with s[i]∈{−1,0,1}

  • 2:

    T←Q,f←1

  • 3:

    fori←m−2down to 0 do

  • 4:

        f←f2·LT,T(P),T←2T

  • 5:

        if s[i]=1 then

  • 6:

            f←f·LT,Q(P),T←T+Q

  • 7:

        else if s[i]=−1 then

  • 8:

            f←f·LT,−Q(P),T←T−Q

  • 9:

        end if

  • 10:

    end for

  • 11:

    R←π(Q),f←f·LT,R(P),T←T+R

  • 12:

    R←π2(Q),f←f·LT,−R(P),T←T−R

  • 13:

    f←f(p12−1)/r

  • 14:

    returnf