Bitcoin Crypto

The cryptographic primitives (ECDSA and HMAC) implementations in this package have been reviewed by the BitPay engineering team. More audits and reviews are welcomed.

Random

The bitcore.crypto.Random namespace contains a single function, named getRandomBuffer(size) that returns a Buffer instance with random bytes. It may not work depending on the engine that bitcore is running on (doesn't work with IE versions lesser than 11).

BN

The bitcore.Crypto.BN class contains a wrapper around bn.js, the bignum library used internally in bitcore.

Point

The bitcore.Crypto.Point class contains a wrapper around the class Point of elliptic.js, the elliptic curve library used internally in bitcore.

Hash

The bitcore.Crypto.Hash namespace contains a set of hashes and utilities. These are either the native crypto hash functions from node.js or their respective browser shims as provided by the browserify library.

ECDSA

bitcore.Crypto.ECDSA contains a pure JavaScript implementation of the elliptic curve DSA signature scheme based on elliptic.js.

Point ⇐ elliptic.curve.point

Kind: global class
Extends: elliptic.curve.point
Link: https://github.com/indutny/elliptic

new Point(x, y)

Instantiate a valid secp256k1 Point from the X and Y coordinates.

Returns: Point - An instance of Point
Throws:

  • Error A validation error if exists
Param Type Description
x BN | String The X coordinate
y BN | String The Y coordinate

point.getX() ⇒ BN

Will return the X coordinate of the Point

Kind: instance method of Point
Returns: BN - A BN instance of the X coordinate

point.getY() ⇒ BN

Will return the Y coordinate of the Point

Kind: instance method of Point
Returns: BN - A BN instance of the Y coordinate

point.validate(An) ⇒ Point

Will determine if the point is valid

Kind: instance method of Point
Returns: Point - An instance of the same Point
Throws:

  • Error A validation error if exists

Link: https://www.iacr.org/archive/pkc2003/25670211/25670211.pdf

Param Type Description
An Point instance of Point

Point.fromX(odd, x) ⇒ Point

Instantiate a valid secp256k1 Point from only the X coordinate

Kind: static method of Point
Returns: Point - An instance of Point
Throws:

  • Error A validation error if exists
Param Type Description
odd boolean If the Y coordinate is odd
x BN | String The X coordinate

Point.getG() ⇒ Point

Will return a secp256k1 ECDSA base point.

Kind: static method of Point
Returns: Point - An instance of the base point.
Link: https://en.bitcoin.it/wiki/Secp256k1

Point.getN() ⇒ BN

Will return the max of range of valid private keys as governed by the secp256k1 ECDSA standard.

Kind: static method of Point
Returns: BN - A BN instance of the number of points on the curve
Link: https://en.bitcoin.it/wiki/Private_key#Range_of_valid_ECDSA_private_keys