Task 4, is the first time that requires interaction with the blockchain.
[references for interacting with smart contracts]
We are tasked with determining all the victims for an Escrow contract and which ones have actually paid the ransom. There are multiple methods for determining this information, depending on if we want to analyze the Escrow or Register contracts and look at the contract storage or events generated by the contracts.
Below are the variables tracked by the Escrow contract:
address owner; //!< This is the account that deployed the Escrow contract uint ownerBalance; //!< This is the account balance of the owner (i.e., fulfilled ransoms) address registry; //!< This is the address of the Registry contract mapping(uint => address) vicToPayerMap; //!< Mapping from victim IDs to the account addresses that submitted payment mapping(uint => Victim) victimMap; //!< Mapping from victim IDs to Victim structs mapping(uint => bytes32) decKeyMap; //!< Mapping from victim IDS to decrypted ransom keys mapping(address => uint) ransomMap; //!< Mapping from Ransom contract addresses to victim IDs mapping(uint => uint) escrowMap; //!< Mapping from victim IDs to the amount of ransom payment received mapping(uint => string) encFileMap; //!< Mapping from victim IDs to encrypted test files address ransomContracts; //!< List of Ransom contracts registered with this Escrow contract address oracleAccount; //!< Address of the off-chain authentication and decryption Oracle
A contracts storage can be examined using python Web3’s function <>.
Code to get all contracts registered with Escrow
After we have the list of contracts, they can be checked to determine which victims have paid the ransom.
This can be done by ransomContract->ransomMap->(decKeyMap or vicToPayerMap)
or we can check Events using
Victims that have not paid:
Victims that have paid: