The AZTEC Crypto Engine lets you validate proofs and cache them for future re-use, since they are fairly expensive (around 800,000 gas for a 4-note join-split proof before Istanbul, and now about 200,000 gas). This question refers to aztec.js 0.9.1.
The proofs contain a signer
, the address of the owner of the notes to operate on, and a sender
or validator
, the address of the (possibly a contract) sender of the proofs to ACE.
When you validate the proofs and cache them, you provide one address, which is called the sender
This is a mutator method and I would expect an EVM revert if it fails.
When you want to read from the cache, you also provide an address called sender
, which I expect to be the same as sender
used in the call above to write to the cache, and the proofHash
:
My question is: do the calls to either or both of ace.validateProof
and ace.validateProofByHash
have to come from the same address as the sender
address parameter?
To test this, I first make a call from Javascript that relays a call to ace.validateProof
via a contract called TradeValidator
const sellerValidation = await result.minedTx(
result.validator.validateAndGetFirstProofOutput,
[result.seller.jsProofData, result.validator.address] )
The Solidity code of the method validateAndGetFirstProofOutput
is
function validateAndGetFirstProofOutput(
bytes memory _proofData,
address _proofSender
) public returns (bytes memory, bytes32) {
bytes memory formattedProofOutput = ace.validateProof(JOIN_SPLIT_PROOF, _proofSender, _proofData).get(0);
lastProofOutput = formattedProofOutput;
lastProofHash = keccak256(formattedProofOutput);
return (lastProofOutput, lastProofHash);
}
I've verified that the proofHash
is what I expect from Javascript, and then I also tried to verify that this proof is cached by calling from Javascript
const validateResult2 = await result.ace.validateProofByHash(
JOIN_SPLIT_PROOF, result.seller.jsProofHash, result.validator.address,
)
assert( Boolean(validateResult2['0']),
'seller proof hash is not associated with transferer/sender, when sent from Javascript user'
)
My expectation is that ace.validateProofByHash
would succeed if proofHash
matches JOIN_SPLIT_PROOF
type and sender
address, when called from anywhere, whether it's a Solidity contract, a Node command-line user, or webpacked JS code in a browser. However, this second call is currently failing.
Two ways I can test this:
- Does
ace.validateProof
revert if thesender
parameter is incorrect, or if it comes from a different sender? - Can I make a Solidity method in the validator contract that also calls
ace.validateProofByHash
, but coming from the samesender
address as the parameter?
validateProof
andvalidateProofByHash
must come from the sender (whether it's a user address called from Javascript, or a Solidity contract)