Skip to content

Instantly share code, notes, and snippets.

@krngrvr09
Created July 24, 2020 18:17
Show Gist options
  • Select an option

  • Save krngrvr09/54719a155e92487e1ce122660c6a69f3 to your computer and use it in GitHub Desktop.

Select an option

Save krngrvr09/54719a155e92487e1ce122660c6a69f3 to your computer and use it in GitHub Desktop.
diff --git a/src/crypto/PBC.cpp b/src/crypto/PBC.cpp
index 1b9c98b..232c6ec 100644
--- a/src/crypto/PBC.cpp
+++ b/src/crypto/PBC.cpp
@@ -119,14 +119,14 @@ unsigned char* PBC::hash(std::string message, element_s *pk) {
byte *messageHash = new byte[SHA256_BYTESIZE];
SHA256::hash((byte*) message.c_str(), message.size(), messageHash);
- int pkByteLength = element_length_in_bytes(pk);
- byte *pkBytes = new byte[pkByteLength];
- element_to_bytes(pkBytes, pk);
+// int pkByteLength = element_length_in_bytes(pk);
+// byte *pkBytes = new byte[pkByteLength];
+// element_to_bytes(pkBytes, pk);
- int totalSize = 32 + pkByteLength;
+ int totalSize = 32; // + pkByteLength;
byte *buffer = new byte[totalSize];
memcpy(buffer, messageHash, SHA256_BYTESIZE);
- memcpy(buffer + SHA256_BYTESIZE, pkBytes, pkByteLength);
+// memcpy(buffer + SHA256_BYTESIZE, pkBytes, pkByteLength);
byte *bufferHash = new byte[SHA256_BYTESIZE];
SHA256::hash(buffer, totalSize, bufferHash);
diff --git a/src/crypto/aggregate_signature.cpp b/src/crypto/aggregate_signature.cpp
index bcbcf6b..113c183 100644
--- a/src/crypto/aggregate_signature.cpp
+++ b/src/crypto/aggregate_signature.cpp
@@ -99,19 +99,30 @@ bool crypto::AggregateSignature::validate(std::string aggSigHex) {
*/
byte* hash0 = crypto::PBC::hash(signatures.at(0)->message, signatures.at(0)->publickey);
element_from_hash(h, hash0, SHA256_BYTESIZE);
- pairing_apply(fullpairing, h, signatures.at(0)->publickey, crypto::PBC::pairing);
-
- for (int i=1; i<signatures.size(); i++) {
- byte* hashValue = crypto::PBC::hash(signatures.at(i)->message, signatures.at(i)->publickey);
- element_t hashElement;
- element_init_G1(hashElement, crypto::PBC::pairing);
- element_from_hash(hashElement, hashValue, SHA256_BYTESIZE);
- element_t p;
- element_init_GT(p, crypto::PBC::pairing);
- pairing_apply(p, hashElement, signatures.at(i)->publickey, crypto::PBC::pairing);
- element_mul(fullpairing, fullpairing, p);
+// pairing_apply(fullpairing, h, signatures.at(0)->publickey, crypto::PBC::pairing);
+
+
+ element_t pks;
+ element_init_GT(pks, crypto::PBC::pairing);
+ pks[0] = signatures[0]->publickey[0];
+
+ for(int i = 1; i < signatures.size(); i++) {
+ element_mul(pks, pks, signatures[i]->publickey);
}
+ pairing_apply(fullpairing, h, pks, crypto::PBC::pairing);
+
+// for (int i=1; i<signatures.size(); i++) {
+// byte* hashValue = crypto::PBC::hash(signatures.at(i)->message, signatures.at(i)->publickey);
+// element_t hashElement;
+// element_init_G1(hashElement, crypto::PBC::pairing);
+// element_from_hash(hashElement, hashValue, SHA256_BYTESIZE);
+// element_t p;
+// element_init_GT(p, crypto::PBC::pairing);
+// pairing_apply(p, hashElement, signatures.at(i)->publickey, crypto::PBC::pairing);
+// element_mul(fullpairing, fullpairing, p);
+// }
+
return !element_cmp(compactSignature, fullpairing);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment