Compare commits

..

7 Commits

Author SHA1 Message Date
PastaPastaPasta
0a7e30a1f2
Merge 47972aab8c into dd96032e12 2024-12-18 13:58:00 +00:00
pasta
47972aab8c
feat: serialize on the stack 2024-12-18 07:57:39 -06:00
pasta
dd96032e12
Merge #6494: depends: update 'src/dashbls' to dashpay/bls-signatures@0bb5c5b0 as efd5c56
Some checks failed
Label Merge Conflicts / main (push) Failing after 24s
CI / Build Image (push) Failing after 52s
CI / Build (linux64_ubsan, linux64, x86_64-pc-linux-gnu) (push) Has been skipped
CI / Build Dependencies (arm-linux, arm-linux-gnueabihf) (push) Has been skipped
CI / Build Dependencies (linux64, x86_64-pc-linux-gnu) (push) Has been skipped
CI / Build (arm-linux, arm-linux, arm-linux-gnueabihf) (push) Has been skipped
CI / Build (linux64, linux64, x86_64-pc-linux-gnu) (push) Has been skipped
CI / Build (linux64_cxx20, linux64, x86_64-pc-linux-gnu) (push) Has been skipped
CI / Build (linux64_fuzz, linux64, x86_64-pc-linux-gnu) (push) Has been skipped
CI / Build (linux64_nowallet, linux64, x86_64-pc-linux-gnu) (push) Has been skipped
CI / Build (linux64_sqlite, linux64, x86_64-pc-linux-gnu) (push) Has been skipped
CI / Build (linux64_tsan, linux64, x86_64-pc-linux-gnu) (push) Has been skipped
Check Merge Fast-Forward Only / check_merge (push) Successful in 1m35s
Guix Build / build-image (push) Failing after 3m21s
Guix Build / build (aarch64-linux-gnu) (push) Has been skipped
Guix Build / build (arm-linux-gnueabihf) (push) Has been skipped
Guix Build / build (arm64-apple-darwin) (push) Has been skipped
Guix Build / build (powerpc64-linux-gnu) (push) Has been skipped
Guix Build / build (riscv64-linux-gnu) (push) Has been skipped
Guix Build / build (x86_64-apple-darwin) (push) Has been skipped
Guix Build / build (x86_64-linux-gnu) (push) Has been skipped
Guix Build / build (x86_64-w64-mingw32) (push) Has been skipped
3bbe16c390 build: stop tracking cmake dependency relic_conf.h.in (Kittywhiskers Van Gogh)
efd5c566da Squashed 'src/dashbls/' changes from 7e747e8a07..0bb5c5b032 (Kittywhiskers Van Gogh)
257fd5ef9e revert: stop tracking cmake dependency relic_conf.h.in (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * Dependency for https://github.com/dashpay/dash/pull/6493
  * Expected subtree hash `7bec74f04710e6031590283cf405e3f141bc63310cafe5e70aae9b8d4c98cbef` (see [instructions](https://github.com/dashpay/dash/pull/6323#pullrequestreview-2357380766) to calculate)
  * Includes [bls-signatures#75](https://github.com/dashpay/bls-signatures/pull/75) and [bls-signatures#106](https://github.com/dashpay/bls-signatures/pull/106)

  ## Breaking Changes

  None expected.

  ## Checklist:

  - [x] I have performed a self-review of my own code **(note: N/A)**
  - [x]  I have commented my code, particularly in hard-to-understand areas **(note: N/A)**
  - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)**
  - [x] I have made corresponding changes to the documentation **(note: N/A)**
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  PastaPastaPasta:
    utACK 3bbe16c390
  UdjinM6:
    subtree looks good, utACK 3bbe16c390

Tree-SHA512: 3f6853f90dfe5e3040189742858b6728e4ab505513202216f1e2f7213569798d2f2e346d73ece7505f87dc2439fde4c3a51472461163fc7c21734a734cbc0bdb
2024-12-17 11:44:08 -06:00
Kittywhiskers Van Gogh
3bbe16c390
build: stop tracking cmake dependency relic_conf.h.in 2024-12-17 04:34:08 +00:00
Kittywhiskers Van Gogh
43043e623f
depends: update 'src/dashbls' to dashpay/bls-signatures@0bb5c5b0 as efd5c566 2024-12-17 04:29:16 +00:00
Kittywhiskers Van Gogh
efd5c566da Squashed 'src/dashbls/' changes from 7e747e8a07..0bb5c5b032
0bb5c5b032 Merge pull request #107 from kwvg/bump_1.3.5
3170e82074 Merge pull request #106 from UdjinM6/bench_chore
6091f5c056 chore: bump version to 1.3.5
90fd986fa5 chore: drop irrelevant PopSchemeMPL benchmark
ba391e681e bench: use BasicSchemeMPL instead of AugSchemeMPL
bcc6cf9cda bench: add benchmars for Serialize/SerializeToArray
cc649f38ee feat: serialize on the stack (#75)

git-subtree-dir: src/dashbls
git-subtree-split: 0bb5c5b03249c463debb5cef5f7e52ee66f3aaab
2024-12-17 04:29:16 +00:00
Kittywhiskers Van Gogh
257fd5ef9e
revert: stop tracking cmake dependency relic_conf.h.in
reverts:
- 02260cba57.
2024-12-17 04:28:10 +00:00
5 changed files with 62 additions and 41 deletions

View File

@ -131,7 +131,7 @@ public:
return impl.SerializeToArray(specificLegacyScheme);
}
std::vector<uint8_t> ToActualByteVector(const bool specificLegacyScheme) const
std::vector<uint8_t> ToByteVector(const bool specificLegacyScheme) const
{
if (!fValid) {
return std::vector<uint8_t>(SerSize, 0);

View File

@ -1,5 +1,5 @@
AC_PREREQ([2.60])
AC_INIT([libdashbls],[1.3.3])
AC_INIT([libdashbls],[1.3.5])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4])

View File

@ -31,21 +31,21 @@ using namespace bls;
void benchSigs() {
string testName = "Signing";
const int numIters = 5000;
PrivateKey sk = AugSchemeMPL().KeyGen(getRandomSeed());
PrivateKey sk = BasicSchemeMPL().KeyGen(getRandomSeed());
vector<uint8_t> message1 = sk.GetG1Element().Serialize();
auto start = startStopwatch();
for (int i = 0; i < numIters; i++) {
AugSchemeMPL().Sign(sk, message1);
BasicSchemeMPL().Sign(sk, message1);
}
endStopwatch(testName, start, numIters);
}
void benchVerification() {
string testName = "Verification";
const int numIters = 10000;
PrivateKey sk = AugSchemeMPL().KeyGen(getRandomSeed());
const int numIters = 1000;
PrivateKey sk = BasicSchemeMPL().KeyGen(getRandomSeed());
G1Element pk = sk.GetG1Element();
std::vector<G2Element> sigs;
@ -54,7 +54,7 @@ void benchVerification() {
uint8_t message[4];
Util::IntToFourBytes(message, i);
vector<uint8_t> messageBytes(message, message + 4);
sigs.push_back(AugSchemeMPL().Sign(sk, messageBytes));
sigs.push_back(BasicSchemeMPL().Sign(sk, messageBytes));
}
auto start = startStopwatch();
@ -62,34 +62,36 @@ void benchVerification() {
uint8_t message[4];
Util::IntToFourBytes(message, i);
vector<uint8_t> messageBytes(message, message + 4);
bool ok = AugSchemeMPL().Verify(pk, messageBytes, sigs[i]);
bool ok = BasicSchemeMPL().Verify(pk, messageBytes, sigs[i]);
ASSERT(ok);
}
endStopwatch(testName, start, numIters);
}
void benchBatchVerification() {
const int numIters = 100000;
const int numIters = 10000;
vector<vector<uint8_t>> sig_bytes;
vector<vector<uint8_t>> pk_bytes;
vector<vector<uint8_t>> ms;
auto start = startStopwatch();
for (int i = 0; i < numIters; i++) {
uint8_t message[4];
Util::IntToFourBytes(message, i);
vector<uint8_t> messageBytes(message, message + 4);
PrivateKey sk = AugSchemeMPL().KeyGen(getRandomSeed());
PrivateKey sk = BasicSchemeMPL().KeyGen(getRandomSeed());
G1Element pk = sk.GetG1Element();
sig_bytes.push_back(AugSchemeMPL().Sign(sk, messageBytes).Serialize());
sig_bytes.push_back(BasicSchemeMPL().Sign(sk, messageBytes).Serialize());
pk_bytes.push_back(pk.Serialize());
ms.push_back(messageBytes);
}
endStopwatch("Batch verification preparation", start, numIters);
vector<G1Element> pks;
pks.reserve(numIters);
auto start = startStopwatch();
start = startStopwatch();
for (auto const& pk : pk_bytes) {
pks.emplace_back(G1Element::FromBytes(Bytes(pk)));
}
@ -105,52 +107,71 @@ void benchBatchVerification() {
endStopwatch("Signature validation", start, numIters);
start = startStopwatch();
G2Element aggSig = AugSchemeMPL().Aggregate(sigs);
G2Element aggSig = BasicSchemeMPL().Aggregate(sigs);
endStopwatch("Aggregation", start, numIters);
start = startStopwatch();
bool ok = AugSchemeMPL().AggregateVerify(pks, ms, aggSig);
bool ok = BasicSchemeMPL().AggregateVerify(pks, ms, aggSig);
ASSERT(ok);
endStopwatch("Batch verification", start, numIters);
}
void benchFastAggregateVerification() {
const int numIters = 5000;
vector<G2Element> sigs;
vector<G1Element> pks;
vector<uint8_t> message = {1, 2, 3, 4, 5, 6, 7, 8};
vector<G2Element> pops;
for (int i = 0; i < numIters; i++) {
PrivateKey sk = PopSchemeMPL().KeyGen(getRandomSeed());
void benchSerialize() {
const int numIters = 5000000;
PrivateKey sk = BasicSchemeMPL().KeyGen(getRandomSeed());
G1Element pk = sk.GetG1Element();
sigs.push_back(PopSchemeMPL().Sign(sk, message));
pops.push_back(PopSchemeMPL().PopProve(sk));
pks.push_back(pk);
}
vector<uint8_t> message = sk.GetG1Element().Serialize();
G2Element sig = BasicSchemeMPL().Sign(sk, message);
auto start = startStopwatch();
G2Element aggSig = PopSchemeMPL().Aggregate(sigs);
endStopwatch("PopScheme Aggregation", start, numIters);
for (int i = 0; i < numIters; i++) {
sk.Serialize();
}
endStopwatch("Serialize PrivateKey", start, numIters);
start = startStopwatch();
for (int i = 0; i < numIters; i++) {
bool ok = PopSchemeMPL().PopVerify(pks[i], pops[i]);
ASSERT(ok);
pk.Serialize();
}
endStopwatch("PopScheme Proofs verification", start, numIters);
endStopwatch("Serialize G1Element", start, numIters);
start = startStopwatch();
bool ok = PopSchemeMPL().FastAggregateVerify(pks, message, aggSig);
ASSERT(ok);
endStopwatch("PopScheme verification", start, numIters);
for (int i = 0; i < numIters; i++) {
sig.Serialize();
}
endStopwatch("Serialize G2Element", start, numIters);
}
void benchSerializeToArray() {
const int numIters = 5000000;
PrivateKey sk = BasicSchemeMPL().KeyGen(getRandomSeed());
G1Element pk = sk.GetG1Element();
vector<uint8_t> message = sk.GetG1Element().Serialize();
G2Element sig = BasicSchemeMPL().Sign(sk, message);
auto start = startStopwatch();
for (int i = 0; i < numIters; i++) {
sk.SerializeToArray();
}
endStopwatch("SerializeToArray PrivateKey", start, numIters);
start = startStopwatch();
for (int i = 0; i < numIters; i++) {
pk.SerializeToArray();
}
endStopwatch("SerializeToArray G1Element", start, numIters);
start = startStopwatch();
for (int i = 0; i < numIters; i++) {
sig.SerializeToArray();
}
endStopwatch("SerializeToArray G2Element", start, numIters);
}
int main(int argc, char* argv[]) {
benchSigs();
benchVerification();
benchBatchVerification();
benchFastAggregateVerification();
benchSerialize();
benchSerializeToArray();
}

View File

@ -258,7 +258,7 @@ bool CGovernanceObject::Sign(const CActiveMasternodeManager& mn_activeman)
if (!sig.IsValid()) {
return false;
}
m_obj.vchSig = sig.ToActualByteVector(false);
m_obj.vchSig = sig.ToByteVector(false);
return true;
}

View File

@ -175,7 +175,7 @@ bool CGovernanceVote::Sign(const CActiveMasternodeManager& mn_activeman)
if (!sig.IsValid()) {
return false;
}
vchSig = sig.ToActualByteVector(false);
vchSig = sig.ToByteVector(false);
return true;
}