Renames util.js to crypto.js
This commit is contained in:
parent
a4c2cc6dd4
commit
81d9c8e759
7 changed files with 16 additions and 16 deletions
|
@ -7,7 +7,7 @@ var ecdsa = require('./ecdsa')
|
|||
var ECPointFp = require('./jsbn/ec').ECPointFp
|
||||
var sec = require('./jsbn/sec')
|
||||
var Network = require('./network')
|
||||
var util = require('./util')
|
||||
var crypto = require('./crypto')
|
||||
var ecparams = sec("secp256k1")
|
||||
|
||||
// input can be nothing, array of bytes, hex string, or base58 string
|
||||
|
@ -175,7 +175,7 @@ ECPubKey.prototype.toString = ECPubKey.prototype.toHex
|
|||
ECPubKey.prototype.getAddress = function(version) {
|
||||
version = version || Network.mainnet.addressVersion
|
||||
|
||||
return new Address(util.sha256ripe160(this.toBytes()), version)
|
||||
return new Address(crypto.sha256ripe160(this.toBytes()), version)
|
||||
}
|
||||
|
||||
ECPubKey.prototype.verify = function(hash, sig) {
|
||||
|
|
|
@ -2,7 +2,7 @@ var convert = require('./convert.js')
|
|||
var base58 = require('./base58.js')
|
||||
var assert = require('assert')
|
||||
var format = require('util').format
|
||||
var util = require('./util.js')
|
||||
var crypto = require('./crypto')
|
||||
var Crypto = require('crypto-js')
|
||||
var HmacSHA512 = Crypto.HmacSHA512
|
||||
var HMAC= Crypto.algo.HMAC
|
||||
|
@ -11,10 +11,10 @@ var ECPubKey = require('./eckey.js').ECPubKey
|
|||
var Address = require('./address.js')
|
||||
var Network = require('./network')
|
||||
|
||||
var crypto = require('crypto')
|
||||
var crypto2 = require('crypto')
|
||||
|
||||
function sha256(buf) {
|
||||
var hash = crypto.createHash('sha256')
|
||||
var hash = crypto2.createHash('sha256')
|
||||
hash.update(buf)
|
||||
|
||||
return hash.digest()
|
||||
|
@ -131,7 +131,7 @@ HDWallet.fromBytes = function(input) {
|
|||
}
|
||||
|
||||
HDWallet.prototype.getIdentifier = function() {
|
||||
return util.sha256ripe160(this.pub.toBytes())
|
||||
return crypto.sha256ripe160(this.pub.toBytes())
|
||||
}
|
||||
|
||||
HDWallet.prototype.getFingerprint = function() {
|
||||
|
@ -139,7 +139,7 @@ HDWallet.prototype.getFingerprint = function() {
|
|||
}
|
||||
|
||||
HDWallet.prototype.getAddress = function() {
|
||||
return new Address(util.sha256ripe160(this.pub.toBytes()), this.getKeyVersion())
|
||||
return new Address(crypto.sha256ripe160(this.pub.toBytes()), this.getKeyVersion())
|
||||
}
|
||||
|
||||
HDWallet.prototype.toBytes = function(priv) {
|
||||
|
|
|
@ -12,7 +12,7 @@ module.exports = {
|
|||
Script: require('./script'),
|
||||
Opcode: require('./opcode'),
|
||||
Transaction: T.Transaction,
|
||||
Util: require('./util'),
|
||||
crypto: require('./crypto'),
|
||||
TransactionIn: T.TransactionIn,
|
||||
TransactionOut: T.TransactionOut,
|
||||
ECPointFp: require('./jsbn/ec').ECPointFp,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var Opcode = require('./opcode')
|
||||
var util = require('./util')
|
||||
var crypto = require('./crypto')
|
||||
var convert = require('./convert')
|
||||
var Address = require('./address')
|
||||
var network = require('./network')
|
||||
|
@ -144,10 +144,10 @@ Script.prototype.toScriptHash = function() {
|
|||
}
|
||||
|
||||
if (outType == 'P2SH') {
|
||||
return util.sha256ripe160(this.buffer)
|
||||
return crypto.sha256ripe160(this.buffer)
|
||||
}
|
||||
|
||||
return util.sha256ripe160(this.buffer)
|
||||
return crypto.sha256ripe160(this.buffer)
|
||||
}
|
||||
|
||||
//TODO: support testnet
|
||||
|
@ -257,7 +257,7 @@ Script.prototype.simpleInPubKey = function() {
|
|||
* This method is useful for indexing transactions.
|
||||
*/
|
||||
Script.prototype.simpleInHash = function() {
|
||||
return util.sha256ripe160(this.simpleInPubKey())
|
||||
return crypto.sha256ripe160(this.simpleInPubKey())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var BigInteger = require('./jsbn/jsbn')
|
||||
var Script = require('./script')
|
||||
var util = require('./util')
|
||||
var crypto = require('./crypto')
|
||||
var convert = require('./convert')
|
||||
var ECKey = require('./eckey').ECKey
|
||||
var ECDSA = require('./ecdsa')
|
||||
|
@ -303,7 +303,7 @@ Transaction.prototype.sign = function(index, key, type) {
|
|||
// TODO: getPub is slow, sha256ripe160 probably is too.
|
||||
// This could be sped up a lot by providing these as inputs.
|
||||
var pub = key.getPub().toBytes(),
|
||||
hash160 = util.sha256ripe160(pub),
|
||||
hash160 = crypto.sha256ripe160(pub),
|
||||
script = Script.createOutputScript(new Address(hash160)),
|
||||
hash = this.hashTransactionForSignature(script, index, type),
|
||||
sig = key.sign(hash).concat([type])
|
||||
|
|
|
@ -2,8 +2,8 @@ var Script = require('../src/script.js')
|
|||
var assert = require('assert')
|
||||
var Address = require('../src/address.js')
|
||||
var Network = require('../src/network.js')
|
||||
var Util = require('../src/util.js')
|
||||
var sha256ripe160 = Util.sha256ripe160
|
||||
var crypto = require('../').crypto
|
||||
var sha256ripe160 = crypto.sha256ripe160
|
||||
var Convert = require('../src/convert.js')
|
||||
var bytesToHex = Convert.bytesToHex
|
||||
var hexToBytes = Convert.hexToBytes
|
||||
|
|
Loading…
Add table
Reference in a new issue