aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-03-08 14:42:17 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-03-08 14:42:17 +0800
commitf7170d6c8d4a0c22e1a5cf61bcf0c39e4efda389 (patch)
tree00a3539fbb5f7b7f7d7279d029612c09c2f1b8d0
parent2d538d8c593bbbef87a946243389807a7befe80b (diff)
downloaddexon-mcl-f7170d6c8d4a0c22e1a5cf61bcf0c39e4efda389.tar.gz
dexon-mcl-f7170d6c8d4a0c22e1a5cf61bcf0c39e4efda389.tar.zst
dexon-mcl-f7170d6c8d4a0c22e1a5cf61bcf0c39e4efda389.zip
avoid size_t because it is depends on 32/64-bit architecture
-rw-r--r--ffi/cs/bn256.cs8
-rw-r--r--include/mcl/bn256.h9
-rw-r--r--src/bn256.cpp16
3 files changed, 16 insertions, 17 deletions
diff --git a/ffi/cs/bn256.cs b/ffi/cs/bn256.cs
index adf999b..95048e1 100644
--- a/ffi/cs/bn256.cs
+++ b/ffi/cs/bn256.cs
@@ -28,7 +28,7 @@ namespace mcl {
[DllImport("bn256.dll")]
public static extern void BN256_Fr_setMsg([Out] Fr x, [In][MarshalAs(UnmanagedType.LPStr)] string s);
[DllImport("bn256.dll")]
- public static extern int BN256_Fr_getStr([Out]StringBuilder buf, long maxBufSize, [In] Fr x);
+ public static extern int BN256_Fr_getStr([Out]StringBuilder buf, int maxBufSize, [In] Fr x);
[DllImport("bn256.dll")]
public static extern void BN256_Fr_neg([Out] Fr y, [In] Fr x);
@@ -56,7 +56,7 @@ namespace mcl {
[DllImport("bn256.dll")]
public static extern int BN256_G1_hashAndMapTo([Out] G1 x, [In][MarshalAs(UnmanagedType.LPStr)] string s);
[DllImport("bn256.dll")]
- public static extern int BN256_G1_getStr([Out]StringBuilder buf, long maxBufSize, [In] G1 x);
+ public static extern int BN256_G1_getStr([Out]StringBuilder buf, int maxBufSize, [In] G1 x);
[DllImport("bn256.dll")]
public static extern void BN256_G1_neg([Out] G1 y, [In] G1 x);
[DllImport("bn256.dll")]
@@ -81,7 +81,7 @@ namespace mcl {
[DllImport("bn256.dll")]
public static extern int BN256_G2_hashAndMapTo([Out] G2 x, [In][MarshalAs(UnmanagedType.LPStr)] string s);
[DllImport("bn256.dll")]
- public static extern int BN256_G2_getStr([Out]StringBuilder buf, long maxBufSize, [In] G2 x);
+ public static extern int BN256_G2_getStr([Out]StringBuilder buf, int maxBufSize, [In] G2 x);
[DllImport("bn256.dll")]
public static extern void BN256_G2_neg([Out] G2 y, [In] G2 x);
[DllImport("bn256.dll")]
@@ -104,7 +104,7 @@ namespace mcl {
[DllImport("bn256.dll")]
public static extern int BN256_GT_isOne([In] GT x);
[DllImport("bn256.dll")]
- public static extern int BN256_GT_getStr([Out]StringBuilder buf, long maxBufSize, [In] GT x);
+ public static extern int BN256_GT_getStr([Out]StringBuilder buf, int maxBufSize, [In] GT x);
[DllImport("bn256.dll")]
public static extern void BN256_GT_neg([Out] GT y, [In] GT x);
[DllImport("bn256.dll")]
diff --git a/include/mcl/bn256.h b/include/mcl/bn256.h
index cb68d8c..8f4f803 100644
--- a/include/mcl/bn256.h
+++ b/include/mcl/bn256.h
@@ -7,7 +7,6 @@
http://opensource.org/licenses/BSD-3-Clause
*/
#include <stdint.h>
-#include <stddef.h>
#ifdef __cplusplus
extern "C" {
@@ -87,7 +86,7 @@ BN256_DLL_API void BN256_Fr_setRand(BN256_Fr *x);
BN256_DLL_API void BN256_Fr_setMsg(BN256_Fr *x, const char *s);
// return 0 if success
-BN256_DLL_API int BN256_Fr_getStr(char *buf, size_t maxBufSize, const BN256_Fr *x);
+BN256_DLL_API int BN256_Fr_getStr(char *buf, int maxBufSize, const BN256_Fr *x);
BN256_DLL_API void BN256_Fr_neg(BN256_Fr *y, const BN256_Fr *x);
BN256_DLL_API void BN256_Fr_inv(BN256_Fr *y, const BN256_Fr *x);
@@ -113,7 +112,7 @@ BN256_DLL_API int BN256_G1_isZero(const BN256_G1 *x);
BN256_DLL_API int BN256_G1_hashAndMapTo(BN256_G1 *x, const char *s);
// return 0 if success
-BN256_DLL_API int BN256_G1_getStr(char *buf, size_t maxBufSize, const BN256_G1 *x);
+BN256_DLL_API int BN256_G1_getStr(char *buf, int maxBufSize, const BN256_G1 *x);
BN256_DLL_API void BN256_G1_neg(BN256_G1 *y, const BN256_G1 *x);
BN256_DLL_API void BN256_G1_dbl(BN256_G1 *y, const BN256_G1 *x);
@@ -138,7 +137,7 @@ BN256_DLL_API int BN256_G2_isZero(const BN256_G2 *x);
BN256_DLL_API int BN256_G2_hashAndMapTo(BN256_G2 *x, const char *s);
// return 0 if success
-BN256_DLL_API int BN256_G2_getStr(char *buf, size_t maxBufSize, const BN256_G2 *x);
+BN256_DLL_API int BN256_G2_getStr(char *buf, int maxBufSize, const BN256_G2 *x);
BN256_DLL_API void BN256_G2_neg(BN256_G2 *y, const BN256_G2 *x);
BN256_DLL_API void BN256_G2_dbl(BN256_G2 *y, const BN256_G2 *x);
@@ -161,7 +160,7 @@ BN256_DLL_API int BN256_GT_isZero(const BN256_GT *x);
BN256_DLL_API int BN256_GT_isOne(const BN256_GT *x);
// return 0 if success
-BN256_DLL_API int BN256_GT_getStr(char *buf, size_t maxBufSize, const BN256_GT *x);
+BN256_DLL_API int BN256_GT_getStr(char *buf, int maxBufSize, const BN256_GT *x);
BN256_DLL_API void BN256_GT_neg(BN256_GT *y, const BN256_GT *x);
BN256_DLL_API void BN256_GT_inv(BN256_GT *y, const BN256_GT *x);
diff --git a/src/bn256.cpp b/src/bn256.cpp
index dbccca7..1254414 100644
--- a/src/bn256.cpp
+++ b/src/bn256.cpp
@@ -124,12 +124,12 @@ void BN256_Fr_setMsg(BN256_Fr *x, const char *str)
}
// return 0 if success
-int BN256_Fr_getStr(char *buf, size_t maxBufSize, const BN256_Fr *x)
+int BN256_Fr_getStr(char *buf, int maxBufSize, const BN256_Fr *x)
try
{
std::string str;
cast(x)->getStr(str);
- if (str.size() < maxBufSize) {
+ if ((int)str.size() < maxBufSize) {
memcpy(buf, str.c_str(), str.size() + 1);
return 0;
}
@@ -214,12 +214,12 @@ int BN256_G1_hashAndMapTo(BN256_G1 *x, const char *str)
}
// return 0 if success
-int BN256_G1_getStr(char *buf, size_t maxBufSize, const BN256_G1 *x)
+int BN256_G1_getStr(char *buf, int maxBufSize, const BN256_G1 *x)
try
{
std::string str;
cast(x)->getStr(str);
- if (str.size() < maxBufSize) {
+ if ((int)str.size() < maxBufSize) {
memcpy(buf, str.c_str(), str.size() + 1);
return 0;
}
@@ -300,12 +300,12 @@ int BN256_G2_hashAndMapTo(BN256_G2 *x, const char *str)
}
// return 0 if success
-int BN256_G2_getStr(char *buf, size_t maxBufSize, const BN256_G2 *x)
+int BN256_G2_getStr(char *buf, int maxBufSize, const BN256_G2 *x)
try
{
std::string str;
cast(x)->getStr(str);
- if (str.size() < maxBufSize) {
+ if ((int)str.size() < maxBufSize) {
memcpy(buf, str.c_str(), str.size() + 1);
return 0;
}
@@ -375,11 +375,11 @@ int BN256_GT_isOne(const BN256_GT *x)
}
// return 0 if success
-int BN256_GT_getStr(char *buf, size_t maxBufSize, const BN256_GT *x)
+int BN256_GT_getStr(char *buf, int maxBufSize, const BN256_GT *x)
try
{
std::string str = cast(x)->getStr();
- if (str.size() < maxBufSize) {
+ if ((int)str.size() < maxBufSize) {
memcpy(buf, str.c_str(), str.size() + 1);
return 0;
}