public static function create() { $status = false; $net = new Gnet(); if (GsonCrypt::cryptoInstalled()) { if (!self::isCreated()) { GsonCrypt::keygen(config::$accountId); } $cert = GsonCrypt::getcert(); $csr = gio::readrawfile($cert); $m = Gmsg::create(Gmsg::prepare($csr, "signcert", config::$SRA)); $m = GsonCrypt::seal($m, config::$SRA); $r = $net->send($m, true); $r = GsonCrypt::unseal($r); $r = Gmsg::extract($r); if ($r['status']) { $data = $r['response']; if ($r['status'] == 1 && $data) { gio::saverawfile($data, $cert); gio::savetofile($data, GsonCrypt::getkey()); gio::output(sprintf("The account '%s' was created succesfully")); $status = true; } else { gio::output($r['response']); } } else { unlink(GsonCrypt::getkey(null, true)); gio::output($r['response']); } } else { gio::output("Kindly install the cryptographic library tools."); } $net = null; return $status; }
public static function getcert($userid = "", $data = false) { if (empty($userid)) { $userid = config::$accountId; } gio::log("Getting certificate for {$userid} ...", VERBOSE); $cfile = Tools::makepath(array(HOME_DIR, "keys", "certificate", "{$userid}.crt")); $ret = $data ? gio::readrawfile($cfile) : $cfile; gio::log("Done getting certificate for {$userid} ...", VERBOSE); return $ret; }
public static function create() { $status = false; $net = new Gnet(); if (GsonCrypt::cryptoInstalled()) { if (!self::isRegistered()) { if (!self::register()) { gio::output("Account Creation Failed! Bank Registration Not Successful"); return false; } } if (!self::isCreated()) { if (!GsonCrypt::keygen(config::$accountId)) { gio::output(); gio::output("Account Creation Failed! You may have entered some parameters wrongly"); self::rollback(); self::deregister(); return false; } } else { gio::output("Account is already created"); return false; } $cert = GsonCrypt::getcert(); $csr = gio::readrawfile($cert); $m = Gmsg::create(Gmsg::prepare($csr, "signcert", config::$SRA)); $m = GsonCrypt::seal($m, config::$SRA); $bm = Gmsg::create(Gmsg::prepare($m, "signcert", config::$bankId)); $r = $net->send($bm); if (!$r) { gio::output(); gio::output("Account Creation Failed! Unable to connect to account creation server"); } else { $s = GsonCrypt::unseal($r); $r = $s ? Gmsg::extract($s) : Gmsg::extract($r); if (!$r) { gio::output(); gio::output("Account Creation Failed! Unable to read the response"); self::rollback(); self::deregister(); return false; } $r = Gmsg::extract($r); } if ($r && $r['status']) { $data = $r['response']; if ($r['status'] == 1 && $data) { $st = Gmsg::extract($net->send(Gmsg::create(Gmsg::prepare($data, "create", config::$bankId)), config::$bankId)); if (!$st || !$st['status']) { gio::output("Account Creation Failed! Account creation rejected by bank"); self::rollback(); self::deregister(); return false; } gio::saverawfile($data, $cert); config::$accountId = gio::readfile(config::$accountIdFile); config::$bankId = gio::readfile(config::$bankIdFile); gio::output("Your account was created succesfully"); gio::output(sprintf("Your account address is '%s'", self::address())); $status = true; } else { gio::output($r['response']); } } else { self::rollback(); self::deregister(); gio::output($r['response']); } } else { gio::output("Kindly install the cryptographic library tools."); } $net = null; return $status; }
public static function create() { $status = false; $net = new Gnet(); if (GsonCrypt::cryptoInstalled()) { if (!self::isCreated()) { if (!self::configserver()) { gio::output("Account Creation Failed! Service address and port configuration failed"); return false; } if (!GsonCrypt::keygen(config::$accountId)) { gio::output(); gio::output("Account Creation Failed! You may have entered some parameters wrongly"); self::rollback(); return false; } } else { gio::output("Account is already created"); return false; } $cert = GsonCrypt::getcert(); $csr = gio::readrawfile($cert); $m = Gmsg::create(Gmsg::prepare($csr, "signcert", config::$SRA)); $m = GsonCrypt::seal($m, config::$SRA); $r = $net->send($m, true); if (!$r) { gio::output(); gio::output("Account Creation Failed! Unable to connect to account creation server"); } else { $r = GsonCrypt::unseal($r); if (!$r) { gio::output(); gio::output("Account Creation Failed! Ensure that the short name you entered is unique to your bank"); self::rollback(); return false; } $r = Gmsg::extract($r); } if ($r && $r['status']) { $data = $r['response']; if ($r['status'] == 1 && $data) { gio::saverawfile($data, $cert); gio::savetofile($data, GsonCrypt::getkey()); gio::output("Your account was created succesfully"); if (is_readable(config::$walCfgFile)) { $cfg = unserialize(gio::readfile(config::$walCfgFile)); config::$networkInterface = $cfg[0]; config::$walletPort = $cfg[1]; config::$remoteAddress = $cfg[2]; config::$remotePort = $cfg[3]; } gio::output(sprintf("Your account address is '%s'", self::address())); $status = popen("service.ecsh", 'r'); } else { gio::output($r['response']); } } else { self::rollback(); gio::output($r['response']); } } else { gio::output("Kindly install the cryptographic library tools."); } $net = null; return $status; }