0.2.2 โ€ข Published 1 year ago

@lukso/eip191-signer.js v0.2.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

eip191-signer.js ยท GitHub license npm version PRs Welcome

Getting Started

The @lukso/eip191-signer.js package is used to sign messages according to the EIP191 standard.

If you want to sign with the version 0x45, then use the function signEthereumSignedMessage.

If you want to sign with the version 0x00, then use the function signDataWithIntendedValidator.

Install

npm install @lukso/eip191-signer.js

Usage

import { EIP191Signer } from '@lukso/eip191-signer.js';

const eip191Signer = new EIP191Signer();

hashEthereumSignedMessage

eip191Signer.hashEthereumSignedMessage(message);

Hashes the given message with the version 0x45.

The message will be enveloped as follows: '\x19' + '\x45' + 'thereum Signed Message:\n' + messageBytes.length + message and hashed using keccak256.

hashDataWithIntendedValidator

eip191Signer.hashDataWithIntendedValidator(validatorAddress, message);

Hashes the given message with the version 0x00.

The message will be enveloped as follows: '\x19' + '\x00' + validatorAddress + message and hashed using keccak256.

signEthereumSignedMessage

eip191Signer.signEthereumSignedMessage(message, signingKey);

This method is for signing a message with the version 0x45.

The message passed as parameter will be wrapped as follows: '\x19' + '\x45' + 'thereum Signed Message:\n' + messageBytes.length + message.

signDataWithIntendedValidator

eip191Signer.signDataWithIntendedValidator(
  validatorAddress,
  message,
  signingKey,
);

This method is for signing a message with the version 0x00.

The message passed as parameter will be wrapped as follows: '\x19' + '\x00' + validatorAddress + message.

recover

eip191Signer.recover(messageHash, signature);

Recovers the address which was used to sign the given message.

Contributing

Please check CONTRIBUTING.md.

License

eip191-signer.js is Apache 2.0 licensed.

Contributors