Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var bsRight = bs.slice(nPrime);
var gLeft = base.getGs().slice(0, nPrime);
var gRight = base.getGs().slice(nPrime);
var hLeft = base.getHs().slice(0, nPrime);
var hRight = base.getHs().slice(nPrime);
var cL = asLeft.innerProduct(bsRight);
var cR = asRight.innerProduct(bsLeft);
var u = base.getH();
var L = gRight.commit(asLeft).add(hLeft.commit(bsRight)).add(u.mul(cL));
var R = gLeft.commit(asRight).add(hRight.commit(bsLeft)).add(u.mul(cR));
ls.push(L);
rs.push(R);
var x = utils.hash(ABICoder.encodeParameters(['bytes32', 'bytes32[2]', 'bytes32[2]'], [bn128.bytes(previousChallenge), bn128.serialize(L), bn128.serialize(R)]));
var xInv = x.redInvm();
var gPrime = gLeft.times(xInv).add(gRight.times(x));
var hPrime = hLeft.times(x).add(hRight.times(xInv));
var aPrime = asLeft.times(x).add(asRight.times(xInv));
var bPrime = bsLeft.times(xInv).add(bsRight.times(x));
var PPrime = L.mul(x.redMul(x)).add(R.mul(xInv.redMul(xInv))).add(P);
var basePrime = new GeneratorParams(u, gPrime, hPrime);
return generateProof(basePrime, PPrime, aPrime, bPrime, ls, rs, x);
};
function encodeConstructorCall(bytecode, def, args=[]) {
return util.addHexPrefix(bytecode) +
util.stripHexPrefix(abiEncoder.encodeParameters(
def.inputs,
normalizeEncodeInput(def.inputs, args),
));
}
constructOutputs() {
const proofOutput = {
inputNotes: this.inputNotes,
outputNotes: this.outputNotes,
publicValue: this.publicValue,
publicOwner: this.publicOwner,
challenge: this.challengeHex,
};
this.output = outputCoder.encodeProofOutput(proofOutput);
this.outputs = outputCoder.encodeProofOutputs([proofOutput]);
this.hash = outputCoder.hashProofOutput(this.output);
this.validatedProofHash = keccak256(
AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.PUBLIC_RANGE_PROOF, this.sender]),
);
}
constructOutputs() {
const proofOutput = {
inputNotes: this.inputNotes,
outputNotes: this.outputNotes,
publicValue: this.publicValue,
publicOwner: this.publicOwner,
challenge: this.challengeHex,
};
this.output = outputCoder.encodeProofOutput(proofOutput);
this.outputs = outputCoder.encodeProofOutputs([proofOutput]);
this.hash = outputCoder.hashProofOutput(this.output);
this.validatedProofHash = keccak256(
AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.JOIN_SPLIT_PROOF, this.sender]),
);
}
encTypes.push('bytes32');
value = Web3Utils.keccak256(value);
encValues.push(value);
} else if (types[field.type] !== undefined) {
encTypes.push('bytes32');
value = Web3Utils.keccak256(oThis.encodeData(field.type, value));
encValues.push(value);
} else if (field.type.lastIndexOf(']') === field.type.length - 1) {
throw 'Arrays currently unimplemented in encodeData';
} else {
encTypes.push(field.type);
encValues.push(value);
}
}
return Web3Abi.encodeParameters(encTypes, encValues);
}
function encodeConstructorArgs(types, args) {
return abi.encodeParameters(types, args).substring(2);
}
this.encodeFunctionParams = function(abi,methodName, params){
var types = this.getFunctionParams(abi,methodName);
var fullName = methodName + '(' + types.join() + ')';
var signature = CryptoJS.SHA3(fullName,{outputLength:256}).toString(CryptoJS.enc.Hex).slice(0, 8);
var dataHex = signature + Web3EthAbi.encodeParameters(...types, params).substring(2);
var payload = '0x'+dataHex;
return payload;
}
outputNotes: [this.outputNotes[0]],
publicValue: this.publicValue,
publicOwner: this.publicOwner,
challenge: this.challengeHex,
},
{
inputNotes: [this.outputNotes[1]],
outputNotes: [this.inputNotes[1]],
publicValue: this.publicValue,
publicOwner: this.publicOwner,
challenge: `0x${keccak256(this.challengeHex).slice(2)}`,
},
]);
this.hash = outputCoder.hashProofOutput(this.outputs);
this.validatedProofHash = keccak256(
AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.SWAP_PROOF, this.sender]),
);
}
outputNotes: [this.outputNotes[0]],
publicValue: this.publicValue,
publicOwner: this.publicOwner,
challenge: this.challengeHex,
},
{
inputNotes: [this.outputNotes[1]],
outputNotes: [this.inputNotes[1]],
publicValue: this.publicValue,
publicOwner: this.publicOwner,
challenge: `0x${keccak256(this.challengeHex).slice(2)}`,
},
]);
this.hash = outputCoder.hashProofOutput(this.outputs);
this.validatedProofHash = keccak256(
AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.SWAP_PROOF, this.sender]),
);
}