<commit_before>var ECDSA = require('../lib/ecdsa');
var Hash = require('../lib/hash');
var Keypair = require('../lib/keypair');
var Privkey = require('../lib/privkey');
var Pubkey = require('../lib/pubkey');
var Signature = require('../lib/signature');
var BN = require('../lib/bn');
var point = require('../lib/point');
var should = require('chai').should();
var fixture = require('./fixtures/ecdsa');

describe("ECDSA", function() {

  describe('test fixtures', function() {

    fixture.valid.forEach(function(obj, i) {
      it('should validate valid fixture ' + i, function() {
        var ecdsa = ECDSA().set({
          keypair: Keypair().fromPrivkey(Privkey().fromBN(BN().fromBuffer(new Buffer(obj.d, 'hex')))),
          k: BN().fromBuffer(new Buffer(obj.k, 'hex')),
          hashbuf: Hash.sha256(new Buffer(obj.message)),
          sig: Signature().set({
            r: BN(obj.signature.r),
            s: BN(obj.signature.s),
            i: obj.i
          })
        });
        var ecdsa2 = ECDSA(ecdsa);
        ecdsa2.sign();
        ecdsa2.calci();
        ecdsa2.sig.toString().should.equal(ecdsa.sig.toString());
        ecdsa2.sig.i.should.equal(ecdsa.sig.i);
        ecdsa.verify().should.equal(true);
      });
    });
    
    fixture.invalid.recoverPubKey.forEach(function() {
    });

    fixture.invalid.verifyRaw.forEach(function() {
    });

  });

  it('should create a blank ecdsa', function() {
    var ecdsa = new ECDSA();
  });

  var ecdsa = new ECDSA();
  ecdsa.hashbuf = Hash.sha256(new Buffer('test data'));
  ecdsa.keypair = new Keypair();
  ecdsa.keypair.privkey = new Privkey({bn: BN().fromBuffer(new Buffer('fee0a1f7afebf9d2a5a80c0c98a31c709681cce195cbcd06342b517970c0be1e', 'hex'))});
  ecdsa.keypair.pubkey = new Pubkey({
    point: point(BN().fromBuffer(new Buffer('ac242d242d23be966085a2b2b893d989f824e06c9ad0395a8a52f055ba39abb2', 'hex')),
    BN().fromBuffer(new Buffer('4836ab292c105a711ed10fcfd30999c31ff7c02456147747e03e739ad527c380', 'hex')))
  });
<commit_msg>add TODOs to test the invalid fixtures<commit_after>var ECDSA = require('../lib/ecdsa');
var Hash = require('../lib/hash');
var Keypair = require('../lib/keypair');
var Privkey = require('../lib/privkey');
var Pubkey = require('../lib/pubkey');
var Signature = require('../lib/signature');
var BN = require('../lib/bn');
var point = require('../lib/point');
var should = require('chai').should();
var fixture = require('./fixtures/ecdsa');

describe("ECDSA", function() {

  describe('test fixtures', function() {

    fixture.valid.forEach(function(obj, i) {
      it('should validate valid fixture ' + i, function() {
        var ecdsa = ECDSA().set({
          keypair: Keypair().fromPrivkey(Privkey().fromBN(BN().fromBuffer(new Buffer(obj.d, 'hex')))),
          k: BN().fromBuffer(new Buffer(obj.k, 'hex')),
          hashbuf: Hash.sha256(new Buffer(obj.message)),
          sig: Signature().set({
            r: BN(obj.signature.r),
            s: BN(obj.signature.s),
            i: obj.i
          })
        });
        var ecdsa2 = ECDSA(ecdsa);
        ecdsa2.sign();
        ecdsa2.calci();
        ecdsa2.sig.toString().should.equal(ecdsa.sig.toString());
        ecdsa2.sig.i.should.equal(ecdsa.sig.i);
        ecdsa.verify().should.equal(true);
      });
    });
    
    fixture.invalid.recoverPubKey.forEach(function(obj, i) {
      //TODO: test recoverPubKey fixtures
    });

    fixture.invalid.verifyRaw.forEach(function(obj, i) {
      //TODO: test verifyRaw fixtures
    });

  });

  it('should create a blank ecdsa', function() {
    var ecdsa = new ECDSA();
  });

  var ecdsa = new ECDSA();
  ecdsa.hashbuf = Hash.sha256(new Buffer('test data'));
  ecdsa.keypair = new Keypair();
  ecdsa.keypair.privkey = new Privkey({bn: BN().fromBuffer(new Buffer('fee0a1f7afebf9d2a5a80c0c98a31c709681cce195cbcd06342b517970c0be1e', 'hex'))});
  ecdsa.keypair.pubkey = new Pubkey({
    point: point(BN().fromBuffer(new Buffer('ac242d242d23be966085a2b2b893d989f824e06c9ad0395a8a52f055ba39abb2', 'hex')),
    BN().fromBuffer(new Buffer('4836ab292c105a711ed10fcfd30999c31ff7c02456147747e03e739ad527c380', 'hex')))
  });

{'fraction_non_alphanumeric': 0.17870079690895918, 'fraction_numerical': 0.06375271673508814, 'mean_word_length': 3.3100936524453695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5165379', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1486, 'n_words': 240}