How do i validate if user entered correct active public and owner public key (e.g. length, no forbidden characters entered) using javascript?

2 Answers 2


Use the eosjs-ecc library to validate keys in JavaScript:

const ecc = require('eosjs-ecc')

const pubkey = 'EOS7rHHE6Gp11zLdTio5xCcGd8KtnDcDYNRC5595hfeKTizePAKZP'
const wif = '5HzevvzwHzcQAZiMSJpZapj87QwtBrtPAwXc4yGwHowLhbujKbg'

console.log(ecc.isValidPublic(pubkey)) // true
console.log(ecc.isValidPrivate(wif)) // true

I believe you would just convert the private key to public with ecc.privateToPublic then compare the result to your pubkey variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.