コード例 #1
0
ファイル: SpdzCommitment.java プロジェクト: GuutBoy/fresco
 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
ファイル: SpdzCommitment.java プロジェクト: GuutBoy/fresco
 /**
  * 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);
 }