/** * Copyright (c) 2017 Armando Faz . * Institute of Computing. * University of Campinas, Brazil. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "fp25519_x64.h" int compare_bytes(uint8_t* A, uint8_t* B,unsigned int num_bytes) { unsigned int i=0; uint8_t ret=0; for(i=0;i 0)\ {\ sqr_EltFp25519_1w_x64(a);\ } EltFp25519_1w_Buffer_x64 buffer_1w; EltFp25519_1w_x64 x0, x1, x2; uint64_t * T[5]; uint64_t counter; T[0] = x0; T[1] = pC; /* x^(-1) */ T[2] = x1; T[3] = x2; T[4] = pA; /* x */ copy_EltFp25519_1w_x64(T[1],pA); sqrn_EltFp25519_1w_x64(T[1],1); copy_EltFp25519_1w_x64(T[2],T[1]); sqrn_EltFp25519_1w_x64(T[2],2); mul_EltFp25519_1w_x64(T[0], pA, T[2]); mul_EltFp25519_1w_x64(T[1], T[1], T[0]); copy_EltFp25519_1w_x64(T[2],T[1]); sqrn_EltFp25519_1w_x64(T[2],1); mul_EltFp25519_1w_x64(T[0], T[0], T[2]); copy_EltFp25519_1w_x64(T[2],T[0]); sqrn_EltFp25519_1w_x64(T[2],5); mul_EltFp25519_1w_x64(T[0], T[0], T[2]); copy_EltFp25519_1w_x64(T[2],T[0]); sqrn_EltFp25519_1w_x64(T[2],10); mul_EltFp25519_1w_x64(T[2], T[2], T[0]); copy_EltFp25519_1w_x64(T[3],T[2]); sqrn_EltFp25519_1w_x64(T[3],20); mul_EltFp25519_1w_x64(T[3], T[3], T[2]); sqrn_EltFp25519_1w_x64(T[3],10); mul_EltFp25519_1w_x64(T[3], T[3], T[0]); copy_EltFp25519_1w_x64(T[0],T[3]); sqrn_EltFp25519_1w_x64(T[0],50); mul_EltFp25519_1w_x64(T[0], T[0], T[3]); copy_EltFp25519_1w_x64(T[2],T[0]); sqrn_EltFp25519_1w_x64(T[2],100); mul_EltFp25519_1w_x64(T[2], T[2], T[0]); sqrn_EltFp25519_1w_x64(T[2],50); mul_EltFp25519_1w_x64(T[2], T[2], T[3]); sqrn_EltFp25519_1w_x64(T[2],5); mul_EltFp25519_1w_x64(T[1], T[1], T[2]); #undef sqrn_EltFp25519_1w_x64 } inline void fred_EltFp25519_1w_x64(uint64_t *const c) { int64_t last = (((int64_t*)c)[3])>>63; c[3] &= ((uint64_t)1<<63)-1; c[0] += 19 & last; }