Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

API Gap: KeyPairGenerator

Open
#147 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start by reading traits.rs and the existing SignaturePublicKey, SignaturePrivateKey, KEMPublicKey, KEMPrivateKey, RNG, SignatureError, and KEMError definitions. Compare the proposed key-generation traits with the current API and decide whether KEM should remain distinct from broader encryption or agreement terminology. Done means the trait scope and naming are agreed and the relevant key types can use the resulting API.

Written by the indexing model from the issue text.

Description

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".

Dominant language
Rust
Stars
25
Forks
18
Avg merge
14d 10h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bcgit/bc-rust

All issues in bcgit/bc-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.