nl_tokens: @arg { String|Buffer } dataSha256 - sha256 hash 32 byte buffer or hex string @arg { String } [ encoding = hex ] - dataSha256 encoding ( if string )
pl_tokens: function recoverHash ( dataSha256 , encoding = "hex" ) { //let time = new Date().valueOf(); if ( typeof dataSha256 === "string" ) { dataSha256 = Buffer . from ( dataSha256 , encoding ) ; } if ( dataSha256 . length !== 32 || ! Buffer . isBuffer ( dataSha256 ) ) { throw new <mask> ( "dataSha256: 32 byte String or buffer requred" ) ; } // sign the message if ( secp256k1 != null ) { let buffer = toBuffer ( ) ; //console.log("[recoverHash] accelerating supported, length of sign: " + buffer.length); var ret = PublicKey . fromBuffer ( secp256k1 . recover ( dataSha256 , buffer . slice ( 1 ) , buffer [ 0 ] - 4 - 27 , true ) ) ; //time = (new Date().valueOf()) - time; //console.log("[+" + time + "ms] recoverHash (c binding)"); return ret ; } else { //console.log("[recoverHash] accelerating not supported"); const e = BigInteger . fromBuffer ( dataSha256 ) ; let i2 = i ; i2 -= 27 ; i2 = i2 & 3 ; const Q = ecdsa . recoverPubKey ( curve , e , { r , s , i } , i2 ) ; // time = (new Date().valueOf()) - time; //console.log("[+" + time + "ms] recoverHash"); return PublicKey . fromPoint ( Q ) ; } }