View full-text article in PMC Sensors (Basel). 2021 Apr 19;21(8):2859. doi: 10.3390/s21082859 Search in PMC Search in PubMed View in NLM Catalog Add to search Copyright and License information © 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/). PMC Copyright notice Algorithm 1 Optimal Ate pairing on the BN curve. Input: s=6t+2, m= the bit length of s, P∈G1, Q∈G2Output: 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