mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 18:45:52 +00:00
Clean up the code
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
This commit is contained in:
@@ -223,19 +223,14 @@ publicKeyType(PublicKey const& publicKey)
|
||||
verifyDigest(
|
||||
PublicKey const& publicKey,
|
||||
uint256 const& digest,
|
||||
Slice const& sig,
|
||||
bool mustBeFullyCanonical = true) noexcept;
|
||||
Slice const& sig) noexcept;
|
||||
|
||||
/** Verify a signature on a message.
|
||||
With secp256k1 signatures, the data is first hashed with
|
||||
SHA512-Half, and the resulting digest is signed.
|
||||
*/
|
||||
[[nodiscard]] bool
|
||||
verify(
|
||||
PublicKey const& publicKey,
|
||||
Slice const& m,
|
||||
Slice const& sig,
|
||||
bool mustBeFullyCanonical = true) noexcept;
|
||||
verify(PublicKey const& publicKey, Slice const& m, Slice const& sig) noexcept;
|
||||
|
||||
/** Calculate the 160-bit node ID from a node public key. */
|
||||
NodeID
|
||||
|
||||
@@ -220,16 +220,14 @@ bool
|
||||
verifyDigest(
|
||||
PublicKey const& publicKey,
|
||||
uint256 const& digest,
|
||||
Slice const& sig,
|
||||
bool mustBeFullyCanonical) noexcept
|
||||
Slice const& sig) noexcept
|
||||
{
|
||||
if (publicKeyType(publicKey) != KeyType::secp256k1)
|
||||
LogicError("sign: secp256k1 required for digest signing");
|
||||
auto const canonicality = ecdsaCanonicality(sig);
|
||||
if (!canonicality)
|
||||
return false;
|
||||
if (mustBeFullyCanonical &&
|
||||
(*canonicality != ECDSACanonicality::fullyCanonical))
|
||||
if (*canonicality != ECDSACanonicality::fullyCanonical)
|
||||
return false;
|
||||
|
||||
secp256k1_pubkey pubkey_imp;
|
||||
@@ -267,18 +265,13 @@ verifyDigest(
|
||||
}
|
||||
|
||||
bool
|
||||
verify(
|
||||
PublicKey const& publicKey,
|
||||
Slice const& m,
|
||||
Slice const& sig,
|
||||
bool mustBeFullyCanonical) noexcept
|
||||
verify(PublicKey const& publicKey, Slice const& m, Slice const& sig) noexcept
|
||||
{
|
||||
if (auto const type = publicKeyType(publicKey))
|
||||
{
|
||||
if (*type == KeyType::secp256k1)
|
||||
{
|
||||
return verifyDigest(
|
||||
publicKey, sha512Half(m), sig, mustBeFullyCanonical);
|
||||
return verifyDigest(publicKey, sha512Half(m), sig);
|
||||
}
|
||||
else if (*type == KeyType::ed25519)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user