Skip to content

Commit 3b7d393

Browse files
committed
Create Party enum
Introducing this enum as a replacement for ElligatorSwiftParty. Party is more descriptive and should cause less confusion than ElligatorSwiftParty
1 parent 379e128 commit 3b7d393

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/ellswift.rs

+27
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,33 @@ impl ElligatorSwiftParty {
307307
}
308308
}
309309

310+
/// Represents the two parties in ECDH
311+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
312+
pub enum Party {
313+
/// The party that starts the key exchange or communication process
314+
Initiator,
315+
/// The party that responds to the initiator's communications
316+
Responder,
317+
}
318+
319+
impl From<ElligatorSwiftParty> for Party {
320+
fn from(value: ElligatorSwiftParty) -> Self {
321+
match value {
322+
ElligatorSwiftParty::A => Party::Initiator,
323+
ElligatorSwiftParty::B => Party::Responder,
324+
}
325+
}
326+
}
327+
328+
impl Party {
329+
fn to_ffi_int(self) -> c_int {
330+
match self {
331+
Party::Initiator => 0,
332+
Party::Responder => 1,
333+
}
334+
}
335+
}
336+
310337
impl FromStr for ElligatorSwift {
311338
fn from_str(hex: &str) -> Result<Self, Self::Err> {
312339
let mut ser = [0u8; 64];

0 commit comments

Comments
 (0)