Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/no checksig in start tx exit #8

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Sidechain functionality (plasma user and operator) is written in Javascript.
This implementation of plasma cash is a bit different from general specification/guidelines.
Main differences:
- it treats each deposit as individual tree/chain.
- exits are stored in matrix, where keys are `depositNonce` and `childBlockIndex`
- exits are stored in matrix, where keys are `depositId` and `blockIndex`
so each exit has its own place.
- every deposit has its own exit queue
- priority is not based on exit time, but based on block index
Expand Down
16 changes: 9 additions & 7 deletions contracts/PlasmaCash.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ contract PlasmaCash is Withdrawable, Operable {
payable {

Transaction.TX memory transaction = Transaction.createTransaction(_txBytes);
validateProofSignaturesAndTxData(_txBytes, _proof, _signature, _spender, _targetBlock);
validateProofSignaturesAndTxData(transaction, _proof, _signature, _spender, _targetBlock, false);

require(exits[transaction.depositId][_targetBlock].finalAt == 0, "exit already exists");

Expand Down Expand Up @@ -171,7 +171,7 @@ contract PlasmaCash is Withdrawable, Operable {
// we will allow users to challenge exit even after challenge time, until someone finalize it
// allow: require(exit.finalAt > block.timestamp, "exit is final, you can't challenge it");

validateProofSignaturesAndTxData(_txBytes, _proof, _signature, exitPtr.exitor, _targetBlock);
validateProofSignaturesAndTxData(transaction, _proof, _signature, exitPtr.exitor, _targetBlock, true);

exitPtr.invalid = true;

Expand All @@ -181,19 +181,21 @@ contract PlasmaCash is Withdrawable, Operable {
}


function validateProofSignaturesAndTxData(bytes _txBytes, bytes _proof, bytes _signature, address _signer, uint256 _targetBlock)
public
function validateProofSignaturesAndTxData(Transaction.TX memory transaction, bytes _proof, bytes _signature, address _signer, uint256 _targetBlock, bool checkSig)
private
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with public, we allow any user to validate on-chain... any reason why you want this to be private?

view
returns (bool) {
Transaction.TX memory transaction = Transaction.createTransaction(_txBytes);
require(transaction.prevTxBlockIndex < chainBlockIndex, "blockchain is the future, but your tx must be from the past");
require(_targetBlock > transaction.prevTxBlockIndex, "invalid targetBlock/prevTxBlockIndex");

bytes32 hash = Transaction.hashTransaction(transaction);

require(transaction.newOwner != _signer, "preventing sending loop");
require(_proof.verifyProof(blocks[_targetBlock].merkleRoot, hash, transaction.depositId), "MerkleProof.verifyProof() failed");
require(Transaction.checkSig(_signer, hash, _signature), "Transaction.checkSig() failed");

if (checkSig) {
require(transaction.newOwner != _signer, "preventing sending loop");
require(Transaction.checkSig(_signer, hash, _signature), "Transaction.checkSig() failed");
}

return true;
}
Expand Down