Пример #1
0
static 
int run(char * material, char * ip, uint count, OE oe, MiniMacs mm) {
  CArena mc = CArena_new(oe);
  MpcPeer mission_control = 0;
     
  mc->connect("87.104.238.146", 65000);
  mission_control = mc->get_peer(0);
  
  if (!mission_control) {
    oe->p("Failed connection to mission control. aborting.\n");
    return -1;
  }
 
  if (mm->get_id() == 0) {
    mm->invite(1,2020+count);
  } else {
    if (mm->connect(ip,2020+count) != 0) {
      return 0;
    }
  }

  {
    byte key[128] = {0};
    byte ptxt[128] = {0};
    mpc_aes(mm,ptxt, key,mission_control);
    CArena_destroy(&mc);
  }
  PrintMeasurements(oe);
  return 0;
}
Пример #2
0
static 
int run(char * material, char * ip, OE oe, MiniMacs mm) {
  uint no_players = mm->get_no_players();
  uint myid = mm->get_id();
  int id = 0;

  printf("number of players: %u\n",no_players);
  printf("I am: %u\n",myid);
  printf("Waiting for %u\n",no_players-(myid+1));

  if (myid < no_players-1) {
    mm->invite(no_players-(myid+1),2020+100*myid);
  }

  for(id = myid-1;id >= 0;--id) {
    printf("connecting to peer at %s:%u\n",ip,2020+100*id);
    mm->connect(ip,2020+100*id);
  }

  {
    byte key[128] = {0};
    byte ptxt[128] = {0};
    ull start = _nano_time();
    mpc_aes(mm,ptxt, key,0,0,0);
    printf("Total time %llu ns\n",_nano_time()-start);
  }

  return 0;
}
Пример #3
0
int main(int c, char **a) {

  OE oe = OperatingEnvironment_LinuxNew();
  init_polynomial();
  if (oe) {
    MR mr = 0;
    int i = 0;
    MiniMacs mm = setup_generic_minimacs(oe, a[1]);
    if (!mm) return -42;
    mm->get_id();
    mr = mm->connect("127.0.0.1",2020);

    mm->init_heap(6); 

    C(mm->secret_input(0,0,0));
    
    C(mm->open(0));

    C(mm->secret_input(0,1,Data_shallow("\001\001",1)));
    C(mm->secret_input(0,2,Data_shallow("\002\002",1)));
    for(i = 0; i < 256;++i) 
      C(mm->mul(3,2,1));
    C(mm->add(3,3,3));
    C(mm->open(3));
    
    oe->p(mm->heap_get(0)->codeword);
    _p("Mul res", mm->heap_get(3)->codeword,8,8);

  }

 failure:
  return 0;
}
Пример #4
0
static 
int run(char * ip, uint myid, uint count, OE oe, MiniMacs mm) {
  CArena mc = CArena_new(oe);
  MpcPeer mission_control = 0;
     
  if (mc->connect("87.104.238.146", 65000).rc != 0) {
    oe->syslog(OSAL_LOGLEVEL_FATAL,"Failed to connect to the performance monitor.");
    return -1;
  };
  mission_control = mc->get_peer(0);
  
  if (!mission_control) {
    oe->p("Failed connection to mission control. aborting.\n");
    return -1;
  }
 
  if (mm->get_id() == 0) {
    if (mm->invite(1,2020+myid) != 0) {
      byte d[256] = {0};
      char m[128] = {0};
      osal_sprintf(m,"Failed to invite %u peers on port %u",1,2020+myid);
      oe->p(m);
      i2b(myid, d);
      osal_sprintf(d+4,"error");
      mission_control->send(Data_shallow(d,128));
      return 0;
    }
  } else {
    if (mm->connect(ip,2020+myid) != 0) {
      char m[128] = {0};
      osal_sprintf(m,"Failed to connect to peer %s:%u",ip,2020+myid);
      oe->p(m);
      return 0;
    }
  }

  {
    byte key[128] = {0};
    byte ptxt[128] = {0};
    mpc_aes(mm,ptxt, key,myid,count,mission_control);
    CArena_destroy(&mc);
  }
  PrintMeasurements(oe);
  return 0;
}
Пример #5
0
/*
 * ] Connect to the monitor
 *
 * ] Listen for clients with ids greater than this client.
 *
 * ] Connect to clients with ids less than this client. (in this way
 *   client 1 connects to no one and listens for every one, vice verse
 *   client N connects to everyone and listens for no one.)
 * 
 * ] Execute mpc_aes with the connected peers
 *
 * ] Destroy the CArena connected to comm with the monitor and leave.
 */
static 
int run(char * ip, uint myid, uint count, OE oe, MiniMacs mm) {
  CArena mc = CArena_new(oe);
  MpcPeer mission_control = 0;

  // connect to monitor 
  if (mc->connect(bitlab, 65000).rc != 0) {
    oe->syslog(OSAL_LOGLEVEL_FATAL,"Failed to connect to the performance monitor.");
    return -1;
  };
  mission_control = mc->get_peer(0);
  
  if (!mission_control) {
    oe->p("Failed connection to mission control. aborting.\n");
    return -1;
  }
 
  // listen for all parties with id greater than mm->myid
  {
    byte msg[92] = {0};
    uint port = 2020+100*mm->get_id();
    uint wait4=mm->get_no_players()-(mm->get_id()+1);
    osal_sprintf(msg,"Waiting for %u players to connect.",wait4);
    oe->p(msg);
    if (wait4 > 0) {
      if (mm->invite(wait4,port) != 0) {
        byte d[256] = {0};
        char m[128] = {0};
        osal_sprintf(m,"Failed to invite %u peers on port %u",wait4,2020+myid);
        oe->syslog(OSAL_LOGLEVEL_FATAL,m);
        i2b(myid, d);
        osal_sprintf(d+4,"error");
        mission_control->send(Data_shallow(d,128));
        return 0;
      };
    }
  }

  // connect to all parties with id less than mm->myid
  {
    int id = 0;
    for(id = mm->get_id()-1;id >= 0;--id) {
      byte address[16] = {0};
      byte msg[92] = {0};
      uint port = 2020+100*id;
      osal_sprintf(msg,"connecting to %u ...",port);
      oe->p(msg);
      osal_sprintf(address,"10.11.82.%d",id+1);
      if (mm->connect(address,port) != 0) {
        byte d[256] = {0};
        char m[128] = {0};
        osal_sprintf(m,"Failed to connect to %s peers on port %u",address,port);
        oe->syslog(OSAL_LOGLEVEL_FATAL,m);
        i2b(myid, d);
        osal_sprintf(d+4,"error");
        mission_control->send(Data_shallow(d,128));
        return 0;
      }
    }
  }

  // invoke AES circuit with zero plaintext and zero key
  {
    byte key[128] = {0};
    byte ptxt[128] = {0};
    mpc_aes(mm,ptxt, key,myid,count,mission_control);
    CArena_destroy(&mc);
  }

  // print time measurements if compiled in
  PrintMeasurements(oe);
  return 0;
}