Account guardians, EIP1271, and recursive proofs

I really like the idea around recursive ZKP’s with the account contracts, as it also will allow us to have something like depositing funds into defi contracts from the private domain WITHOUT needing approvals :eyes:.

Recall that funds can be spend if you can generate a valid proof and only someone having knowledge of the notes and being able to satisfy the account contract can make such a proof.
This means that a transferFrom function could practically take from, to, amount, proof and do a staticcall to from to see if the proof is valid for a transfer(to, amount) function call. If it is, do the transfer, and go back to the execution you were in the middle of otherwise the entire thing reverts.

If an oracle is used to generate the proof, dapps could look quite similar to what people expect of solidity dapps, but without needing to deal with lingering approvals :tada:

// Private function to deposit into X
fn deposit(asset: Address, amount: u120) -> ... {
  // Perform input validation 

  // Encoded function signature and args
  let transfer_call = ...;
  
  // Oracle call to get a proof.
  // The oracle could either generate or pass it on
  let proof = oracle.get_proof(asset, transfer_call);
  
  // Transfer the assets into this contract
  Token::at(asset).transferFrom(
    context.message_sender(), 
    context.this_address(),
    amount,
    proof
  );

  // Some accounting logic in this contract. 
  // The actual defi stuff.
}
89 Likes