Example #1
0
  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();
  }
Example #2
0
 /**
  * Called to generate the shufflers group
  */
 virtual void GenerateShufflerGroup()
 {
     SetShufflers(GetGroupGenerator()->NextGroup());
 }