diff --git a/include/port.h b/include/port.h new file mode 100644 index 0000000..18fd272 --- /dev/null +++ b/include/port.h @@ -0,0 +1,23 @@ +#ifndef __MPC_LIB_PORT_H__ +#define __MPC_LIB_PORT_H__ + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +// byteswap +#if defined(__APPLE__) + // Mac OS X / Darwin + #include + #define bswap_16(x) OSSwapInt16(x) + #define bswap_32(x) OSSwapInt32(x) + #define bswap_64(x) OSSwapInt64(x) +#else + #include +#endif + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif // __MPC_LIB_PORT_H__ diff --git a/src/common/crypto/GFp_curve_algebra/GFp_curve_algebra.c b/src/common/crypto/GFp_curve_algebra/GFp_curve_algebra.c index 7c77a83..55eb98b 100644 --- a/src/common/crypto/GFp_curve_algebra/GFp_curve_algebra.c +++ b/src/common/crypto/GFp_curve_algebra/GFp_curve_algebra.c @@ -1,8 +1,8 @@ #include "crypto/GFp_curve_algebra/GFp_curve_algebra.h" +#include "port.h" #include #include -#include #include #include diff --git a/src/common/crypto/ed25519_algebra/ed25519_algebra.c b/src/common/crypto/ed25519_algebra/ed25519_algebra.c index cb9b115..af22180 100644 --- a/src/common/crypto/ed25519_algebra/ed25519_algebra.c +++ b/src/common/crypto/ed25519_algebra/ed25519_algebra.c @@ -3,7 +3,7 @@ #include "crypto/keccak1600/keccak1600.h" #include "curve25519.c" -#include +#include "port.h" #include #include diff --git a/src/common/crypto/zero_knowledge_proof/diffie_hellman_log.c b/src/common/crypto/zero_knowledge_proof/diffie_hellman_log.c index 8eefd5d..871dbde 100644 --- a/src/common/crypto/zero_knowledge_proof/diffie_hellman_log.c +++ b/src/common/crypto/zero_knowledge_proof/diffie_hellman_log.c @@ -1,6 +1,6 @@ #include "crypto/zero_knowledge_proof/diffie_hellman_log.h" #include "crypto/drng/drng.h" -#include +#include "port.h" #include #include diff --git a/test/crypto/ed25519_algebra/tests.cpp b/test/crypto/ed25519_algebra/tests.cpp index e7969d7..ba3d55a 100644 --- a/test/crypto/ed25519_algebra/tests.cpp +++ b/test/crypto/ed25519_algebra/tests.cpp @@ -1,10 +1,10 @@ #include "crypto/ed25519_algebra/ed25519_algebra.h" #include "crypto/elliptic_curve_algebra/elliptic_curve256_algebra.h" +#include "port.h" #include #include -#include #include #include diff --git a/test/crypto/secp256k1_algebra/tests.cpp b/test/crypto/secp256k1_algebra/tests.cpp index 8530950..05cba9d 100644 --- a/test/crypto/secp256k1_algebra/tests.cpp +++ b/test/crypto/secp256k1_algebra/tests.cpp @@ -1,11 +1,11 @@ #include "crypto/GFp_curve_algebra/GFp_curve_algebra.h" +#include "port.h" #include #include #include #include -#include #include #include