Socket
Socket
Sign inDemoInstall

bitcoinjs-lib

Package Overview
Dependencies
Maintainers
4
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitcoinjs-lib - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

11

package.json
{
"name": "bitcoinjs-lib",
"version": "1.0.1",
"version": "1.0.2",
"description": "Client-side Bitcoin JavaScript library",

@@ -76,9 +76,8 @@ "main": "./src/index.js",

"bigi": "1.1.0",
"bs58": "1.1.0",
"bs58check": "1.0.0",
"bs58": "1.2.1",
"bs58check": "1.0.1",
"crypto-js": "3.1.2-3",
"crypto-browserify": "2.1.8",
"ecurve": "0.10.0",
"secure-random": "1.1.1"
"crypto-browserify": "3.0.0",
"ecurve": "1.0.0"
}
}

@@ -78,3 +78,3 @@ # BitcoinJS (bitcoinjs-lib)

console.log(key.toWIF())
// => 8c112cf628362ecf4d482f68af2dbb50c8a2cb90d226215de925417aa9336a48
// => Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct

@@ -124,2 +124,3 @@ // Print your public key (toString defaults to a Bitcoin address)

console.log("multisigP2SH:", multisigAddress)
// => multisigP2SH: 35k9EWv2F1X5JKXHSF1DhTm7Ybdiwx4RkD
```

@@ -141,3 +142,4 @@

- [GreenAddress](https://greenaddress.it)
- [DecentralBank](http://decentralbank.com)
## Contributors

@@ -144,0 +146,0 @@

@@ -6,3 +6,2 @@ var assert = require('assert')

var ECSignature = require('./ecsignature')
var Point = require('ecurve').Point

@@ -79,2 +78,4 @@ // https://tools.ietf.org/html/rfc6979#section-3.2

function verify(curve, hash, signature, Q) {
// 1.4.2 H = Hash(M), already done by the user
// 1.4.3 e = H
var e = BigInteger.fromBuffer(hash)

@@ -92,13 +93,22 @@

if (r.signum() === 0 || r.compareTo(n) >= 0) return false
if (s.signum() === 0 || s.compareTo(n) >= 0) return false
// 1.4.1 Enforce r and s are both integers in the interval [1, n − 1]
if (r.signum() <= 0 || r.compareTo(n) >= 0) return false
if (s.signum() <= 0 || s.compareTo(n) >= 0) return false
// c = s^-1 mod n
var c = s.modInverse(n)
// 1.4.4 Compute u1 = es^−1 mod n
// u2 = rs^−1 mod n
var u1 = e.multiply(c).mod(n)
var u2 = r.multiply(c).mod(n)
var point = G.multiplyTwo(u1, Q, u2)
var v = point.affineX.mod(n)
// 1.4.5 Compute R = (xR, yR) = u1G + u2Q
var R = G.multiplyTwo(u1, Q, u2)
var v = R.affineX.mod(n)
// 1.4.5 (cont.) Enforce R is not at infinity
if (curve.isInfinity(R)) return false
// 1.4.8 If v = r, output "valid", and if v != r, output "invalid"
return v.equals(r)

@@ -118,5 +128,11 @@ }

var n = curve.n
var G = curve.G
var r = signature.r
var s = signature.s
assert(r.signum() > 0 && r.compareTo(n) < 0, 'Invalid r value')
assert(s.signum() > 0 && s.compareTo(n) < 0, 'Invalid s value')
// A set LSB signifies that the y-coordinate is odd

@@ -129,5 +145,2 @@ var isYOdd = i & 1

var n = curve.n
var G = curve.G
// 1.1 Let x = r + jn

@@ -134,0 +147,0 @@ var x = isSecondKey ? r.add(n) : r

var assert = require('assert')
var base58check = require('bs58check')
var crypto = require('crypto')
var ecdsa = require('./ecdsa')
var networks = require('./networks')
var secureRandom = require('secure-random')

@@ -46,3 +46,3 @@ var BigInteger = require('bigi')

ECKey.makeRandom = function(compressed, rng) {
rng = rng || secureRandom.randomBuffer
rng = rng || crypto.randomBytes

@@ -49,0 +49,0 @@ var buffer = rng(32)

@@ -8,3 +8,2 @@ var assert = require('assert')

var Address = require('./address')
var ECKey = require('./eckey')
var ECSignature = require('./ecsignature')

@@ -11,0 +10,0 @@ var Script = require('./script')

var assert = require('assert')
var crypto = require('crypto')
var networks = require('./networks')
var rng = require('secure-random')

@@ -28,3 +28,3 @@ var Address = require('./address')

this.newMasterKey = function(seed) {
seed = seed || new Buffer(rng(32))
seed = seed || crypto.randomBytes(32)
masterkey = HDNode.fromSeedBuffer(seed, network)

@@ -31,0 +31,0 @@

var assert = require('assert')
var crypto = require('../src/crypto')
var crypto = require('crypto')
var networks = require('../src/networks')
var secureRandom = require('secure-random')
var sinon = require('sinon')

@@ -87,9 +85,9 @@

describe('using default RNG', function() {
describe('uses default crypto RNG', function() {
beforeEach(function() {
sinon.stub(secureRandom, 'randomBuffer').returns(exBuffer)
sinon.stub(crypto, 'randomBytes').returns(exBuffer)
})
afterEach(function() {
secureRandom.randomBuffer.restore()
crypto.randomBytes.restore()
})

@@ -120,3 +118,3 @@

describe('signing', function() {
var hash = crypto.sha256('Vires in numeris')
var hash = crypto.randomBytes(32)
var priv = ECKey.makeRandom()

@@ -123,0 +121,0 @@ var signature = priv.sign(hash)

@@ -77,4 +77,14 @@ {

{
"description": "Invalid r value (< 0)",
"exception": "Invalid r value",
"e": "01",
"signature": {
"r": "-01",
"s": "02"
},
"i": 0
},
{
"description": "Invalid r value (== 0)",
"exception": "nR is not a valid curve point",
"exception": "Invalid r value",
"e": "01",

@@ -88,2 +98,42 @@ "signature": {

{
"description": "Invalid s value (< 0)",
"exception": "Invalid s value",
"e": "01",
"signature": {
"r": "02",
"s": "-01"
},
"i": 0
},
{
"description": "Invalid s value (== 0)",
"exception": "Invalid s value",
"e": "01",
"signature": {
"r": "02",
"s": "00"
},
"i": 0
},
{
"description": "Invalid r value (nR is infinity)",
"exception": "nR is not a valid curve point",
"e": "01",
"signature": {
"r": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
"s": "01"
},
"i": 0
},
{
"description": "Invalid curve point",
"exception": "Point is not on the curve",
"e": "01",
"signature": {
"r": "99999999999999999999999999999999999999",
"s": "01"
},
"i": 0
},
{
"description": "Invalid i value (> 3)",

@@ -110,2 +160,11 @@ "exception": "Recovery param is more than two bits",

{
"description": "Invalid r value (< 0)",
"d": "01",
"e": "01",
"signature": {
"r": "-01",
"s": "02"
}
},
{
"description": "Invalid r value (== 0)",

@@ -129,2 +188,11 @@ "d": "01",

{
"description": "Invalid s value (< 0)",
"d": "01",
"e": "01",
"signature": {
"r": "02",
"s": "-01"
}
},
{
"description": "Invalid s value (== 0)",

@@ -146,2 +214,11 @@ "d": "01",

}
},
{
"description": "Invalid r, s values (r = s = -n)",
"d": "01",
"e": "01",
"signature": {
"r": "-115792089237316195423570985008687907852837564279074904382605163141518161494337",
"s": "-115792089237316195423570985008687907852837564279074904382605163141518161494337"
}
}

@@ -148,0 +225,0 @@ ]

@@ -307,13 +307,9 @@ var assert = require('assert')

describe('processConfirmedTx', function(){
it('does not fail on scripts with no corresponding Address', function() {
it('does not throw on scripts with no corresponding Address', function() {
var pubKey = wallet.getPrivateKey(0).pub
var script = scripts.pubKeyOutput(pubKey)
var tx2 = new Transaction()
tx2.addInput(fakeTxId(1), 0)
// FIXME: Transaction doesn't support custom ScriptPubKeys... yet
// So for now, we hijack the script with our own, and undefine the cached address
tx2.addOutput(addresses[0], 10000)
tx2.outs[0].script = script
tx2.outs[0].address = undefined
tx2.addInput(fakeTxHash(1), 0)
tx2.addOutput(script, 10000)

@@ -320,0 +316,0 @@ wallet.processConfirmedTx(tx2)

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