How to generate a pair of public and private keys with ECDSA
At Stark Bank, we use the secp256k1 curve to create and validate digital signatures, the same used by Bitcoin, Ethereum and other cryptocurrencies.
We recommend any of the following methods to create a pair of public and private ECDSA keys.
Remember: your private key should never be shared with anyone, including us!
Solution 1: Using OpenSSL
For Mac and most Linux distros, OpenSSL is already installed by default. Windows users need to install OpenSSL in order to use this solution. We recommend the version that comes bundled with Git for Windows.
To generate your key pair, open the terminal (Git Bash for Windows) and insert the code below:
openssl ecparam -name secp256k1 -genkey -out privateKey.pem
openssl ec -in privateKey.pem -pubout -out publicKey.pem
Solution 2: Using our SDKs
If you use one of the programming languages below, just install our SDK and use the commands below to generate the key pair:
Python
import starkbank
private_key, public_key = starkbank.key.create("sample/destination/path")
print(private_key)
print(public_key)
Javascript
const starkbank = require('starkbank')
let privateKey, publicKey
[privateKey, publicKey] = starkbank.key.create("sample/destination/path")
console.log(privateKey)
console.log(publicKey)
PHP
use StarkBankKey;
list($privateKey, $publicKey) = Key::create("sample/destination/path");
print_r($privateKey)
print_r($publicKey)
Java
import com.starkbank.*;
Key key = Key.create("sample/destination/path");
String privatePem = key.privatePem;
String publicPem = key.publicPem;
System.out.print(privatePem);
System.out.print(publicPem);
Ruby
require('starkbank')
private_key, public_key = StarkBank::Key.create("sample/destination/path")
puts private_key
puts public_key
Elixir
{private_key, public_key} = StarkBank.Key.create("sample/destination/path")
IO.puts(private_key)
IO.puts(public_key)
C#
(string privateKey, string publicKey) = StarkBank.Key.Create("sample/destination/path");
Console.WriteLine(privateKey);
Console.WriteLine(publicKey);
Go
package main
import (
"fmt"
"github.com/starkinfra/core-go/starkcore/key"
)
func main() {
privateKey, publicKey := key.Create("sample/destination/path")
fmt.Println(privateKey)
fmt.Println(publicKey)
}
Clojure
(ns my-lib.core
(:use starkbank.core))
(def key-pair (starkbank.key/create "/sample/destination/path"))
(println (:private-pem key-pair))
(println (:public-pem key-pair))
Curl
Solution 3: Using your browser
If none of the methods above worked for you, we can use our Node ECDSA library to generate a pair of keys locally in your browser. To create your keys, just click on the button below: