Skip to content

How to create Keys

Junha Yang(양준하) edited this page Jul 20, 2020 · 1 revision

Our tools foundry account and foundry-keystore-cli do not expose public key and private key. There are two reasons. A normal user does not need a public key and a private key. (We assumed that a developer can write a script easily that prints private key and public key). Printing private key has a security problem. A suer must keep their private key as an encrypted form.

Since we are developers, we need a script that prints private key and public key.

Generating private key

const { generatePrivateKey } = require("foundry-primitives");
console.log(generatePrivateKey());

Print public key from private key

const { getPublicFromPrivate } = require("foundry-primitives");
console.log(
  getPublicFromPrivate(
    "PRIVATE_KEY"
  )
);

You can run the code above in the repl.it service

https://repl.it/@majecty/privatepublicaccountfoundry