miracl / MIRACL

MIRACL Cryptographic SDK: Multiprecision Integer and Rational Arithmetic Cryptographic Library is a C software library that is widely regarded by developers as the gold standard open source SDK for elliptic curve cryptography (ECC).
https://miracl.com
653 stars 242 forks source link

output of SHA512 function is not same in 64 and 32 bit machine #75

Open urbi001 opened 5 years ago

urbi001 commented 5 years ago

The output of SHA512 function is giving different output in MIRACL for 64 and 32 bit machine. How can we handle this issue? string R_A="11110000000001010110110011001010110111011110110011111110101000110111110000100101011001101110111110001111010001000110010100110011"; / initialise curve for points in G1 START

ifdef AFFINE

    ecurve(A,B,p,MR_AFFINE);
#endif
#ifdef PROJECTIVE
    ecurve(A,B,p,MR_PROJECTIVE);
#endif
// initialise curve for points in G1 END

P_A= hash_and_map((char *)&R_A[0], cof); hash_and_map function calls H1() which hashes a zero-terminated string to a number < modulus. The output of H1 in 64-bit is: 26F10CF41B42CCD067569104F11E9DCD653CCD2D4EE4435C429F66A6A6A47DFA6B4A88D82BF6D4D8BFF7F4A547A912C3F5AAE43A99221310144E1D6B7E9CF9E0 The output of H1 in 32-bit is: 27F10DF41C42CDD067569205F21F9DCD663CCE2E4EE4435D439F67A6A6A47EFA6B4B88D82CF6D5D8BFF7F4A547A912C4F6AAE43A9A221310154F1D6B7E9CFAE0

mcarrickscott commented 5 years ago

Hello,

I am guessing that the program you are trying to run is ake2sst.cpp ?

Can you confirm? Have you modified the program in any way?

Wait a minute - I think I see what the problem may be..

In hash_and_map change

    else         h+=s[j++];

to

    else         h+=(int)s[j++]&0xff;

Mike

On Mon, Apr 8, 2019 at 8:17 AM urbi001 notifications@github.com wrote:

The output of SHA512 function is giving different output in MIRACL for 64 and 32 bit machine. How can we handle this issue? string R_A="11110000000001010110110011001010110111011110110011111110101000110111110000100101011001101110111110001111010001000110010100110011"; / initialise curve for points in G1 START

ifdef AFFINE

ecurve(A,B,p,MR_AFFINE);

endif

ifdef PROJECTIVE

ecurve(A,B,p,MR_PROJECTIVE);

endif

// initialise curve for points in G1 END P_A= hash_and_map((char *)&R_A[0], cof); hash_and_map function calls H1() which hashes a zero-terminated string to a number < modulus. The output of H1 in 64-bit is: 26F10CF41B42CCD067569104F11E9DCD653CCD2D4EE4435C429F66A6A6A47DFA6B4A88D82BF6D4D8BFF7F4A547A912C3F5AAE43A99221310144E1D6B7E9CF9E0 The output of H1 in 32-bit is:

27F10DF41C42CDD067569205F21F9DCD663CCE2E4EE4435D439F67A6A6A47EFA6B4B88D82CF6D5D8BFF7F4A547A912C4F6AAE43A9A221310154F1D6B7E9CFAE0

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/miracl/MIRACL/issues/75, or mute the thread https://github.com/notifications/unsubscribe-auth/ACm8juS3Bb8IGgc1TChwWaRXssI0iQaoks5veu0AgaJpZM4chd4V .