diff --git a/common/crypto/src/identity/mod.rs b/common/crypto/src/identity/mod.rs new file mode 100644 index 0000000000..175806394e --- /dev/null +++ b/common/crypto/src/identity/mod.rs @@ -0,0 +1,38 @@ + +pub trait MixnetIdentityKeyPair +where + Priv: MixnetIdentityPrivateKey, + Pub: MixnetIdentityPublicKey, +{ + fn new() -> Self; + fn private_key(&self) -> &Priv; + fn public_key(&self) -> &Pub; + + // TODO: signing related methods +} + +pub trait MixnetIdentityPublicKey: + Sized + for<'a> From<&'a ::PrivateKeyMaterial> +{ + // we need to couple public and private keys together + type PrivateKeyMaterial: MixnetIdentityPrivateKey; + + fn to_bytes(&self) -> Vec; + fn from_bytes(b: &[u8]) -> Self; +} + +pub trait MixnetIdentityPrivateKey: Sized { + // we need to couple public and private keys together + type PublicKeyMaterial: MixnetIdentityPublicKey; + + /// Returns the associated public key + fn public_key(&self) -> Self::PublicKeyMaterial { + self.into() + } + + fn to_bytes(&self) -> Vec; + fn from_bytes(b: &[u8]) -> Self; +} + +// same for validator +