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