Skip to content

Commit

Permalink
add Ord, Hash impls for VerificationKey (#9)
Browse files Browse the repository at this point in the history
* add Ord, Hash impls for VerificationKey
  • Loading branch information
hdevalence authored Jan 23, 2023
1 parent 94763f4 commit 78f83b2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Entries are listed in reverse chronological order.

# 2.1.0

* Add `PartialOrd`, `Ord`, `Hash` implementations for `VerificationKey`,
forwarding to the implementations on `VerificationKeyBytes`.

# 2.0.1

* Improve `Debug` output for `VerificationKey`.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "ed25519-consensus"
# Before publishing:
# - update CHANGELOG.md
# - update html_root_url
version = "2.0.1"
version = "2.1.0"
authors = ["Henry de Valence <hdevalence@hdevalence.ca>"]
license = "MIT OR Apache-2.0"
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/ed25519-consensus/2.0.1")]
#![doc(html_root_url = "https://docs.rs/ed25519-consensus/2.1.0")]
#![doc = include_str!("../README.md")]
#![deny(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
Expand Down
18 changes: 18 additions & 0 deletions src/verification_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ pub struct VerificationKey {
pub(crate) minus_A: EdwardsPoint,
}

impl PartialOrd for VerificationKey {
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
Some(self.cmp(other))
}
}

impl Ord for VerificationKey {
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
self.A_bytes.cmp(&other.A_bytes)
}
}

impl core::hash::Hash for VerificationKey {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.A_bytes.hash(state);
}
}

impl core::fmt::Debug for VerificationKey {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("VerificationKey")
Expand Down

0 comments on commit 78f83b2

Please sign in to comment.