tari-project / tari-crypto

Tari Cryptography library
BSD 3-Clause "New" or "Revised" License
20 stars 25 forks source link

Add elliptic curve marker trait? #72

Open CjS77 opened 2 years ago

CjS77 commented 2 years ago

Consider

impl<P, K> SchnorrSignature<P, K>
where
    P: PublicKey<K = K>,
    K: SecretKey,
{...}

This is a nice, clean interface imo, but we implicitly assume that the P and K live on an elliptic curve. If we introduce an RSA public-private keypair implementation to this create in the future for example, then we could still impl the PublicKey and PrivaeKey traits, but Schnorr signature should not be allowed.

A simple solution is to create marker trait: pub trait EllipticCurve {} and implement it for say Ristretto, but not our hypothetical RSA keypair

AaronFeickert commented 6 months ago

One approach could be using traits generalizing cryptographic groups. These are implemented in the Ristretto library.