2 ms·
I have only studied Move by reading the whitepaper, but there's a gaping architectural hole that I found in five minutes: public withdraw_from_sender(amoun
by amluto 7y ago
I have only studied Move by reading the whitepaper, but there's a gaping architectural hole that I found in five minutes:
public withdraw_from_sender(amount:u64): Coin {
let transaction_sender_address: address = GetTxnSenderAddress();
...
}
Checking the global txn sender address is not a sound way to authorize a transaction in a smart contract language. Consider that a buggy or malicious function in a different smart contract could call withdraw(). Linear type theory might prevent the resulting stolen coins from being duplicated, but they're still stolen.
I don't know if there is a clean theoretically sound way to do this, but here's an idea based on linear types:
The main function in a transaction is given a Sender object as one of its arguments. The Sender has a method that generates an assertion (an object) that the transaction intends to perform a specific action, e.g. withdraw 10 coins of type A. The withdraw() function takes an assertion as a parameter and calls a method that consumes the assertion before withdrawing the coins.
- baby 7y agoThere's no other ways to get the sender address, this is a built-in.
- _nhynes 7y agoIt sounds like what you're describing is passing a capability to withdraw balance (which is implicitly captured in an erc20's internal state via `approve` [0]). Of course, cap handling is probably a bit unwieldy for a snippet in a whitepaper, so they're likely making the assumption of "don't call untrusted code." I don't see a construction for sender delegation, so at least it reduces the TCB to the immediate callee. [0] https://eips.ethereum.org/EIPS/eip-20 https://eips.ethereum.org/EIPS/eip-20