0.0.1 • Published 3 years ago
@hypereon/message v0.0.1
Hypereon - Message
JavaScript functions for signing and verifying messages.
Installation
npm install @hypereon/message;
Usage
Sign a message
import { sign } from '@hypereon/message';
const privateKey = 'L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1';
const message = 'This is an example of a signed message.';
const signature = sign({ message, privateKey });
// Expected Result: H9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk=
Verify a message
import { verify } from '@hypereon/message';
const address = '<public_address_of_private_key_wif>';
const message = 'This is an example of a signed message.';
const signature = '<generated_signature_from_sign>';
const isVerified = verify({ address, message, signature });
Message signing defaults to Bitcoin '\u0018Bitcoin Signed Message:\n'. See @hypereon/message
for message prefixes to sign for a different blockchain.
import { sign, verify } from '@hypereon/message';
import message from '@hypereon/message';
const { messagePrefix } = message.ltc.main;
const signature = sign({
privateKey: '...',
message: '...',
messagePrefix,
});
const isVerified = verify({
address: '...',
message: '...',
signature: '...',
messagePrefix,
});
Contributing
If you're interested in contributing, please read the contributing docs before submitting a pull request.
Authors
License
MIT License
0.0.1
3 years ago