Esteban Ordano
10 years ago
10 changed files with 110 additions and 168 deletions
@ -1,36 +1,23 @@ |
|||
# Crypto |
|||
|
|||
The cryptographic primitives (ECDSA and HMAC) implementations in this package |
|||
have been audited by: |
|||
|
|||
* The BitPay engineering team |
|||
The cryptographic primitives (ECDSA and HMAC) implementations in this package have been audited bythe BitPay engineering team. More review and certifications are always 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). |
|||
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](https://github.com/indutny/bn.js), the bignum library used internally |
|||
in bitcore. |
|||
The `bitcore.Crypto.BN` class contains a wrapper around [bn.js](https://github.com/indutny/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](https://github.com/indutny/elliptic.js), the elliptic curve |
|||
library used internally in bitcore. |
|||
The `bitcore.Crypto.Point` class contains a wrapper around the class Point of [elliptic.js](https://github.com/indutny/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. |
|||
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. |
|||
`bitcore.Crypto.ECDSA` contains a pure javascript implementation of the elliptic curve DSA signature scheme. |
|||
|
@ -1,12 +1,38 @@ |
|||
# Hierarichically Derived Keys |
|||
|
|||
Bitcore provides full support for |
|||
[BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki), |
|||
allowing for many key management schemas that benefit from this property. |
|||
Please be sure to read and understand the basic concepts and the warnings on |
|||
that BIP before using these classes. |
|||
Bitcore provides full support for [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki), allowing for many key management schemas that benefit from this property. Please be sure to read and understand the basic concepts and the warnings on that BIP before using these classes. |
|||
|
|||
## HDPrivateKey |
|||
|
|||
This class initially meant to share the interface of |
|||
[PrivateKey](http://missing-link) but add the ability to derive new keys. |
|||
An instance of a [PrivateKey](#PrivateKey.md) that also contains information required to derive child keys. |
|||
|
|||
Sample usage: |
|||
|
|||
```javascript |
|||
var hdPrivateKey = new HDPrivateKey(); |
|||
var retrieved = new HDPrivateKey('xpriv...'); |
|||
var derived = privateKey.derive("m/0'"); |
|||
var derivedByNumber = privateKey.derive(1).derive(2, true); |
|||
var derivedByArgument = privateKey.derive("m/1/2'"); |
|||
assert(derivedByNumber.xprivkey === derivedByArgument.xprivkey); |
|||
|
|||
var address = new Address(privateKey.publicKey, Networks.livenet); |
|||
var redeem = new Transaction().from(output).to(target, 10000).sign(derived.privateKey); |
|||
``` |
|||
|
|||
## HDPublicKey |
|||
|
|||
An instance of a PublicKey that can be derived to build extended public keys. Note that hardened paths are not available when deriving an HDPublicKey. |
|||
|
|||
```javascript |
|||
var hdPrivateKey = new HDPrivateKey(); |
|||
var hdPublicKey = privateKey.hdPublicKey; |
|||
try { |
|||
new HDPublicKey(); |
|||
} catch(e) { |
|||
console.log("Can't generate a public key without a private key"); |
|||
} |
|||
|
|||
var address = new Address(hdPublicKey.publicKey, Networks.livenet); |
|||
var derivedAddress = new Address(hdPublicKey.derive(100).publicKey, Networks.testnet); |
|||
``` |
|||
|
@ -1 +0,0 @@ |
|||
# Input |
@ -1 +0,0 @@ |
|||
# Output |
Loading…
Reference in new issue