function deterministicGenerateK(hash, key, algorithm, length) {	
	var v = new Uint8Array(length),
		k = new Uint8Array(length);

	v.fill(1);
	k.fill(0);
	
	var hmac = createHmac(algorithm, k);
	hmac.update(v);
	hmac.update(new Uint8Array([0]));
	hmac.update(key);
	hmac.update(hash);
	k = hmac.digest();
	
	hmac = createHmac(algorithm, k);
	hmac.update(v);
	v = hmac.digest();
	
	hmac = createHmac(algorithm, k);
	hmac.update(v);
	hmac.update(new Uint8Array([1]));
	hmac.update(key);
	hmac.update(hash);
	k = hmac.digest();
	
	hmac = createHmac(algorithm, k);
	hmac.update(v);
	v = hmac.digest();
	
	hmac = createHmac(algorithm, k);
	hmac.update(v);
	v = hmac.digest();
	
	return new BigInteger(v.toString('hex'), 16);
}
// generate K value based on RFC6979
generate K value based on RFC6979
generate K value based on RFC6979
function deterministicGenerateK(hash, key, algorithm, length) {	
	var v = new Uint8Array(length),
		k = new Uint8Array(length);
	v.fill(1);
	k.fill(0);
	var hmac = createHmac(algorithm, k);
	hmac.update(v);
	hmac.update(new Uint8Array([0]));
	hmac.update(key);
	hmac.update(hash);
	k = hmac.digest();
	hmac = createHmac(algorithm, k);
	hmac.update(v);
	v = hmac.digest();
	hmac = createHmac(algorithm, k);
	hmac.update(v);
	hmac.update(new Uint8Array([1]));
	hmac.update(key);
	hmac.update(hash);
	k = hmac.digest();
	hmac = createHmac(algorithm, k);
	hmac.update(v);
	v = hmac.digest();
	hmac = createHmac(algorithm, k);
	hmac.update(v);
	v = hmac.digest();
	return new BigInteger(v.toString('hex'), 16);
}
function deterministicGenerateK ( hash , key , algorithm , length ) { var v = new Uint8Array ( length ) , k = new Uint8Array ( length ) ; v . fill ( 1 ) ; k . fill ( 0 ) ; var hmac = createHmac ( algorithm , k ) ; hmac . update ( v ) ; hmac . update ( new Uint8Array ( [ 0 ] ) ) ; hmac . update ( key ) ; hmac . update ( hash ) ; k = hmac . digest ( ) ; hmac = createHmac ( algorithm , k ) ; hmac . update ( v ) ; v = hmac . digest ( ) ; hmac = createHmac ( algorithm , k ) ; hmac . update ( v ) ; hmac . update ( new Uint8Array ( [ 1 ] ) ) ; hmac . update ( key ) ; hmac . update ( hash ) ; k = hmac . digest ( ) ; hmac = createHmac ( algorithm , k ) ; hmac . update ( v ) ; v = hmac . digest ( ) ; hmac = createHmac ( algorithm , k ) ; hmac . update ( v ) ; v = hmac . digest ( ) ; return new BigInteger ( v . toString ( 'hex' ) , 16 ) ; }
generate K value based on RFC6979
generate K value based on RFC6979