Skip to content

API Gap: KeyPairGenerator #147

Description

@dghgit

There's currently nothing in traits.rs for this.

My learned machine colleague suggests a natural fit for the public/private key classes would be:

pub trait SignatureKeyPairGenerator<
    PK: SignaturePublicKey<PK_LEN>,
    SK: SignaturePrivateKey<SK_LEN>,
    const PK_LEN: usize,
    const SK_LEN: usize,
>
{
    /// Generates a key pair using the library's default OS-backed RNG.
    fn keygen() -> Result<(PK, SK), SignatureError>;

    /// Generates a key pair using the provided RNG.
    fn keygen_from_rng(rng: &mut dyn RNG) -> Result<(PK, SK), SignatureError>;
}

and

pub trait KEMKeyPairGenerator<
    PK: KEMPublicKey<PK_LEN>,
    SK: KEMPrivateKey<SK_LEN>,
    const PK_LEN: usize,
    const SK_LEN: usize,
>
{
    /// Generates a key pair using the library's default OS-backed RNG.
    fn keygen() -> Result<(PK, SK), KEMError>;

    /// Generates a key pair using the provided RNG.
    fn keygen_from_rng(rng: &mut dyn RNG) -> Result<(PK, SK), KEMError>;
}

These could then be combined with the appropriate types to simplify the notation for invoking one.

It's possible that KEMKeyPairGenerator might be better as EncryptionKeyPairGenerator in-case RSA/OAEP get's added at a later date, XDH might be another candidate for "Encryption" although again, it and Diffie-Hellman might deserve "Agreement".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions