rsa_keygen

Crates.iorsa_keygen
lib.rsrsa_keygen
version1.0.9
sourcesrc
created_at2024-04-11 01:37:57.417541
updated_at2024-06-09 22:27:05.724368
descriptionA crate for generating rsa keys with a 12 word seedphrase
homepagehttps://github.com/supersanta183/lassecoin_keygen
repositoryhttps://github.com/supersanta183/lassecoin_keygen
max_upload_size
id1204278
size27,132
Emil Klemmensen (supersanta183)

documentation

README

rsa_keygen

How to use:

A keypair is a struct where the first element is the private key and the second element is the public key:

type Keypair = (RsaPrivateKey, RsaPublicKey);
pub use rsa_keygen::generate_seedphrase;
pub use rsa_keygen::keypair_from_seedphrase;
pub use rsa_keygen::keypair_from_private_key;
pub use rsa_keygen::generate_seedphrase_and_keypair;
pub use rsa_keygen::store_in_file;

//generate a 12 word seedphrase
let seedphrase = generate_seedphrase();

//generate an rsa keypair from the 12 word seedphrase
let (priv_key, pub_key) = keypair_from_seedphrase(&seedphrase).unwrap();

//generate an rsa keypair from an already known secret key
let (priv_key, pub_key) = keypair_from_private_key(&keypair.priv_key);

you can generate the seedphrase and keypair easily using the generate_seedphrase_and_keypair function:

let (seedphrase, keypair) = generate_seedphrase_and_keypair().unwrap();

you can export the private key or the public key to pem format in order to make it more readable, using the pkcsx_pem_from functions. Currently pkcs1 and pkcs8 are supported:

pub use rsa_keygen::pkcs8_pem_from_priv_key;
pub use rsa_keygen::pkcs8_pem_from_pub_key;

let priv_key_pem = pkcs8_pem_from_priv_key(&keypair.0).unwrap();
let pub_key_pem = pkcs8_pem_from_pub_key(&keypair.1).unwrap();

it's possible to write the keypair and seedphrase to a file using the store_in_file function:

store_in_file(keypair, &seedphrase, "id.txt");

If you have any requests or improvements, make an issue or a pr on the github.

Commit count: 45

cargo fmt