Browse Source

'hide' encoding and crypto

patch-2
Manuel Araoz 10 years ago
parent
commit
a45dee3a4b
  1. 24
      index.js
  2. 4
      test/block.js
  3. 2
      test/blockheader.js
  4. 2
      test/keypair.js
  5. 18
      test/networks.js
  6. 4
      test/privkey.js
  7. 12
      test/pubkey.js
  8. 2
      test/signature.js
  9. 4
      test/transaction.js
  10. 4
      test/txin.js
  11. 6
      test/txout.js

24
index.js

@ -2,18 +2,20 @@ var bitcore = module.exports;
// crypto // crypto
bitcore.BN = require('./lib/crypto/bn'); bitcore.crypto = {};
bitcore.ECDSA = require('./lib/crypto/ecdsa'); bitcore.crypto.BN = require('./lib/crypto/bn');
bitcore.Hash = require('./lib/crypto/hash'); bitcore.crypto.ECDSA = require('./lib/crypto/ecdsa');
bitcore.Random = require('./lib/crypto/random'); bitcore.crypto.Hash = require('./lib/crypto/hash');
bitcore.Point = require('./lib/crypto/point'); bitcore.crypto.Random = require('./lib/crypto/random');
bitcore.crypto.Point = require('./lib/crypto/point');
// encoding // encoding
bitcore.Base58 = require('./lib/encoding/base58'); bitcore.encoding = {};
bitcore.Base58Check = require('./lib/encoding/base58check'); bitcore.encoding.Base58 = require('./lib/encoding/base58');
bitcore.BufferReader = require('./lib/encoding/bufferreader'); bitcore.encoding.Base58Check = require('./lib/encoding/base58check');
bitcore.BufferWriter = require('./lib/encoding/bufferwriter'); bitcore.encoding.BufferReader = require('./lib/encoding/bufferreader');
bitcore.Varint = require('./lib/encoding/varint'); bitcore.encoding.BufferWriter = require('./lib/encoding/bufferwriter');
bitcore.encoding.Varint = require('./lib/encoding/varint');
// main bitcoin library // main bitcoin library
bitcore.Address = require('./lib/address'); bitcore.Address = require('./lib/address');
@ -21,7 +23,7 @@ bitcore.BIP32 = require('./lib/bip32');
bitcore.Block = require('./lib/block'); bitcore.Block = require('./lib/block');
bitcore.Blockheader = require('./lib/blockheader'); bitcore.Blockheader = require('./lib/blockheader');
bitcore.Keypair = require('./lib/keypair'); bitcore.Keypair = require('./lib/keypair');
bitcore.networks = require('./lib/networks'); bitcore.Networks = require('./lib/networks');
bitcore.Opcode = require('./lib/opcode'); bitcore.Opcode = require('./lib/opcode');
bitcore.Privkey = require('./lib/privkey'); bitcore.Privkey = require('./lib/privkey');
bitcore.Pubkey = require('./lib/pubkey'); bitcore.Pubkey = require('./lib/pubkey');

4
test/block.js

