New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@hyperbitjs/message

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyperbitjs/message

![Hyperbit Message Banner](https://github.com/hyperbit-dev/message/raw/master/media/repo-banner.png)

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

Hyperbit Message Banner

Hyperbit - Message

JavaScript functions for signing and verifying messages.

Installation

npm install @hyperbitjs/message

Usage

Sign a message using a private key

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

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

import { verify } from "@hyperbitjs/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 isValid = verify({ address, message, signature });

Full Example

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

FAQs

Package last updated on 23 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts