66
77#include " hash.h"
88#include " random.h"
9- #include " tinyformat.h"
109
1110#ifndef BUILD_BITCOIN_INTERNAL
1211#include " support/allocators/secure.h"
1615#include < assert.h>
1716#include < string.h>
1817
19- bool CBLSId::InternalSetBuf (const void * buf, size_t size)
20- {
21- assert (size == sizeof (uint256));
22- memcpy (impl.begin (), buf, sizeof (uint256));
23- return true ;
24- }
25-
26- bool CBLSId::InternalGetBuf (void * buf, size_t size) const
27- {
28- if (size != GetSerSize ()) {
29- return false ;
30- }
31- memcpy (buf, impl.begin (), sizeof (uint256));
32- return true ;
33- }
34-
35- void CBLSId::SetInt (int x)
36- {
37- impl.SetHex (strprintf (" %x" , x));
38- fValid = true ;
39- UpdateHash ();
40- }
41-
42- void CBLSId::SetHash (const uint256& hash)
43- {
44- impl = hash;
45- fValid = true ;
46- UpdateHash ();
47- }
48-
49- CBLSId CBLSId::FromInt (int64_t i)
50- {
51- CBLSId id;
52- id.SetInt (i);
53- return id;
54- }
55-
56- CBLSId CBLSId::FromHash (const uint256& hash)
57- {
58- CBLSId id;
59- id.SetHash (hash);
60- return id;
61- }
62-
6318bool CBLSSecretKey::InternalSetBuf (const void * buf, size_t size)
6419{
6520 if (size != GetSerSize ()) {
@@ -133,7 +88,7 @@ bool CBLSSecretKey::SecretKeyShare(const std::vector<CBLSSecretKey>& msk, const
13388 fValid = false ;
13489 UpdateHash ();
13590
136- if (! _id.IsValid ()) {
91+ if (_id.IsNull ()) {
13792 return false ;
13893 }
13994
@@ -147,7 +102,7 @@ bool CBLSSecretKey::SecretKeyShare(const std::vector<CBLSSecretKey>& msk, const
147102 }
148103
149104 try {
150- impl = bls::BLS::PrivateKeyShare (mskVec, (const uint8_t *)_id.impl . begin ());
105+ impl = bls::BLS::PrivateKeyShare (mskVec, (const uint8_t *)_id.begin ());
151106 } catch (...) {
152107 return false ;
153108 }
@@ -241,7 +196,7 @@ bool CBLSPublicKey::PublicKeyShare(const std::vector<CBLSPublicKey>& mpk, const
241196 fValid = false ;
242197 UpdateHash ();
243198
244- if (! _id.IsValid ()) {
199+ if (_id.IsNull ()) {
245200 return false ;
246201 }
247202
@@ -255,7 +210,7 @@ bool CBLSPublicKey::PublicKeyShare(const std::vector<CBLSPublicKey>& mpk, const
255210 }
256211
257212 try {
258- impl = bls::BLS::PublicKeyShare (mpkVec, (const uint8_t *)_id.impl . begin ());
213+ impl = bls::BLS::PublicKeyShare (mpkVec, (const uint8_t *)_id.begin ());
259214 } catch (...) {
260215 return false ;
261216 }
@@ -433,11 +388,11 @@ bool CBLSSignature::Recover(const std::vector<CBLSSignature>& sigs, const std::v
433388 idsVec.reserve (sigs.size ());
434389
435390 for (size_t i = 0 ; i < sigs.size (); i++) {
436- if (!sigs[i].IsValid () || ! ids[i].IsValid ()) {
391+ if (!sigs[i].IsValid () || ids[i].IsNull ()) {
437392 return false ;
438393 }
439394 sigsVec.emplace_back (sigs[i].impl );
440- idsVec.emplace_back (ids[i].impl . begin ());
395+ idsVec.emplace_back (ids[i].begin ());
441396 }
442397
443398 try {
0 commit comments