bool Page::isValid(bool deepTest) { Json::FastWriter writer; std::string data = writer.write(getCommonData()); const uint8_t* bytes = reinterpret_cast<const uint8_t*>(data.c_str()); int check = ed25519_sign_open(bytes, data.size(), publicEd_.data(), pageSig_.data()); if (check == 0) { if (deepTest) for (auto r : recordList_) if (!r->isValid()) return false; return true; } else if (check == 1) { return false; } else { Log::get().warn("General Ed25519 signature failure on Page signature."); return false; } }
std::string Page::toString() const { Json::Value obj = getCommonData(); obj["publicEd"] = Botan::base64_encode(publicEd_.data(), publicEd_.size()); obj["pageSig"] = Botan::base64_encode(pageSig_.data(), pageSig_.size()); Json::FastWriter writer; return writer.write(obj); }
void Page::resign(const std::array<uint8_t, Const::ED25519_KEY_LEN>& sk) { ed25519_public_key pk; ed25519_publickey(sk.data(), pk); Json::FastWriter writer; std::string data = writer.write(getCommonData()); const uint8_t* bytes = reinterpret_cast<const uint8_t*>(data.c_str()); ed25519_sign(bytes, data.size(), sk.data(), pk, pageSig_.data()); }
SHA384_HASH Page::toHash() const { Json::FastWriter writer; std::string str = writer.write(getCommonData()); const uint8_t* bytes = reinterpret_cast<const uint8_t*>(str.c_str()); SHA384_HASH array; Botan::SHA_384 sha384; memcpy(array.data(), sha384.process(bytes, str.size()), Const::SHA384_LEN); return array; }
void mainMenu::onRender() { objectBase::getRenderer()->setViewMatrixToGL(&m_cViewMatrix); #if !defined (USE_ProgrammablePipeLine) glMatrixMode(GL_PROJECTION); glLoadMatrixf(objectBase::getRenderer()->getOrthoProjectionMatrix()->getMatrix()); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -1); #endif glPushMatrix(); glPopMatrix(); char buffer[128]; sprintf(buffer, "BALL GAME\n\n\n\nPress 'Space' to play the game... 'ESc' to exit."); getCommonData()->getArialBold15Font()->drawString(buffer, getCommonData()->getScreenWidth()*0.5f, getCommonData()->getScreenHeight()*0.5f, true); Scene::onRender(); }
void mainMenu::onSize(int cx, int cy) { getCommonData()->getRendererPtr()->setViewPort(0, 0, cx, cy); Scene::onSize(cx, cy); }