Skip to content

Commit

Permalink
Small cleanups to signandverify test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbelshe committed Jan 13, 2014
1 parent b16eb5d commit 682fe70
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/benchmark/signandverify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ var SignAndVerify = new BenchmarkSuite('SignAndVerify', [69930], [
]);


var private_key = new Bitcoin.ECKey();
var privateKey = new Bitcoin.ECKey();
var message = "this is the bitcoin transaction";
var sigHex;

function signMessage() {
var hash = Crypto.SHA256(Crypto.SHA256(message, {asBytes: true}), {asBytes: true});
var sig = private_key.sign(hash);
var sig = privateKey.sign(hash);
var obj = Bitcoin.ECDSA.parseSig(sig);
sigHex = Crypto.util.bytesToHex(integerToBytes(obj.r, 32))+Crypto.util.bytesToHex(integerToBytes(obj.s, 32));
}

function verifyMessage() {
var adr = private_key.getBitcoinAddress();
var pub = private_key.getPub();
var adr = privateKey.getBitcoinAddress().toString();
var sig = sigHex;

var hash = Crypto.SHA256(Crypto.SHA256(message, {asBytes: true}), {asBytes: true});

var sig = [27].concat(Crypto.util.hexToBytes(sig));
sig = [27].concat(Crypto.util.hexToBytes(sig));
sig = Bitcoin.ECDSA.parseSigCompact(sig);

var res = false;
Expand Down

0 comments on commit 682fe70

Please sign in to comment.