1

I have two smart contracts, say Admin and Subject. For this purpose lets assume that ten unique accounts have deployed 10 such Admin contracts. One Subject contract has been deployed which has a function that can be called only by an authorized admin. This function allows the admin to add some data (which is encrypted). Now the admin who added this data is the only one who can decrypt it. Since the mapping is public, anyone can see which address added that data to the Subject contract. I am trying to find a way to abstract this so that no one can know for sure, which of the admins own what data.

Admin Contract is

/**
 * Represents each organization. Governs their CRUD access
 * Helps in mapping the type of identities on the system
 * Some more functionalities needed ??
*/
pragma solidity ^0.4.0;
contract Admin {
  bool public contractStatus = false;
  address public owner;

  // Details
  struct AdminDetails {
      string name;
      string details;
      bool state;
      address addr;
      uint group;
  }

  // Contructor function. Called once upon initialization
  function Admin() {
    contractStatus = true;
    owner = msg.sender;
  }

  // CRUD => a-b-c-d
  // Hex values for permissions. Bytewise operations does in binary
  // Create - 2^3, Read - 2^2 , Update - 2^1, Delete - 2^0
  // Combination of permissions can be made by simply adding hex values
  function checkCreatePermission(bytes1 permVal) returns (bool permCheck) {
    return ((permVal & 0x08) == 0x08);
  }

  function isOwned(address ownerAddr) returns (bool _owned) {
    return (owner == ownerAddr);
  }
}

Subject contract is

pragma solidity ^0.4.0;
contract Subject {
    bool public contractStatus = false;
    address public adminAddress;
    mapping (address => Data) adminToDataMapping;

    struct Data {
      string name;
      string details;
    }

   modifier onlyIfActive() {
     if (contractStatus) throw;
     _;
   }

   modifier onlyByCreator(address addr){
      if (msg.sender != addr) throw;
      _;
  }

  function addData(string someName, string someDetails address adminAddr) onlyIfActive {
    Admin admin = Admin(adminAddr);
    if(admin.checkCreatePermission(someSpecialValues)  && admin.isOwner(msg.sender)) {
      adminToDataMapping[msg.sender].name = someName;
      adminToDataMapping[msg.sender].details = someDetails;
    } else() {
      throw;
    }
  }
}

As of now in Subject, the data is mapped to an address of the sender. I want to abstract this is a way that no one can figure out who the sender is but at the same provide a way to verify the owner of the data for the editData() function.

I have considered using ecrecover and some ways of using DSA but am completely stump on how to use it effectively. Need some help/ suggestions!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.