<commit_before>/*jslint node: true */
"use strict";
var ecdsa = require('secp256k1');

exports.sign = function(hash, priv_key){
	var res = ecdsa.sign(hash, priv_key);
	return res.signature.toString("base64");
};

exports.verify = function(hash, b64_sig, b64_pub_key){
	var signature = new Buffer(b64_sig, "base64"); // 64 bytes (32+32)
	return ecdsa.verify(hash, signature, new Buffer(b64_pub_key, "base64"));
};

<commit_msg>safer signature checking<commit_after>/*jslint node: true */
"use strict";
var ecdsa = require('secp256k1');

exports.sign = function(hash, priv_key){
	var res = ecdsa.sign(hash, priv_key);
	return res.signature.toString("base64");
};

exports.verify = function(hash, b64_sig, b64_pub_key){
	try{
		var signature = new Buffer(b64_sig, "base64"); // 64 bytes (32+32)
		return ecdsa.verify(hash, signature, new Buffer(b64_pub_key, "base64"));
	}
	catch(e){
		console.log('signature verification exception: '+e.toString());
		return false;
	}
};


{'fraction_non_alphanumeric': 0.16288659793814433, 'fraction_numerical': 0.049484536082474224, 'mean_word_length': 5.605442176870748, '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': '1010341', 'n_tokens_mistral': 387, 'n_tokens_neox': 354, 'n_words': 80}