diff --git a/contracts/ZSLPrecompile.sol b/contracts/ZSLPrecompile.sol index d9e91da..a38075e 100644 --- a/contracts/ZSLPrecompile.sol +++ b/contracts/ZSLPrecompile.sol @@ -24,10 +24,17 @@ contract ZSLPrecompileSHA256Compress { /** @title Abstract contract for built-in function */ -contract ZSLPrecompileVerify { +contract ZSLPrecompileVerifyShielding { function run(bytes, bytes32, bytes32, uint64) constant returns (bytes32); } +/** + @title Abstract contract for built-in function + */ +contract ZSLPrecompileVerifyUnshielding { + function run(bytes, bytes32, bytes32, address, uint64) constant returns (bytes32); +} + /** @title Abstract contract for built-in function */ @@ -42,15 +49,15 @@ contract ZSLPrecompile { ZSLPrecompileSHA256Compress private compressContract; ZSLPrecompileVerifyTransfer private verifyShieldedTransferContract; - ZSLPrecompileVerify private verifyShieldingContract; - ZSLPrecompileVerify private verifyUnshieldingContract; + ZSLPrecompileVerifyShielding private verifyShieldingContract; + ZSLPrecompileVerifyUnshielding private verifyUnshieldingContract; // @dev Address of precompiles must match those in the Geth/Quorum client function ZSLPrecompile() { compressContract = ZSLPrecompileSHA256Compress(0x0000000000000000000000000000000000008801); verifyShieldedTransferContract = ZSLPrecompileVerifyTransfer(0x0000000000000000000000000000000000008802); - verifyShieldingContract = ZSLPrecompileVerify(0x0000000000000000000000000000000000008803); - verifyUnshieldingContract = ZSLPrecompileVerify(0x0000000000000000000000000000000000008804); + verifyShieldingContract = ZSLPrecompileVerifyShielding(0x0000000000000000000000000000000000008803); + verifyUnshieldingContract = ZSLPrecompileVerifyUnshielding(0x0000000000000000000000000000000000008804); } // @param input Input data block must be 64 bytes (512 bits) in length @@ -98,8 +105,8 @@ contract ZSLPrecompile { // @param input The ZK Proof to verify - function verifyUnshielding(bytes proof, bytes32 spend_nf, bytes32 rt, uint64 value) constant external returns (bool) { - bytes32 buffer = verifyUnshieldingContract.run(proof, spend_nf, rt, value); + function verifyUnshielding(bytes proof, bytes32 spend_nf, bytes32 rt, address addr, uint64 value) constant external returns (bool) { + bytes32 buffer = verifyUnshieldingContract.run(proof, spend_nf, rt, addr, value); byte b = buffer[0]; if (b == 0x00) { return false; diff --git a/contracts/ZTokenExample.sol b/contracts/ZTokenExample.sol index 62eba09..b0da585 100644 --- a/contracts/ZTokenExample.sol +++ b/contracts/ZTokenExample.sol @@ -155,7 +155,7 @@ contract ZToken is owned, SafeMath, ZSLMerkleTree { function unshield(bytes proof, bytes32 spend_nf, bytes32 cm, bytes32 rt, uint64 value) public { require(mapNullifiers[spend_nf] == 0); // check if nullifier has been used before require(commitmentExists(cm)); - assert(zsl.verifyUnshielding(proof, spend_nf, rt, value)); // verfy proof + assert(zsl.verifyUnshielding(proof, spend_nf, rt, msg.sender, value)); // verfy proof mapNullifiers[spend_nf] = 1; balanceOf[msg.sender] = safeAdd(balanceOf[msg.sender], value); // check for overflow LogUnshielding(msg.sender, value, sha3(cm));