Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hyperbit-dev/message
JavaScript functions for blockchain signing and verifying messages.
https://github.com/hyperbit-dev/message
bitcoin bitcoinjs javascript message-signing message-verifier sign typescript verify
Last synced: 24 days ago
JSON representation
JavaScript functions for blockchain signing and verifying messages.
- Host: GitHub
- URL: https://github.com/hyperbit-dev/message
- Owner: hyperbit-dev
- License: mit
- Created: 2022-11-15T03:30:12.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-23T00:17:03.000Z (9 months ago)
- Last Synced: 2024-04-25T11:43:44.780Z (7 months ago)
- Topics: bitcoin, bitcoinjs, javascript, message-signing, message-verifier, sign, typescript, verify
- Language: TypeScript
- Homepage:
- Size: 424 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![Hyperbit Message Banner](https://github.com/hyperbit-dev/message/raw/master/media/repo-banner.png)
# Hyperbit - Message
JavaScript functions for signing and verifying messages.
## Installation
```bash
npm install @hyperbitjs/message
```## Usage
### Sign a message using a private key
```javascript
import { rvn } from "@hyperbitjs/chains";
import { sign } from "@hyperbitjs/message";// Wallet Import Format (WIF) format
const privateKey =
"963523425d5de8ad42320df7ec9ba0e7f15783914da16e0aff93df20c7b668fb";
const message = "This is an example of a signed message.";const signature = sign({ message, privateKey, network: rvn.mainnet });
// Expected Result: IIHJVUBhHEnGXun89PyIyoua265DKhACWFxG3LRAJTz+S03huR+vIaWhgJPYDoxAlS/EFN7nqydAfP6n+UBDvdY=
```### Sign a message using a private key WIF
```javascript
import { rvn } from "@hyperbitjs/chains";
import { sign } from "@hyperbitjs/message";// Wallet Import Format (WIF) format
const privateKeyWIF = "T85xhCTbfJnMW4a8qB4ubAFVgshrDdU9jcDmrSgNntTp6YSrub7M";
const message = "This is an example of a signed message.";const signature = sign({ message, privateKeyWIF, network: rvn.mainnet });
// Expected Result: IIHJVUBhHEnGXun89PyIyoua265DKhACWFxG3LRAJTz+S03huR+vIaWhgJPYDoxAlS/EFN7nqydAfP6n+UBDvdY=
```### Verify a message
```javascript
import { verify } from "@hyperbitjs/message";const address = "";
const message = "This is an example of a signed message.";
const signature = "";const isValid = verify({ address, message, signature });
```### Full Example
```javascript
import { Mnemonic } from "@hyperbitjs/mnemonic";
import { sign, verify } from "@hyperbitjs/message";
import { ltc } from "@hyperbitjs/chains";const mnemonic = new Mnemonic({ network: ltc.main });
const addresses = mnemonic.generateAddresses();const { address, privateKey } = addresses[0].external;
const network = ltc.main;
const message = "This is an example of a signed message.";const signature = sign({
privateKey,
message,
network,
});const isValid = verify({
message,
address,
signature,
network,
});console.log("isValid", isValid);
// Expected Output: true
```## License
[MIT](/LICENSE) License