mirror of
https://github.com/tornadocash/tornado-nova
synced 2024-02-02 14:53:56 +01:00
cache currentCommitmentIndex
This commit is contained in:
parent
75419e5cff
commit
476668d250
@ -79,10 +79,12 @@ contract TornadoPool {
|
|||||||
require(!isSpent(_args.inputNullifiers[i]), "Input is already spent");
|
require(!isSpent(_args.inputNullifiers[i]), "Input is already spent");
|
||||||
}
|
}
|
||||||
require(uint256(_args.extDataHash) == uint256(keccak256(abi.encode(_extData))) % FIELD_SIZE, "Incorrect external data hash");
|
require(uint256(_args.extDataHash) == uint256(keccak256(abi.encode(_extData))) % FIELD_SIZE, "Incorrect external data hash");
|
||||||
require(_args.outPathIndices == currentCommitmentIndex >> 1, "Invalid merkle tree insert position");
|
uint256 cachedCommitmentIndex = currentCommitmentIndex;
|
||||||
|
require(_args.outPathIndices == cachedCommitmentIndex >> 1, "Invalid merkle tree insert position");
|
||||||
require(verifyProof(_args), "Invalid transaction proof");
|
require(verifyProof(_args), "Invalid transaction proof");
|
||||||
|
|
||||||
currentRoot = _args.newRoot;
|
currentRoot = _args.newRoot;
|
||||||
|
currentCommitmentIndex = cachedCommitmentIndex + 2;
|
||||||
for (uint256 i = 0; i < _args.inputNullifiers.length; i++) {
|
for (uint256 i = 0; i < _args.inputNullifiers.length; i++) {
|
||||||
nullifierHashes[_args.inputNullifiers[i]] = true;
|
nullifierHashes[_args.inputNullifiers[i]] = true;
|
||||||
}
|
}
|
||||||
@ -102,8 +104,8 @@ contract TornadoPool {
|
|||||||
_extData.relayer.transfer(_args.fee);
|
_extData.relayer.transfer(_args.fee);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit NewCommitment(_args.outputCommitments[0], currentCommitmentIndex++, _extData.encryptedOutput1);
|
emit NewCommitment(_args.outputCommitments[0], cachedCommitmentIndex, _extData.encryptedOutput1);
|
||||||
emit NewCommitment(_args.outputCommitments[1], currentCommitmentIndex++, _extData.encryptedOutput2);
|
emit NewCommitment(_args.outputCommitments[1], cachedCommitmentIndex + 1, _extData.encryptedOutput2);
|
||||||
for (uint256 i = 0; i < _args.inputNullifiers.length; i++) {
|
for (uint256 i = 0; i < _args.inputNullifiers.length; i++) {
|
||||||
emit NewNullifier(_args.inputNullifiers[i]);
|
emit NewNullifier(_args.inputNullifiers[i]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user