diff --git a/src/avalanche/delegation.h b/src/avalanche/delegation.h --- a/src/avalanche/delegation.h +++ b/src/avalanche/delegation.h @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -25,7 +26,7 @@ struct Level { CPubKey pubkey; - std::array sig; + SchnorrSig sig; SERIALIZE_METHODS(Level, obj) { READWRITE(obj.pubkey, obj.sig); } }; diff --git a/src/avalanche/processor.cpp b/src/avalanche/processor.cpp --- a/src/avalanche/processor.cpp +++ b/src/avalanche/processor.cpp @@ -247,7 +247,7 @@ */ class TCPResponse { Response response; - std::array sig; + SchnorrSig sig; public: TCPResponse(Response responseIn, const CKey &key) @@ -404,7 +404,7 @@ } // Now let's sign! - std::array sig; + SchnorrSig sig; { CHashWriter hasher(SER_GETHASH, 0); diff --git a/src/avalanche/proof.h b/src/avalanche/proof.h --- a/src/avalanche/proof.h +++ b/src/avalanche/proof.h @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -50,17 +51,17 @@ class SignedStake { Stake stake; - std::array sig; + SchnorrSig sig; public: explicit SignedStake() = default; - SignedStake(Stake stake_, std::array sig_) + SignedStake(Stake stake_, SchnorrSig sig_) : stake(std::move(stake_)), sig(std::move(sig_)) {} SERIALIZE_METHODS(SignedStake, obj) { READWRITE(obj.stake, obj.sig); } const Stake &getStake() const { return stake; } - const std::array &getSignature() const { return sig; } + const SchnorrSig &getSignature() const { return sig; } bool verify(const ProofId &proofid) const; }; diff --git a/src/avalanche/proofbuilder.cpp b/src/avalanche/proofbuilder.cpp --- a/src/avalanche/proofbuilder.cpp +++ b/src/avalanche/proofbuilder.cpp @@ -11,7 +11,7 @@ SignedStake ProofBuilder::StakeSigner::sign(const ProofId &proofid) { const uint256 h = stake.getHash(proofid); - std::array sig; + SchnorrSig sig; if (!key.SignSchnorr(h, sig)) { sig.fill(0); } diff --git a/src/avalanche/protocol.h b/src/avalanche/protocol.h --- a/src/avalanche/protocol.h +++ b/src/avalanche/protocol.h @@ -67,10 +67,10 @@ class Hello { Delegation delegation; - std::array sig; + SchnorrSig sig; public: - Hello(Delegation delegationIn, std::array sigIn) + Hello(Delegation delegationIn, SchnorrSig sigIn) : delegation(std::move(delegationIn)), sig(sigIn) {} std::array GetSig() { return sig; } diff --git a/src/key.h b/src/key.h --- a/src/key.h +++ b/src/key.h @@ -21,6 +21,9 @@ */ typedef std::vector> CPrivKey; +//! a Schnorr signature +using SchnorrSig = std::array; + /** An encapsulated secp256k1 private key. */ class CKey { public: @@ -120,8 +123,7 @@ * Create a Schnorr signature. * The test_case parameter tweaks the deterministic nonce. */ - bool SignSchnorr(const uint256 &hash, - std::array &sig, + bool SignSchnorr(const uint256 &hash, SchnorrSig &sig, uint32_t test_case = 0) const; bool SignSchnorr(const uint256 &hash, std::vector &vchSig, uint32_t test_case = 0) const; diff --git a/src/key.cpp b/src/key.cpp --- a/src/key.cpp +++ b/src/key.cpp @@ -285,8 +285,7 @@ return true; } -bool CKey::SignSchnorr(const uint256 &hash, - std::array &sig, +bool CKey::SignSchnorr(const uint256 &hash, SchnorrSig &sig, uint32_t test_case) const { return DoSignSchnorr(*this, hash, sig.data(), test_case); } diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3964,7 +3964,7 @@ return; } - std::array sig; + SchnorrSig sig; verifier >> sig; } @@ -4090,7 +4090,7 @@ verifier >> response; if (!g_avalanche->forNode(pfrom.GetId(), [&](const avalanche::Node &n) { - std::array sig; + SchnorrSig sig; vRecv >> sig; return n.pubkey.VerifySchnorr(verifier.GetHash(), sig); })) {