Optimization in computeProofChallengeScalar as input is already parsed

pull/947/head
David Núñez 2019-04-26 12:29:26 +02:00
parent 068d783cfc
commit de208c1db1
2 changed files with 6 additions and 8 deletions

View File

@ -63,7 +63,7 @@ library ReEncryptionValidator {
require(alicesAddress == _precomputed.alicesKeyAsAddress, "Bad KFrag signature");
// Compute proof's challenge scalar h, used in all ZKP verification equations
uint256 h = computeProofChallengeScalar(_capsuleBytes, _cFragBytes);
uint256 h = computeProofChallengeScalar(_capsule, _cFrag);
//////
// Verifying 1st equation: z*E == h*E_1 + E_2
@ -257,14 +257,10 @@ library ReEncryptionValidator {
}
function computeProofChallengeScalar(
bytes memory _capsuleBytes,
bytes memory _cFragBytes
UmbralDeserializer.Capsule memory _capsule,
UmbralDeserializer.CapsuleFrag memory _cFrag
) internal pure returns (uint256) {
// TODO: Optimize this since they have already been parsed by the caller
UmbralDeserializer.Capsule memory _capsule = _capsuleBytes.toCapsule();
UmbralDeserializer.CapsuleFrag memory _cFrag = _cFragBytes.toCapsuleFrag();
// Compute h = hash_to_bignum(e, e1, e2, v, v1, v2, u, u1, u2, metadata)
bytes memory hashInput = abi.encodePacked(
// Point E

View File

@ -185,7 +185,9 @@ contract ReEncryptionValidatorMock {
)
public pure returns (uint256)
{
return ReEncryptionValidator.computeProofChallengeScalar(_capsuleBytes, _cFragBytes);
UmbralDeserializer.Capsule memory _capsule = _capsuleBytes.toCapsule();
UmbralDeserializer.CapsuleFrag memory _cFrag = _cFragBytes.toCapsuleFrag();
return ReEncryptionValidator.computeProofChallengeScalar(_capsule, _cFrag);
}
function aliceAddress(