Skip to main content
. 2021 Apr 19;21(8):2859. doi: 10.3390/s21082859
Algorithm 2 Products of optimal Ate pairings on the BN curve (Product method).
Input: s=6t+2, m= the bit length of s, Pj∈G1, Qj∈G2, where j is 1,…,d
Output: eprod(P,Q)
  • 1:

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

  • 2:

    f←1

  • 3:

    forj←1tondo

  • 4:

        Tj←Qj

  • 5:

    end for

  • 6:

    fori←m−2down to 0 do

  • 7:

        f←f2

  • 8:

        for j←1 to d do

  • 9:

            f←f·LTj,Tj(Pj),Tj←[2]Tj

  • 10:

            if s[i]=1 then

  • 11:

               f←f·LTj,Qj(Pj),Tj←Tj+Qj

  • 12:

            else if s[i]=−1 then

  • 13:

               f←f·LTj,−Qj(Pj),Tj←Tj−Qj

  • 14:

            end if

  • 15:

        end for

  • 16:

    end for

  • 17:

    forj←1toddo

  • 18:

        R←π(Qj),f←f·LTj,R(Pj),Tj←Tj+R

  • 19:

        R←π2(Qj),f←f·LTj,−R(Pj),Tj←Tj−R

  • 20:

    end for

  • 21:

    f←f(p12−1)/r

  • 22:

    returnf