Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Vote.Verify() #3837

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ To be released.
[[#3811]]
- (Libplanet) `BlockChain.DetermineBlockStateRootHash()`
has been removed. [[#3811]]
- (Libplanet.Types) `Vote.Verify()` has been removed. [[#3837]]

### Backward-incompatible API changes

Expand Down Expand Up @@ -63,6 +64,7 @@ To be released.
### CLI tools

[#3811]: https://github.com/planetarium/libplanet/pull/3811
[#3837]: https://github.com/planetarium/libplanet/pull/3837


Version 4.6.1
Expand Down
9 changes: 2 additions & 7 deletions Libplanet.Net/Consensus/HeightVoteSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ public void AddVote(Vote vote)

PublicKey validatorKey = vote.ValidatorPublicKey;

if (validatorKey is null)
{
throw new InvalidVoteException("ValidatorKey of the vote cannot be null", vote);
}

if (!_validatorSet.ContainsPublicKey(validatorKey))
{
throw new InvalidVoteException(
Expand All @@ -140,10 +135,10 @@ public void AddVote(Vote vote)
vote);
}

if (!vote.Verify())
if (vote.Signature.IsEmpty)
{
throw new InvalidVoteException(
"Received vote's signature is invalid",
"Received vote's signature is empty",
vote);
}

Expand Down
13 changes: 0 additions & 13 deletions Libplanet.Types/Consensus/Vote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,6 @@ private Vote(Bencodex.Types.Dictionary encoded)
? ((Bencodex.Types.Dictionary)_metadata.Bencoded).Add(SignatureKey, Signature)
: _metadata.Bencoded;

/// <summary>
/// Verifies whether the <see cref="Vote"/>'s payload is properly signed by
/// <see cref="Validator"/>.
/// </summary>
/// <returns><see langword="true"/> if the <see cref="Signature"/> is not empty
/// and is a valid signature signed by <see cref="Validator"/>,
/// <see langword="false"/> otherwise.</returns>
[Pure]
public bool Verify() =>
!Signature.IsEmpty &&
ValidatorPublicKey.Verify(
_codec.Encode(_metadata.Bencoded).ToImmutableArray(), Signature);

/// <inheritdoc/>
[Pure]
public bool Equals(Vote? other)
Expand Down
Loading