Socket
Socket
Sign inDemoInstall

eth-sig-util

Package Overview
Dependencies
Maintainers
6
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eth-sig-util

A few useful functions for signing ethereum data


Version published
Weekly downloads
116K
decreased by-21.43%
Maintainers
6
Weekly downloads
 
Created

What is eth-sig-util?

The eth-sig-util npm package provides utilities for signing and verifying Ethereum signatures. It is commonly used in Ethereum-based applications to handle cryptographic operations related to user authentication, transaction signing, and message verification.

What are eth-sig-util's main functionalities?

Sign Typed Data

This feature allows you to sign typed data according to the EIP-712 standard. The code sample demonstrates how to sign a typed data object using a private key.

const sigUtil = require('eth-sig-util');
const privateKey = Buffer.from('your_private_key', 'hex');
const data = { types: { EIP712Domain: [ { name: 'name', type: 'string' }, { name: 'version', type: 'string' }, { name: 'chainId', type: 'uint256' }, { name: 'verifyingContract', type: 'address' } ], Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' } ] }, primaryType: 'Person', domain: { name: 'MyApp', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC' }, message: { name: 'Alice', wallet: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC' } };
const signature = sigUtil.signTypedData_v4(privateKey, { data });
console.log(signature);

Recover Typed Data Signer

This feature allows you to recover the address of the signer from a signed typed data object. The code sample demonstrates how to recover the signer's address using the signature and the original data.

const sigUtil = require('eth-sig-util');
const signature = 'your_signature';
const data = { types: { EIP712Domain: [ { name: 'name', type: 'string' }, { name: 'version', type: 'string' }, { name: 'chainId', type: 'uint256' }, { name: 'verifyingContract', type: 'address' } ], Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' } ] }, primaryType: 'Person', domain: { name: 'MyApp', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC' }, message: { name: 'Alice', wallet: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC' } };
const recoveredAddress = sigUtil.recoverTypedSignature_v4({ data, sig: signature });
console.log(recoveredAddress);

Personal Sign

This feature allows you to sign a personal message. The code sample demonstrates how to sign a simple message using a private key.

const sigUtil = require('eth-sig-util');
const privateKey = Buffer.from('your_private_key', 'hex');
const message = 'Hello, world!';
const signature = sigUtil.personalSign(privateKey, { data: message });
console.log(signature);

Recover Personal Signer

This feature allows you to recover the address of the signer from a signed personal message. The code sample demonstrates how to recover the signer's address using the signature and the original message.

const sigUtil = require('eth-sig-util');
const signature = 'your_signature';
const message = 'Hello, world!';
const recoveredAddress = sigUtil.recoverPersonalSignature({ data: message, sig: signature });
console.log(recoveredAddress);

Other packages similar to eth-sig-util

Keywords

FAQs

Package last updated on 05 Feb 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc