Securing private keys in Zilliqa using Hashicorp Vault

vault token create
const { BN, Long, bytes, units } = require(‘@zilliqa-js/util’);const { Zilliqa } = require(‘@zilliqa-js/zilliqa’);const {toBech32Address,getAddressFromPrivateKey,} = require(‘@zilliqa-js/crypto’);const zilliqa = new Zilliqa(‘https://dev-api.zilliqa.com');const chainId = 333; // chainId of the developer testnetconst msgVersion = 1; // current msgVersionvar options = {apiVersion: ‘v1’,endpoint: ‘http://127.0.0.1:8200',token: ‘s.qlIhIpaAcgnxQf0fytWyIt4H’};// get new instance of the clientvar vault = require(“node-vault”)(options);//store private key inside a secret engine in vault — This can be done via cli so that the private key is not exposedvault.write(‘secret/private’, { key: ‘2ffeab20e8e3cb7a909581016152c2348b7d5aecac20c80397fc3fa39582c9a1’ }).then(() => vault.read(‘secret/private’)).then((result) => {zilliqa.wallet.addByPrivateKey(result.data.key);const address = getAddressFromPrivateKey(privateKey);console.log(`My account address is: ${address}`);console.log(`My account bech32 address is: ${toBech32Address(address)}`);}).then(() => vault.delete(‘secret/private’)).catch(console.error);
  1. https://learn.hashicorp.com/tutorials/vault/codify-mgmt-oss?in=vault/operations
  2. https://learn.hashicorp.com/tutorials/vault/pattern-approle?in=vault/recommended-patterns

--

--

--

A blockchain dev | Zilliqa Developer Ambassador | RedChillies Labs, Inc. | Pastel Soft | JS Security Technologies | AART

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Inspecting Runtimes

Android Place Picker API

I will convert psd, xd, sketch, ai, figma, pdf, png, jpg, zeplin to wordpress website

A New Book — How I Saved Christmas IV (SANS Holiday Hack Challenge 2017 Write-up Part 4 of 6)

Setting up Eclipse IDE for your CERN ROOT project with existing Makefile

Mana Engine: More on Component Usage

“How to What” Integration

Get your company psyched about data using Slack

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bibek Koirala

Bibek Koirala

A blockchain dev | Zilliqa Developer Ambassador | RedChillies Labs, Inc. | Pastel Soft | JS Security Technologies | AART

More from Medium

So… do you use Kubernetes?

Hands On Network Policies In Kubernetes

About Cloudflare proxy status and Let’s encrypt and too many redirects error

Explore DialogV3 in HarmonyOS