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
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.