Skip to content

Instantly share code, notes, and snippets.

@Mobelis
Created June 7, 2018 08:10
Show Gist options
  • Select an option

  • Save Mobelis/b247f2357978a5c841ce8be06d73b144 to your computer and use it in GitHub Desktop.

Select an option

Save Mobelis/b247f2357978a5c841ce8be06d73b144 to your computer and use it in GitHub Desktop.
let BitMessage = require("bitcoinjs-message");
var address = '1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN'
var signature = 'HJLQlDWLyb1Ef8bQKEISzFbDAKctIlaqOpGbrk3YVtRsjmC61lpE5ErkPRUFtDKtx98vHFGUWlFhsh3DiW6N0rE'
var message = 'This is an example of a signed message'
function checkSignature(message, address, signature) {
return new Promise((resolve,reject) => {
let result = BitMessage.verify(message, address, signature);
if(result) {
resolve(true);
} else {
reject(result);
}
});
}
checkSignature(message, address, signature)
.then(res => console.log(res))
.catch(err => console.error(`Erorr:`, err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment