Generate keypairs for use in other applications. The repository contains generators for the following cryptosystems:
- ed25519 (https://en.wikipedia.org/wiki/EdDSA)
- secp256k1 (https://en.bitcoin.it/wiki/Secp256k1)
- x25519 (https://en.wikipedia.org/wiki/Curve25519)
cargo build --releaseReproducible builds can be done using Nix. The monorepo provides a Nix flake which includes this project and can be used to trigger builds:
nix build -v .#initialization.keygen.<output>Supported outputs:
default, cargo build outputed25519.service, systemd service config for x25519 keygensecp256k1.service, systemd service config for x25519 keygenx25519.service, systemd service config for x25519 keygen
$ keygen-ed25519 --help
Usage: keygen-ed25519 --secret <SECRET> --public <PUBLIC>
Options:
-s, --secret <SECRET> path to private key file
-p, --public <PUBLIC> path to public key file
-h, --help Print help
-V, --version Print versionkeygen-ed25519 generates a ed25519 key pair and stores it in the file paths provided. The secret key and public key are stored as bytes, with a size of 64 and 32 respectively.
$ keygen-ed25519 --secret ed25519.sec --public ed25519.pub
private key: ed25519.sec, public key: ed25519.pub
Generation successful!
$ xxd ed25519.sec
00000000: d470 d794 7b10 a3f1 e255 fc6d 562b a953 .p..{....U.mV+.S
00000010: adaf 2957 9798 c646 603b 4c4e c197 aeb0 ..)W...F`;LN....
00000020: c583 a2b0 dc98 f152 1774 b5c1 51e2 885d .......R.t..Q..]
00000030: f10e cab1 ea38 b17d ac05 8814 89d3 b156 .....8.}.......V
$ xxd ed25519.pub
00000000: c583 a2b0 dc98 f152 1774 b5c1 51e2 885d .......R.t..Q..]
00000010: f10e cab1 ea38 b17d ac05 8814 89d3 b156 .....8.}.......V$ keygen-secp256k1 --help
Usage: keygen-secp256k1 --secret <SECRET> --public <PUBLIC>
Options:
-s, --secret <SECRET> path to private key file
-p, --public <PUBLIC> path to public key file
-h, --help Print help
-V, --version Print versionkeygen-secp256k1 generates a secp256k1 key pair and stores it in the file paths provided. The secret key and public key are stored as bytes, with a size of 32 and 64 respectively. Note that the public key is stored uncompressed without the 0x04 prefix byte.
$ keygen-secp256k1 --secret secp256k1.sec --public secp256k1.pub
private key: secp256k1.sec, public key: secp256k1.pub
Generation successful!
$ xxd secp256k1.sec
00000000: 98ef bf0a 6ffa 9fb8 c9ec 5c95 8d8d bead ....o.....\.....
00000010: a169 a3b5 026b a234 a37c 23f0 09b3 62d9 .i...k.4.|#...b.
$ xxd secp256k1.pub
00000000: 38b4 6703 1fdd 557a 70cc 701d b26c a40b 8.g...Uzp.p..l..
00000010: af91 771b efeb bf9a 1813 bc49 3687 d79d ..w........I6...
00000020: bef9 f73a 8239 5593 3618 6d6d bf01 2cb4 ...:.9U.6.mm..,.
00000030: 7161 50c5 801a 24fe 9bd3 83a4 ca79 655d qaP...$......ye]$ keygen-x25519 --help
Usage: keygen-x25519 --secret <SECRET> --public <PUBLIC>
Options:
-s, --secret <SECRET> path to private key file
-p, --public <PUBLIC> path to public key file
-h, --help Print help
-V, --version Print versionkeygen-x25519 generates a x25519 key pair and stores it in the file paths provided. The secret key and public key are stored as bytes, with a size of 32 and 32 respectively.
$ keygen-x25519 --secret x25519.sec --public x25519.pub
private key: x25519.sec, public key: x25519.pub
Generation successful!
$ xxd x25519.sec
00000000: bb14 d80d e0c8 bcd5 db75 432e eaf8 79ab .........uC...y.
00000010: da07 9a3d 435c e2bf cf5a a529 9265 d6a0 ...=C\...Z.).e..
$ xxd x25519.pub
00000000: c794 718a 3671 b319 3bcd 98c5 2b72 b426 ..q.6q..;...+r.&
00000010: 39e8 052b bfb1 62e2 ef0d 5a57 74cd 9469 9..+..b...ZWt..iThis project is licensed under the GNU AGPLv3 or any later version. See LICENSE.txt.