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

4
test/block.js

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

2
test/blockheader.js

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

2
test/keypair.js

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

18
test/networks.js

@ -2,20 +2,20 @@
var should = require('chai').should();
var bitcore = require('..');
var networks = bitcore.networks;
var Networks = bitcore.Networks;
describe('networks', function() {
describe('Networks', function() {
it('should contain all networks', function() {
should.exist(networks.livenet);
should.exist(networks.testnet);
should.exist(networks.mainnet);
it('should contain all Networks', function() {
should.exist(Networks.livenet);
should.exist(Networks.testnet);
should.exist(Networks.mainnet);
});
describe('contain all constants for livenet and testnet', function() {
for (var key in networks.livenet) {
if (networks.livenet.hasOwnProperty(key)) {
for (var key in Networks.livenet) {
if (Networks.livenet.hasOwnProperty(key)) {
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 bitcore = require('..');
var BN = bitcore.crypto.BN;
var Point = bitcore.crypto.Point;
var Privkey = bitcore.Privkey;
var BN = bitcore.BN;
var Point = bitcore.Point;
describe('Privkey', function() {
var hex = '96c132224121b509b7d0a16245e957d9192609c5637c6228311287b1be21627a';

12
test/pubkey.js

@ -2,9 +2,9 @@
var should = require('chai').should();
var bitcore = require('..');
var Point = bitcore.crypto.Point;
var BN = bitcore.crypto.BN;
var Pubkey = bitcore.Pubkey;
var Point = bitcore.Point;
var Bn = bitcore.BN;
var Privkey = bitcore.Privkey;
describe('Pubkey', function() {
@ -128,7 +128,7 @@ describe('Pubkey', function() {
describe('#fromX', 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();
pk.fromX(true, x);
pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
@ -140,7 +140,7 @@ describe('Pubkey', function() {
describe('#toBuffer', 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();
pk.fromX(true, x);
pk.toBuffer().toString('hex').should.equal('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
@ -151,14 +151,14 @@ describe('Pubkey', function() {
describe('#toDER', 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();
pk.fromX(true, x);
pk.toDER(true).toString('hex').should.equal('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
});
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();
pk.fromX(true, x);
pk.toDER(false).toString('hex').should.equal('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341');

2
test/signature.js

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

4
test/transaction.js

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

4
test/txin.js

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

6
test/txout.js

@ -2,11 +2,11 @@
var should = require('chai').should();
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 Script = bitcore.Script;
var Varint = bitcore.Varint;
var BufferReader = bitcore.BufferReader;
describe('Txout', function() {

Loading…
Cancel
Save