Skip to content

Commit fef48bc

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 fef48bc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/ellswift.rs

+28
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ pub enum ElligatorSwiftParty {
298298
B,
299299
}
300300

301+
301302
impl ElligatorSwiftParty {
302303
fn to_ffi_int(self) -> c_int {
303304
match self {
@@ -307,6 +308,33 @@ impl ElligatorSwiftParty {
307308
}
308309
}
309310

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

0 commit comments

Comments
 (0)