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, PG1, QG2
Output:  e(P,Q)
  • 1:

    Write s in signed binary form, s=i=0m1s[i]2i with s[i]{1,0,1}

  • 2:

    TQ,f1

  • 3:

    forim2down to 0 do

  • 4:

        ff2·LT,T(P),T2T

  • 5:

        if s[i]=1 then

  • 6:

            ff·LT,Q(P),TT+Q

  • 7:

        else if s[i]=1 then

  • 8:

            ff·LT,Q(P),TTQ

  • 9:

        end if

  • 10:

    end for

  • 11:

    Rπ(Q),ff·LT,R(P),TT+R

  • 12:

    Rπ2(Q),ff·LT,R(P),TTR

  • 13:

    ff(p121)/r

  • 14:

    returnf