#include double f[12]; char s[32]; extern void curve25519_todouble(double [12],const char s[32]); const double curve25519_constants[21] = { 170141183460469231731687303715884105728.0 /* 2^127 */ , 0.0000000000000000000000000000000000000058774717541114375398436826861112283890933277838604376075437585313920862972736358642578125 /* 2^-127 */ , 0.000000000000000000000000000000000000000000000000000000000000000000000000000328174405093588895764681370786415183702408013848578692630900731866406488520172228202917285131946952609300797169953687216685813759979613974358814143528206841438077390193939208984375 /* 19 2^-255 */ , 2.0 , 28334198897217871282176.0 /* 2^22 (2^52 + 2^51) */ , 59421121885698253195157962752.0 /* 2^43 (2^52 + 2^51) */ , 124615124604835863084731911901282304.0 /* 2^64 (2^52 + 2^51) */ , 261336857795280739939871698507597986398208.0 /* 2^85 (2^52 + 2^51) */ , 1096126227998177188652763624537212264741949407232.0 /* 2^107 (2^52 + 2^51) */ , 2298743311298833287537520540725463775428108683275403264.0 /* 2^128 (2^52 + 2^51) */ , 4820814132776970826625886277023487807566608981348378505904128.0 /* 2^149 (2^52 + 2^51) */ , 10109980000181489923000130657632361502613929158452714680413853843456.0 /* 2^170 (2^52 + 2^51) */ , 42404329554681223909999140017830044379859613525014854994918548831022874624.0 /* 2^192 (2^52 + 2^51) */ , 88928324534258838085302516486672313231311348223211953182303424518077283563470848.0 /* 2^213 (2^52 + 2^51) */ , 186496213653669990808268343055057815037671056549005394040173991334934811379700015824896.0 /* 2^234 (2^52 + 2^51) */ , 391110907456221328563541572174600606921881931583859760122138966276041209554560647587212296192.0 /* 2^255 (2^52 + 2^51) */ , 6755399441055744.0 /* 2^0 (2^52 + 2^51) */ , 1901475900342344102245054808064.0 /* 2^48 (2^52 + 2^51) */ , 2090694862362245919518973588060783891185664.0 /* 2^88 (2^52 + 2^51) */ , 647038720011615355072008362088471136167291466140973739546486645981184.0 /* 2^176 (2^52 + 2^51) */ , 711426596274070704682420131893378505850490785785695625458427396144618268507766784.0 /* 2^216 (2^52 + 2^51) */ } ; int main(int argc,char **argv) { int i; int loop; for (loop = 0;loop < 100;++loop) { for (i = 0;i < 32;++i) s[i] = random(); printf("s=0"); for (i = 0;i < 32;++i) printf("%+d*256^%d",(i == 31 ? 127 : 255) & (int) s[i],i); printf(";\n"); curve25519_todouble(f,s); printf("f=0"); for (i = 0;i < 12;++i) printf("%+.0f",f[i]); printf(";\n"); printf("f-s\n"); } return 0; }