コード例 #1
0
ファイル: CppECGroup.cpp プロジェクト: Orange9/Dissent
 bool CppECGroup::IsProbablyValid() const
 {
   return IsElement(GetGenerator()) && 
     IsIdentity(Exponentiate(GetGenerator(), GetOrder())) &&
     CryptoPP::IsPrime(_curve.FieldSize()) &&
     GetOrder().IsPrime();
 }
コード例 #2
0
ファイル: LRSPublicKey.cpp プロジェクト: ranzhao1/Dissent-1
  bool LRSPublicKey::Verify(const QByteArray &data, const LRSSignature &sig) const
  {
    if(!sig.IsValid()) {
      qDebug() << "Invalid signature";
      return false;
    }

    if(sig.SignatureCount() != GetKeys().count()) {
      qDebug() << "Incorrect amount of keys used to generate signature.";
      return false;
    }

    CppHash hash;
    hash.Update(GetGroupGenerator().GetByteArray());
    hash.Update(sig.GetTag().GetByteArray());
    hash.Update(data);
    QByteArray precompute = hash.ComputeHash();

    Integer tcommit = sig.GetCommit1();

    QVector<Integer> keys = GetKeys();
    for(int idx = 0; idx < keys.count(); idx++) {
      Integer z_p = (GetGenerator().Pow(sig.GetSignature(idx), GetModulus()) *
          _keys[idx].Pow(tcommit, GetModulus())) % GetModulus();
      Integer z_pp = (GetGroupGenerator().Pow(sig.GetSignature(idx), GetModulus()) *
          sig.GetTag().Pow(tcommit, GetModulus())) % GetModulus();

      hash.Update(precompute);
      hash.Update(z_p.GetByteArray());
      hash.Update(z_pp.GetByteArray());
      tcommit = Integer(hash.ComputeHash()) % GetSubgroup();
    }

    return tcommit == sig.GetCommit1();
  }
コード例 #3
0
ファイル: SyncRandom.cpp プロジェクト: Disasm/karya-valya
    void set_rand(unsigned int new_seed, unsigned int new_calls_counter)
    {
        SYSTEM_STREAM << "set_seed: " << new_seed << std::endl;
        SYSTEM_STREAM << "set_calls_counter: " << new_calls_counter << std::endl;
        calls_counter = new_calls_counter;
        seed = new_seed;

        GetGenerator(new_seed).discard(new_calls_counter);
    }
コード例 #4
0
ファイル: BlockRenderStratery.cpp プロジェクト: denesik/World
void BlockRenderStratery::Load(const rapidjson::Value & val)
{
  auto &mg = GetGenerator();

  if (val.HasMember("all"))
  {
    mg.SetTexture(MeshBlockGenerator::ALL, val["all"].GetString());
    
  }

  mg.Generate();
}
コード例 #5
0
void
CMakeProjectSettingsPanel::StoreSettings()
{
    if (!m_settings)
        return;

    m_settings->enabled = IsCMakeEnabled();
    m_settings->sourceDirectory = GetSourceDirectory();
    m_settings->buildDirectory = GetBuildDirectory();
    m_settings->generator = GetGenerator();
    m_settings->buildType = GetBuildType();
    m_settings->arguments = GetArguments();
    m_settings->parentProject = GetParentProject();
}
コード例 #6
0
ファイル: LRSPublicKey.cpp プロジェクト: ranzhao1/Dissent-1
  bool LRSPublicKey::operator==(const AsymmetricKey &key) const
  {
    const LRSPublicKey *other = dynamic_cast<const LRSPublicKey *>(&key);
    if(!other) {
      return false;
    }

    if(this == other) {
      return true;
    }

    return (other->GetGenerator() == GetGenerator()) &&
      (other->GetKeys() == GetKeys()) &&
      (other->GetModulus() == GetModulus()) &&
      (other->GetSubgroup() == GetSubgroup()) &&
      (other->GetLinkageContext() == GetLinkageContext()) &&
      (other->IsValid() == IsValid());
  }
コード例 #7
0
ファイル: CppECGroup.cpp プロジェクト: Orange9/Dissent
 Element CppECGroup::RandomElement() const
 {
   return Exponentiate(GetGenerator(), RandomExponent());
 }
コード例 #8
0
ファイル: metabuild.cpp プロジェクト: ancapdev/vpm
int Metabuild::Run(Configuration const& configuration, int argc, char** argv) const
{
    Options const options(mOptionsDesc, argc, argv);

    std::stringstream cmdline;

    std::vector<char const*> const& unnamed = options.GetUnnamedValues();
    if (unnamed.empty())
    {
        std::cout << "No packages specified" << std::endl;
        return 1;
    }

    cmdline << "cmake " << configuration.frameworkDirectory;

    std::string const* bitsString = options.GetValue("bits");
    std::size_t const bits = bitsString ? (*bitsString == "32" ? 32 : 64) : configuration.defaultBits;
    std::string const generator = GetGenerator(configuration, options, bits);

    cmdline << " -G \"" << generator << "\"";
    
    cmdline << " -DVPM_BITS=" << bits;

    if (std::string const* configurations = options.GetValue("configurations"))
    {
        if (IsMultiConfigurationGenerator(generator))
        {
            cmdline << " -DCMAKE_CONFIGURATION_TYPES=\"" << *configurations << "\"";
        }
        else
        {
            if (configurations->find(';') != std::string::npos)
                throw std::runtime_error(generator + " generator only supports 1 configuration. Given: " + *configurations);

            cmdline << " -DCMAKE_BUILD_TYPE=" << *configurations;
        }
    }

    if (std::string const* configPackage = options.GetValue("config_package"))
        cmdline << " -DVPM_CONFIG_PACKAGE=\"" << *configPackage << "\"";
    else
        cmdline << " -DVPM_CONFIG_PACKAGE=\"" << configuration.defaultConfigPackage << "\"";

    if (!configuration.packageRoots.empty())
    {
        cmdline << " -DVPM_PACKAGE_ROOTS=\"";
        std::vector<std::string>::const_iterator it = configuration.packageRoots.begin();
        cmdline << *it;
        for (++it; it != configuration.packageRoots.end(); ++it)
            cmdline << ";" << *it;
        cmdline << "\"";
    }

    cmdline << " -DVPM_BUILD_PACKAGES=\"";
    for (std::vector<char const*>::const_iterator it = unnamed.begin(), end = unnamed.end(); it != end; ++it)
        cmdline << (it != unnamed.begin() ? ";" : "") << EscapeBackslash(*it);
    cmdline << "\"";
    
    if (std::string const* cmakeArgs = options.GetValue("cmake_args"))
        cmdline << " " << *cmakeArgs;

    if (options.GetValue("whatif") != nullptr)
    {
        std::cout << "[WHATIF] Executing: " << cmdline.str() << std::endl;
        return 0;
    }
    else
    {
        std::cout << "Executing: " << cmdline.str() << std::endl;
        return system(cmdline.str().c_str());
    }
}
コード例 #9
0
ファイル: SyncRandom.cpp プロジェクト: Disasm/karya-valya
unsigned int get_rand()
{
    ++calls_counter;
    unsigned int retval = GetGenerator()();
    return retval;
}