aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-05-30 05:23:51 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-05-30 05:23:51 +0800
commitcdea71ee335760b0f9cb8422dd995176cf6bdc5f (patch)
tree140cb75fc796420c77ca415b2b28a03d0826634c
parent4854a50087865b7f4f4147a43e9ff21c26df7e1f (diff)
downloaddexon-bls-cdea71ee335760b0f9cb8422dd995176cf6bdc5f.tar
dexon-bls-cdea71ee335760b0f9cb8422dd995176cf6bdc5f.tar.gz
dexon-bls-cdea71ee335760b0f9cb8422dd995176cf6bdc5f.tar.bz2
dexon-bls-cdea71ee335760b0f9cb8422dd995176cf6bdc5f.tar.lz
dexon-bls-cdea71ee335760b0f9cb8422dd995176cf6bdc5f.tar.xz
dexon-bls-cdea71ee335760b0f9cb8422dd995176cf6bdc5f.tar.zst
dexon-bls-cdea71ee335760b0f9cb8422dd995176cf6bdc5f.zip
rename IsSame to IsEqual
-rw-r--r--go/bls/bls.go24
-rw-r--r--go/bls/bls_test.go22
-rw-r--r--include/bls/bls_if.h10
-rw-r--r--src/bls_if.cpp8
-rw-r--r--test/bls_if_test.cpp6
5 files changed, 36 insertions, 34 deletions
diff --git a/go/bls/bls.go b/go/bls/bls.go
index c569f1f..adcacff 100644
--- a/go/bls/bls.go
+++ b/go/bls/bls.go
@@ -139,9 +139,9 @@ func (id *ID) SetDecString(s string) error {
return nil
}
-// IsSame --
-func (id *ID) IsSame(rhs *ID) bool {
- return C.blsIdIsSame(id.getPointer(), rhs.getPointer()) == 1
+// IsEqual --
+func (id *ID) IsEqual(rhs *ID) bool {
+ return C.blsIdIsEqual(id.getPointer(), rhs.getPointer()) == 1
}
// SecretKey --
@@ -220,9 +220,9 @@ func (sec *SecretKey) SetDecString(s string) error {
return nil
}
-// IsSame --
-func (sec *SecretKey) IsSame(rhs *SecretKey) bool {
- return C.blsSecretKeyIsSame(sec.getPointer(), rhs.getPointer()) == 1
+// IsEqual --
+func (sec *SecretKey) IsEqual(rhs *SecretKey) bool {
+ return C.blsSecretKeyIsEqual(sec.getPointer(), rhs.getPointer()) == 1
}
// Init --
@@ -334,9 +334,9 @@ func (pub *PublicKey) SetHexString(s string) error {
return nil
}
-// IsSame --
-func (pub *PublicKey) IsSame(rhs *PublicKey) bool {
- return C.blsPublicKeyIsSame(pub.getPointer(), rhs.getPointer()) == 1
+// IsEqual --
+func (pub *PublicKey) IsEqual(rhs *PublicKey) bool {
+ return C.blsPublicKeyIsEqual(pub.getPointer(), rhs.getPointer()) == 1
}
// Add --
@@ -416,9 +416,9 @@ func (sign *Sign) SetHexString(s string) error {
return nil
}
-// IsSame --
-func (sign *Sign) IsSame(rhs *Sign) bool {
- return C.blsSignatureIsSame(sign.getPointer(), rhs.getPointer()) == 1
+// IsEqual --
+func (sign *Sign) IsEqual(rhs *Sign) bool {
+ return C.blsSignatureIsEqual(sign.getPointer(), rhs.getPointer()) == 1
}
// GetPublicKey --
diff --git a/go/bls/bls_test.go b/go/bls/bls_test.go
index 2561e83..418a664 100644
--- a/go/bls/bls_test.go
+++ b/go/bls/bls_test.go
@@ -21,14 +21,14 @@ func testPre(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !id.IsSame(&id2) {
+ if !id.IsEqual(&id2) {
t.Errorf("not same id\n%s\n%s", id.GetHexString(), id2.GetHexString())
}
err = id2.SetDecString(id.GetDecString())
if err != nil {
t.Fatal(err)
}
- if !id.IsSame(&id2) {
+ if !id.IsEqual(&id2) {
t.Errorf("not same id\n%s\n%s", id.GetDecString(), id2.GetDecString())
}
}
@@ -87,7 +87,7 @@ func testStringConversion(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !sec.IsSame(&sec2) {
+ if !sec.IsEqual(&sec2) {
t.Error("not equal")
}
}
@@ -122,7 +122,7 @@ func testRecoverSecretKey(t *testing.T) {
if err != nil {
t.Error(err)
}
- if !sec.IsSame(&sec2) {
+ if !sec.IsEqual(&sec2) {
t.Errorf("Mismatch in recovered secret key:\n %s\n %s.", sec.GetHexString(), sec2.GetHexString())
}
}
@@ -154,7 +154,7 @@ func testEachSign(t *testing.T, m string, msk []SecretKey, mpk []PublicKey) ([]I
}
t.Logf("pubVec[%d]=%s\n", i, pubVec[i].GetHexString())
- if !pubVec[i].IsSame(secVec[i].GetPublicKey()) {
+ if !pubVec[i].IsEqual(secVec[i].GetPublicKey()) {
t.Errorf("Pubkey derivation does not match\n%s\n%s", pubVec[i].GetHexString(), secVec[i].GetPublicKey().GetHexString())
}
@@ -187,7 +187,7 @@ func testSign(t *testing.T) {
if err != nil {
t.Error(err)
}
- if !sec0.IsSame(&sec1) {
+ if !sec0.IsEqual(&sec1) {
t.Error("Mismatch in recovered seckey.")
}
var pub1 PublicKey
@@ -195,7 +195,7 @@ func testSign(t *testing.T) {
if err != nil {
t.Error(err)
}
- if !pub0.IsSame(&pub1) {
+ if !pub0.IsEqual(&pub1) {
t.Error("Mismatch in recovered pubkey.")
}
var s1 Sign
@@ -203,7 +203,7 @@ func testSign(t *testing.T) {
if err != nil {
t.Error(err)
}
- if !s0.IsSame(&s1) {
+ if !s0.IsEqual(&s1) {
t.Error("Mismatch in recovered signature.")
}
}
@@ -254,7 +254,7 @@ func testData(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !sec1.IsSame(&sec2) {
+ if !sec1.IsEqual(&sec2) {
t.Error("SecretKey not same")
}
pub1 := sec1.GetPublicKey()
@@ -264,7 +264,7 @@ func testData(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !pub1.IsSame(&pub2) {
+ if !pub1.IsEqual(&pub2) {
t.Error("PublicKey not same")
}
m := "doremi"
@@ -275,7 +275,7 @@ func testData(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !sign1.IsSame(&sign2) {
+ if !sign1.IsEqual(&sign2) {
t.Error("Sign not same")
}
}
diff --git a/include/bls/bls_if.h b/include/bls/bls_if.h
index be1467c..c36ad70 100644
--- a/include/bls/bls_if.h
+++ b/include/bls/bls_if.h
@@ -67,8 +67,9 @@ BLS_DLL_API int blsGetCurveOrder(char *buf, size_t maxBufSize);
BLS_DLL_API int blsGetFieldOrder(char *buf, size_t maxBufSize);
// return 1 if same else 0
-BLS_DLL_API int blsIdIsSame(const blsId *lhs, const blsId *rhs);
+BLS_DLL_API int blsIdIsEqual(const blsId *lhs, const blsId *rhs);
+// mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
// return 0 if success
BLS_DLL_API int blsIdSetLittleEndian(blsId *id, const void *buf, size_t bufSize);
BLS_DLL_API int blsIdSetDecStr(blsId *id, const char *buf, size_t bufSize);
@@ -86,8 +87,9 @@ BLS_DLL_API size_t blsIdGetDecStr(char *buf, size_t maxBufSize, const blsId *id)
BLS_DLL_API size_t blsIdGetHexStr(char *buf, size_t maxBufSize, const blsId *id);
// return 1 if same else 0
-BLS_DLL_API int blsSecretKeyIsSame(const blsSecretKey *lhs, const blsSecretKey *rhs);
+BLS_DLL_API int blsSecretKeyIsEqual(const blsSecretKey *lhs, const blsSecretKey *rhs);
+// mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
// return 0 if success
BLS_DLL_API int blsSecretKeySetLittleEndian(blsSecretKey *sec, const void *buf, size_t bufSize);
BLS_DLL_API int blsSecretKeySetDecStr(blsSecretKey *sec, const char *buf, size_t bufSize);
@@ -122,7 +124,7 @@ BLS_DLL_API int blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey *secVe
BLS_DLL_API void blsGetPop(blsSignature *sig, const blsSecretKey *sec);
// return 1 if same else 0
-BLS_DLL_API int blsPublicKeyIsSame(const blsPublicKey *lhs, const blsPublicKey *rhs);
+BLS_DLL_API int blsPublicKeyIsEqual(const blsPublicKey *lhs, const blsPublicKey *rhs);
// return 0 if success
BLS_DLL_API int blsPublicKeyDeserialize(blsPublicKey *pub, const void *buf, size_t bufSize);
/*
@@ -138,7 +140,7 @@ BLS_DLL_API int blsPublicKeyShare(blsPublicKey *pub, const blsPublicKey *mpk, si
BLS_DLL_API int blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const blsId *idVec, size_t n);
// return 1 if same else 0
-BLS_DLL_API int blsSignatureIsSame(const blsSignature *lhs, const blsSignature *rhs);
+BLS_DLL_API int blsSignatureIsEqual(const blsSignature *lhs, const blsSignature *rhs);
// return 0 if success
BLS_DLL_API int blsSignatureDeserialize(blsSignature *sig, const void *buf, size_t bufSize);
diff --git a/src/bls_if.cpp b/src/bls_if.cpp
index 48f16b5..9d0c6ce 100644
--- a/src/bls_if.cpp
+++ b/src/bls_if.cpp
@@ -81,7 +81,7 @@ int blsGetFieldOrder(char *buf, size_t maxBufSize)
return 0;
}
-int blsIdIsSame(const blsId *lhs, const blsId *rhs)
+int blsIdIsEqual(const blsId *lhs, const blsId *rhs)
{
return *(const bls::Id*)lhs == *(const bls::Id*)rhs ? 1 : 0;
}
@@ -110,7 +110,7 @@ size_t blsIdGetHexStr(char *buf, size_t maxBufSize, const blsId *id)
{
return getStrT<bls::Id, blsId>(id, buf, maxBufSize, 16);
}
-int blsSecretKeyIsSame(const blsSecretKey *lhs, const blsSecretKey *rhs)
+int blsSecretKeyIsEqual(const blsSecretKey *lhs, const blsSecretKey *rhs)
{
return *(const bls::SecretKey*)lhs == *(const bls::SecretKey*)rhs ? 1 : 0;
}
@@ -197,7 +197,7 @@ void blsGetPop(blsSignature *sig, const blsSecretKey *sec)
((const bls::SecretKey*)sec)->getPop(*(bls::Signature*)sig);
}
-int blsPublicKeyIsSame(const blsPublicKey *lhs, const blsPublicKey *rhs)
+int blsPublicKeyIsEqual(const blsPublicKey *lhs, const blsPublicKey *rhs)
{
return *(const bls::PublicKey*)lhs == *(const bls::PublicKey*)rhs ? 1 : 0;
}
@@ -257,7 +257,7 @@ int blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const bls
return -1;
}
-int blsSignatureIsSame(const blsSignature *lhs, const blsSignature *rhs)
+int blsSignatureIsEqual(const blsSignature *lhs, const blsSignature *rhs)
{
return *(const bls::Signature*)lhs == *(const bls::Signature*)rhs ? 1 : 0;
}
diff --git a/test/bls_if_test.cpp b/test/bls_if_test.cpp
index 3c75b8b..62b914a 100644
--- a/test/bls_if_test.cpp
+++ b/test/bls_if_test.cpp
@@ -33,21 +33,21 @@ void bls_ifDataTest()
CYBOZU_TEST_ASSERT(0 < n && n <= fpSize * 2);
ret = blsSecretKeySetHexStr(&sec2, buf, n);
CYBOZU_TEST_EQUAL(ret, 0);
- CYBOZU_TEST_ASSERT(blsSecretKeyIsSame(&sec1, &sec2));
+ CYBOZU_TEST_ASSERT(blsSecretKeyIsEqual(&sec1, &sec2));
blsPublicKey pub1, pub2;
blsGetPublicKey(&pub1, &sec1);
n = blsPublicKeySerialize(buf, sizeof(buf), &pub1);
CYBOZU_TEST_EQUAL(n, fpSize * 2);
ret = blsPublicKeyDeserialize(&pub2, buf, n);
CYBOZU_TEST_EQUAL(ret, 0);
- CYBOZU_TEST_ASSERT(blsPublicKeyIsSame(&pub1, &pub2));
+ CYBOZU_TEST_ASSERT(blsPublicKeyIsEqual(&pub1, &pub2));
blsSignature sig1, sig2;
blsSign(&sig1, &sec1, msg, msgSize);
n = blsSignatureSerialize(buf, sizeof(buf), &sig1);
CYBOZU_TEST_EQUAL(n, fpSize);
ret = blsSignatureDeserialize(&sig2, buf, n);
CYBOZU_TEST_EQUAL(ret, 0);
- CYBOZU_TEST_ASSERT(blsSignatureIsSame(&sig1, &sig2));
+ CYBOZU_TEST_ASSERT(blsSignatureIsEqual(&sig1, &sig2));
}
void bls_ifOrderTest(const char *curveOrder, const char *fieldOrder)