HashCommitter (Bouncy Castle Library 1.52 API Specification)
Date: 2015-03-01

org.bouncycastle.crypto.commitments

## Class HashCommitter

- java.lang.Object
- - org.bouncycastle.crypto.commitments.HashCommitter

- All Implemented Interfaces:
    Committer

      public class HashCommitter
      extends java.lang.Object
      implements Committer

  A basic hash-committer as described in "Making Mix Nets Robust for Electronic Voting by Randomized Partial Checking", by Jakobsson, Juels, and Rivest (11th Usenix Security Symposium, 2002).

  Use this class if you can enforce fixed length for messages. If you need something more general, use the GeneralHashCommitter.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HashCommitter(ExtendedDigest digest, java.security.SecureRandom random)` Base Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Commitment` | `commit(byte[] message)` Generate a commitment for the passed in message.
    `boolean` | `isRevealed(Commitment commitment, byte[] message)` Return true if the passed in commitment represents a commitment to the passed in message.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HashCommitter

          public HashCommitter(ExtendedDigest digest,
                       java.security.SecureRandom random)

      Base Constructor. The maximum message length that can be committed to is half the length of the internal block size for the digest (ExtendedDigest.getBlockLength()).
      Parameters:
        `digest` - digest to use for creating commitments.
        `random` - source of randomness for generating secrets.

  - ### Method Detail

    - #### commit

          public Commitment commit(byte[] message)

      Generate a commitment for the passed in message.
      Specified by:
        `commit` in interface `Committer`
      Parameters:
        `message` - the message to be committed to,
      Returns:
        a Commitment

    - #### isRevealed

          public boolean isRevealed(Commitment commitment,
                           byte[] message)

      Return true if the passed in commitment represents a commitment to the passed in message.
      Specified by:
        `isRevealed` in interface `Committer`
      Parameters:
        `commitment` - a commitment previously generated.
        `message` - the message that was expected to have been committed to.
      Returns:
        true if commitment matches message, false otherwise.