Пример #1
0
 public BigInteger getCommitment() {
   if (this.commitment != null) {
     return this.commitment;
   }
   H.update(value.toByteArray());
   this.randomness = new BigInteger(Util.getModulus().bitLength(), rand);
   H.update(this.randomness.toByteArray());
   this.commitment = new BigInteger(H.digest()).mod(Util.getModulus());
   return this.commitment;
 }
Пример #2
0
 /**
  * Returns true if the given values match the commitment given.
  *
  * @param commitment
  * @param value
  * @param randomness
  * @return
  */
 public static boolean checkCommitment(
     MessageDigest H, BigInteger commitment, BigInteger value, BigInteger randomness) {
   H.update(value.toByteArray());
   H.update(randomness.toByteArray());
   BigInteger testSubject = new BigInteger(H.digest()).mod(Util.getModulus());
   return commitment.equals(testSubject);
 }