src/secp256k1.js
function ScalarMultiple(bytes, discrim) {
	var order = ec.curve.n;
	for (var i = 0; i <= 0xFFFFFFFF; i++) {
		// We hash the bytes to find a 256 bit number, looping until we are sure it
		// is less than the order of the curve.
		var hasher = new Sha512().add(bytes);
		// If the optional discriminator index was passed in, update the hash.
		if (discrim !== undefined) {
			hasher.addU32(discrim);
		}
		hasher.addU32(i);
		var key = hasher.first256BN();
		/* istanbul ignore next */
		if (key.cmpn(0) > 0 && key.cmp(order) < 0) {
			return key;
		}
	}

	/* istanbul ignore next */
	throw new Error('impossible space search)');
}
function ScalarMultiple(bytes, discrim) {
	var order = ec.curve.n;
	for (var i = 0; i <= 0xFFFFFFFF; i++) {
		// We hash the bytes to find a 256 bit number, looping until we are sure it
		// is less than the order of the curve.
		var hasher = new Sha512().add(bytes);
		// If the optional discriminator index was passed in, update the hash.
		if (discrim !== undefined) {
			hasher.addU32(discrim);
		}
		hasher.addU32(i);
		var key = hasher.first256BN();
		/* istanbul ignore next */
		if (key.cmpn(0) > 0 && key.cmp(order) < 0) {
			return key;
		}
	}

	/* istanbul ignore next */
	throw new Error('impossible space search)');
}
function ScalarMultiple ( bytes , discrim ) { var order = ec . curve . n ; for ( var i = 0 ; i <= 0xFFFFFFFF ; i ++ ) { // We hash the bytes to find a 256 bit number, looping until we are sure it // is less than the order of the curve. var hasher = new Sha512 ( ) . add ( bytes ) ; // If the optional discriminator index was passed in, update the hash. if ( discrim !== undefined ) { hasher . addU32 ( discrim ) ; } hasher . addU32 ( i ) ; var key = hasher . first256BN ( ) ; /* istanbul ignore next */ if ( key . cmpn ( 0 ) > 0 && key . cmp ( order ) < 0 ) { return key ; } } /* istanbul ignore next */ throw new Error ( 'impossible space search)' ) ; }
Scalar multiplication to find one 256 bit number
where it is less than the order of the curve.
@param bytes
@param discrim
@returns {*}
@constructor
Scalar multiplication to find one 256 bit number where it is less than the order of the curve .