const babyJub = require("./babyjub"); const createBlakeHash = require("blake-hash"); const blake2b = require("blake2b"); const Scalar = require("ffjavascript").Scalar; const GENPOINT_PREFIX = "PedersenGenerator"; const windowSize = 4; const nWindowsPerSegment = 50; exports.hash = pedersenHash; exports.getBasePoint = getBasePoint; function baseHash(type, S) { if (type == "blake") { return createBlakeHash("blake256").update(S).digest(); } else if (type == "blake2b") { return Buffer.from(blake2b(32).update(Buffer.from(S)).digest()); } } function pedersenHash(msg, options) { options = options || {}; options.baseHash = options.baseHash || "blake"; const bitsPerSegment = windowSize*nWindowsPerSegment; const bits = buffer2bits(msg); const nSegments = Math.floor((bits.length - 1)/(windowSize*nWindowsPerSegment)) +1; let accP = [babyJub.F.zero,babyJub.F.one]; for (let s=0; s