Skip to content

Commit 33fda15

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 ba04d92 commit 33fda15

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
@@ -301,6 +301,33 @@ impl ElligatorSwiftParty {
301301
}
302302
}
303303

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

0 commit comments

Comments
 (0)