Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@metamask/eth-sig-util

Package Overview
Dependencies
Maintainers
11
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/eth-sig-util

A few useful functions for signing ethereum data

  • 8.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
337K
increased by14.89%
Maintainers
11
Weekly downloads
 
Created

What is @metamask/eth-sig-util?

@metamask/eth-sig-util is a utility library for Ethereum signature operations. It provides functions for signing and verifying messages, encoding and decoding data, and other cryptographic operations related to Ethereum.

What are @metamask/eth-sig-util's main functionalities?

Sign Typed Data

This feature allows you to sign typed data using a private key. The `signTypedData` function takes a private key and a message parameter, and returns a signature.

const { signTypedData } = require('@metamask/eth-sig-util');
const privateKey = Buffer.from('your-private-key', 'hex');
const msgParams = {
  data: [{
    type: 'string',
    name: 'message',
    value: 'Hello, world!'
  }]
};
const signature = signTypedData({ privateKey, data: msgParams.data });
console.log(signature);

Recover Typed Signature

This feature allows you to recover the address that signed a typed data message. The `recoverTypedSignature` function takes a message parameter and a signature, and returns the address that signed the message.

const { recoverTypedSignature } = require('@metamask/eth-sig-util');
const msgParams = {
  data: [{
    type: 'string',
    name: 'message',
    value: 'Hello, world!'
  }]
};
const signature = 'your-signature';
const address = recoverTypedSignature({ data: msgParams.data, sig: signature });
console.log(address);

Encrypt and Decrypt Data

This feature allows you to encrypt and decrypt data using public and private keys. The `encrypt` function takes a public key and data, and returns encrypted data. The `decrypt` function takes a private key and encrypted data, and returns the decrypted data.

const { encrypt, decrypt } = require('@metamask/eth-sig-util');
const publicKey = 'recipient-public-key';
const data = 'Hello, world!';
const encryptedData = encrypt({ publicKey, data });
console.log(encryptedData);
const privateKey = Buffer.from('your-private-key', 'hex');
const decryptedData = decrypt({ privateKey, encryptedData });
console.log(decryptedData);

Other packages similar to @metamask/eth-sig-util

Keywords

FAQs

Package last updated on 18 Oct 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

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