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

tiny-secp256k1-native

v1.1.0

Published

A tiny secp256k1 native wrapper

Downloads

9

Readme

tiny-secp256k1-native

Build Status NPM js-standard-style

This library is under development, and, like the secp256k1 C library it depends on, this is a research effort to determine an optimal API for end-users of the bitcoinjs ecosystem.

This library is the native component of tiny-secp256k1. It is an optional dependency so that npm install will not fail for tiny-secp256k1 and it will fallback to the JS implementation

Installation

npm

npm install tiny-secp256k1-native

yarn

yarn add tiny-secp256k1-native

If you are having problems, please read the guide at secp256k1-node, as the build instructions should be exactly the same (and this module is a direct derivation).

Documentation

isPoint (A)

isPoint :: Buffer -> Bool

Returns false if

  • A is not encoded with a sequence tag of 0x02, 0x03 or 0x04
  • A.x is not in [1...p - 1]
  • A.y is not in [1...p - 1]

isPointCompressed (A)

isPointCompressed :: Buffer -> Bool

Returns false if the signature is not compressed.

isPrivate (d)

isPrivate :: Buffer -> Bool

Returns false if

  • d is not 256-bit, or
  • d is not in [1..order - 1]

pointAdd (A, B[, compressed])

pointAdd :: Buffer -> Buffer [-> Bool] -> Maybe Buffer

Returns null if result is at infinity.

Throws:
  • Expected Point if !isPoint(A)
  • Expected Point if !isPoint(B)

pointAddScalar (A, tweak[, compressed])

pointAddScalar :: Buffer -> Buffer [-> Bool] -> Maybe Buffer

Returns null if result is at infinity.

Throws:
  • Expected Point if !isPoint(A)
  • Expected Tweak if tweak is not in [0...order - 1]

pointCompress (A, compressed)

pointCompress :: Buffer -> Bool -> Buffer
Throws:
  • Expected Point if !isPoint(A)

pointFromScalar (d[, compressed])

pointFromScalar :: Buffer [-> Bool] -> Maybe Buffer

Returns null if result is at infinity.

Throws:
  • Expected Private if !isPrivate(d)

pointMultiply (A, tweak[, compressed])

pointMultiply :: Buffer -> Buffer [-> Bool] -> Maybe Buffer

Returns null if result is at infinity.

Throws:
  • Expected Point if !isPoint(A)
  • Expected Tweak if tweak is not in [0...order - 1]

privateAdd (d, tweak)

privateAdd :: Buffer -> Buffer -> Maybe Buffer

Returns null if result is equal to 0.

Throws:
  • Expected Private if !isPrivate(d)
  • Expected Tweak if tweak is not in [0...order - 1]

privateSub (d, tweak)

privateSub :: Buffer -> Buffer -> Maybe Buffer

Returns null if result is equal to 0.

Throws:
  • Expected Private if !isPrivate(d)
  • Expected Tweak if tweak is not in [0...order - 1]

sign (h, d)

sign :: Buffer -> Buffer -> Buffer

Returns normalized signatures, each of (r, s) values are guaranteed to less than order / 2. Uses RFC6979.

Throws:
  • Expected Private if !isPrivate(d)
  • Expected Scalar if h is not 256-bit

signWithEntropy (h, d, e)

sign :: Buffer -> Buffer -> Buffer -> Buffer

Returns normalized signatures, each of (r, s) values are guaranteed to less than order / 2. Uses RFC6979. Adds e as Added Entropy to the deterministic k generation.

Throws:
  • Expected Private if !isPrivate(d)
  • Expected Scalar if h is not 256-bit
  • Expected Extra Data (32 bytes) if e is not 256-bit

verify (h, Q, signature[, strict = false])

verify :: Buffer -> Buffer -> Buffer -> Bool

Returns false if any of (r, s) values are equal to 0, or if the signature is rejected.

If strict is true, valid signatures with any of (r, s) values greater than order / 2 are rejected.

Throws:
  • Expected Point if !isPoint(Q)
  • Expected Signature if signature has any (r, s) values not in range [0...order - 1]
  • Expected Scalar if h is not 256-bit

Credit

This is a partially derived work of https://github.com/cryptocoinjs/secp256k1-node, specifically this commit.

This library uses the native library secp256k1 by the bitcoin-core developers, including derivatives of its tests and test vectors.

LICENSE MIT