npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@xstorage/xs-js-libp2p-crypto-secp256k1

v0.1.2

Published

xStorage impletion of ipfs js-libp2p-crypto-secp256k1

Downloads

7

Readme

xS-js-libp2p-crypto-secp256k1

![npm](https://img.shields.io/badge/Project-xS%20js%20libp2p crypto-blue.svg?style=plastic) npm npm

Build Status codecov Nodejs npm

Support for secp256k1 keys in xS-js-libp2p-crypto

维护者: Paul Zhang, Chunhv Liu

This repo contains a xS-js-libp2p-crypto-compatible implementation of cryptographic signature generation and verification using the secp256k1 elliptic curve popularized by Bitcoin and other crypto currencies.

Table of Contents

1. 安装

npm install --save xS-js-libp2p-crypto-secp256k1

2. 使用

This module is designed to work with xS-js-libp2p-crypto
Installing xS-js-libp2p-crypto-secp256k1 will automatically add support for the 'secp256k1' key type, which can be used as an argument to the xS-js-libp2p-crypto API functions generateKeyPair, unmarshalPublicKey, and marshalPrivateKey. The keys returned from those functions will be instances of the Secp256k1PublicKey or Secp256k1PrivateKey classes provided by this module.

Example

const crypto = require('libp2p-crypto')

const msg = Buffer.from('Hello World')

crypto.generateKeyPair('secp256k1', 256, (err, key) => {
  // assuming no error, key will be an instance of Secp256k1PrivateKey
  // the public key is available as key.public
  key.sign(msg, (err, sig) => {
    key.public.verify(msg, sig, (err, valid) => {
      assert(valid, 'Something went horribly wrong')
    })
  })
})

3. API

The functions below are the public API of this module.

generateKeyPair([bits, ] callback)

  • bits: Number - Optional, included for compatibility with js-libp2p-crypto. Ignored if present; private keys will always be 256 bits.
  • callback: Function

unmarshalSecp256k1PublicKey(bytes)

  • bytes: Buffer

Converts a serialized secp256k1 public key into an instance of Secp256k1PublicKey and returns it

unmarshalSecp256k1PrivateKey(bytes, callback)

  • bytes: Buffer
  • callback: Function

Converts a serialized secp256k1 private key into an instance of Secp256k1PrivateKey, passing it to callback on success

Secp256k1PublicKey

.verify(data, sig, callback)

  • data: Buffer
  • sig: Buffer
  • callback: Function

Calculates the SHA-256 hash of data, and verifies the DER-encoded signature in sig, passing the result to callback

Secp256k1PrivateKey

.public

Accessor for the Secp256k1PublicKey associated with this private key.

.sign(data, callback)

  • data: Buffer

Calculates the SHA-256 hash of data and signs it, passing the DER-encoded signature to callback

4. Contribute

Contributions welcome. Please check out the issues.

5. 致谢

@multiformats multiaddr

6. 资助我们

Cryptocurrency is welcomed.

ETH: 0xCd0e5cE4a29Fd6441b95FA857753f68D09339628

7. License

MIT © 2016 Protocol Labs Inc.