@ -2,10 +2,10 @@
var should = require('chai').should(); var should = require('chai').should();
var bitcore = require('..'); var bitcore = require('..');
var Varint = bitcore.encoding.Varint;
var BufferReader = bitcore.encoding.BufferReader;
var Blockheader = bitcore.Blockheader; var Blockheader = bitcore.Blockheader;
var Block = bitcore.Block; var Block = bitcore.Block;
var BufferReader = bitcore.BufferReader;
var Varint = bitcore.Varint;
var Transaction = bitcore.Transaction; var Transaction = bitcore.Transaction;
describe('Block', function() { describe('Block', function() {

2
test/blockheader.js

@ -2,8 +2,8 @@
var should = require('chai').should(); var should = require('chai').should();
var bitcore = require('..'); var bitcore = require('..');
var BufferReader = bitcore.encoding.BufferReader;
var Blockheader = bitcore.Blockheader; var Blockheader = bitcore.Blockheader;
var BufferReader = bitcore.BufferReader;
describe('Blockheader', function() { describe('Blockheader', function() {

2
test/keypair.js

@ -2,7 +2,7 @@
var should = require('chai').should(); var should = require('chai').should();
var bitcore = require('..'); var bitcore = require('..');
var bn = bitcore.BN; var bn = bitcore.crypto.BN;
var Privkey = bitcore.Privkey; var Privkey = bitcore.Privkey;
var Pubkey = bitcore.Pubkey; var Pubkey = bitcore.Pubkey;
var Keypair = bitcore.Keypair; var Keypair = bitcore.Keypair;

18
test/networks.js

@ -2,20 +2,20 @@
var should = require('chai').should(); var should = require('chai').should();
var bitcore = require('..'); var bitcore = require('..');
var networks = bitcore.networks; var Networks = bitcore.Networks;
describe('networks', function() { describe('Networks', function() {
it('should contain all networks', function() { it('should contain all Networks', function() {
should.exist(networks.livenet); should.exist(Networks.livenet);
should.exist(networks.testnet); should.exist(Networks.testnet);
should.exist(networks.mainnet); should.exist(Networks.mainnet);
}); });
describe('contain all constants for livenet and testnet', function() { describe('contain all constants for livenet and testnet', function() {
for (var key in networks.livenet) { for (var key in Networks.livenet) {
if (networks.livenet.hasOwnProperty(key)) { if (Networks.livenet.hasOwnProperty(key)) {
it('all should contain '+key, function() { it('all should contain '+key, function() {
networks.testnet.hasOwnProperty(key).should.equal(true); Networks.testnet.hasOwnProperty(key).should.equal(true);
}); });
} }
} }

4
test/privkey.js

@ -2,9 +2,9 @@
var should = require('chai').should(); var should = require('chai').should();
var bitcore = require('..'); var bitcore = require('..');
var BN = bitcore.crypto.BN;
var Point = bitcore.crypto.Point;
var Privkey = bitcore.Privkey; var Privkey = bitcore.Privkey;
var BN = bitcore.BN;
var Point = bitcore.Point;
describe('Privkey', function() { describe('Privkey', function() {
var hex = '96c132224121b509b7d0a16245e957d9192609c5637c6228311287b1be21627a'; var hex = '96c132224121b509b7d0a16245e957d9192609c5637c6228311287b1be21627a';

12
test/pubkey.js

@ -2,9 +2,9 @@
var should = require('chai').should(); var should = require('chai').should();
var bitcore = require('..'); var bitcore = require('..');
var Point = bitcore.crypto.Point;
var BN = bitcore.crypto.BN;
var Pubkey = bitcore.Pubkey; var Pubkey = bitcore.Pubkey;
var Point = bitcore.Point;
var Bn = bitcore.BN;
var Privkey = bitcore.Privkey; var Privkey = bitcore.Privkey;
describe('Pubkey', function() { describe('Pubkey', function() {
@ -128,7 +128,7 @@ describe('Pubkey', function() {
describe('#fromX', function() { describe('#fromX', function() {
it('should create this known public key', function() { it('should create this known public key', function() {
var x = Bn.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex')); var x = BN.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
var pk = new Pubkey(); var pk = new Pubkey();
pk.fromX(true, x); pk.fromX(true, x);
pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a'); pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
@ -140,7 +140,7 @@ describe('Pubkey', function() {
describe('#toBuffer', function() { describe('#toBuffer', function() {
it('should return this compressed DER format', function() { it('should return this compressed DER format', function() {
var x = Bn.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex')); var x = BN.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
var pk = new Pubkey(); var pk = new Pubkey();
pk.fromX(true, x); pk.fromX(true, x);
pk.toBuffer().toString('hex').should.equal('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a'); pk.toBuffer().toString('hex').should.equal('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
@ -151,14 +151,14 @@ describe('Pubkey', function() {
describe('#toDER', function() { describe('#toDER', function() {
it('should return this compressed DER format', function() { it('should return this compressed DER format', function() {
var x = Bn.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex')); var x = BN.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
var pk = new Pubkey(); var pk = new Pubkey();
pk.fromX(true, x); pk.fromX(true, x);
pk.toDER(true).toString('hex').should.equal('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a'); pk.toDER(true).toString('hex').should.equal('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
}); });
it('should return this uncompressed DER format', function() { it('should return this uncompressed DER format', function() {
var x = Bn.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex')); var x = BN.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
var pk = new Pubkey(); var pk = new Pubkey();
pk.fromX(true, x); pk.fromX(true, x);
pk.toDER(false).toString('hex').should.equal('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341'); pk.toDER(false).toString('hex').should.equal('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341');

2
test/signature.js

@ -2,7 +2,7 @@
var should = require('chai').should(); var should = require('chai').should();
var bitcore = require('..'); var bitcore = require('..');
var BN = bitcore.BN; var BN = bitcore.crypto.BN;
var Signature = bitcore.Signature; var Signature = bitcore.Signature;
describe('Signature', function() { describe('Signature', function() {

4
test/transaction.js

@ -2,11 +2,11 @@
var should = require('chai').should(); var should = require('chai').should();
var bitcore = require('..'); var bitcore = require('..');
var Varint = bitcore.Varint; var Varint = bitcore.encoding.Varint;
var BufferReader = bitcore.encoding.BufferReader;
var Transaction = bitcore.Transaction; var Transaction = bitcore.Transaction;
var Txin = bitcore.Txin; var Txin = bitcore.Txin;
var Txout = bitcore.Txout; var Txout = bitcore.Txout;
var BufferReader = bitcore.BufferReader;
describe('Transaction', function() { describe('Transaction', function() {

4
test/txin.js

@ -2,10 +2,10 @@
var should = require('chai').should(); var should = require('chai').should();
var bitcore = require('..'); var bitcore = require('..');
var Varint = bitcore.encoding.Varint;
var BufferReader = bitcore.encoding.BufferReader;
var Script = bitcore.Script; var Script = bitcore.Script;
var Txin = bitcore.Txin; var Txin = bitcore.Txin;
var Varint = bitcore.Varint;
var BufferReader = bitcore.BufferReader;
describe('Txin', function() { describe('Txin', function() {

6
test/txout.js

@ -2,11 +2,11 @@
var should = require('chai').should(); var should = require('chai').should();
var bitcore = require('..'); var bitcore = require('..');
var BN = bitcore.BN; var BN = bitcore.crypto.BN;
var Varint = bitcore.encoding.Varint;
var BufferReader = bitcore.encoding.BufferReader;
var Txout = bitcore.Txout; var Txout = bitcore.Txout;
var Script = bitcore.Script; var Script = bitcore.Script;
var Varint = bitcore.Varint;
var BufferReader = bitcore.BufferReader;
describe('Txout', function() { describe('Txout', function() {

Loading…
Cancel
Save