Top Description Fields Constructors Methods
org.bouncycastle.crypto.commitments

public Class HashCommitter

extends Object
implements Committer
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.Committer
Imports
java.security.SecureRandom, org.bouncycastle.crypto.Commitment, .Committer, .DataLengthException, .Digest, .ExtendedDigest, org.bouncycastle.util.Arrays

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.

Field Summary

Modifier and TypeField and Description
private final int
private final Digest
private final SecureRandom

Constructor Summary

AccessConstructor and Description
public
HashCommitter(ExtendedDigest
digest to use for creating commitments.
digest
,
SecureRandom
source of randomness for generating secrets.
random
)

Base Constructor.

Method Summary

Modifier and TypeMethod and Description
private byte[]
calculateCommitment(byte[] w, byte[] message)

public Commitment

Returns:

a Commitment
commit
(byte[]
the message to be committed to,
message
)

Implements org.bouncycastle.crypto.Committer.commit.

Generate a commitment for the passed in message.

public boolean

Returns:

true if commitment matches message, false otherwise.
isRevealed
(Commitment
a commitment previously generated.
commitment
,
byte[]
the message that was expected to have been committed to.
message
)

Implements org.bouncycastle.crypto.Committer.isRevealed.

Return true if the passed in commitment represents a commitment to the passed in message.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

byteLengthback to summary
private final int byteLength
digestback to summary
private final Digest digest
randomback to summary
private final SecureRandom random

Constructor Detail

HashCommitterback to summary
public HashCommitter(ExtendedDigest digest, 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:ExtendedDigest

digest to use for creating commitments.

random:SecureRandom

source of randomness for generating secrets.

Method Detail

calculateCommitmentback to summary
private byte[] calculateCommitment(byte[] w, byte[] message)
commitback to summary
public Commitment commit(byte[] message)

Implements org.bouncycastle.crypto.Committer.commit.

Generate a commitment for the passed in message.

Parameters
message:byte[]

the message to be committed to,

Returns:Commitment

a Commitment

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

Implements org.bouncycastle.crypto.Committer.isRevealed.

Return true if the passed in commitment represents a commitment to the passed in message.

Parameters
commitment:Commitment

a commitment previously generated.

message:byte[]

the message that was expected to have been committed to.

Returns:boolean

true if commitment matches message, false otherwise.