public class HashingMultiKeyEncryption extends java.lang.Object implements MultiKeyEncryptionScheme
In this encryption scheme the garbled values of each wire are appended to each other and the result is hashed. We XOR the plaintext with the output of the hash function.
See Garbling Schemes by Mihir Bellare, Viet Tung Hoang, and Phillip Rogaway for a full discussion on the many different types of garbling schemes and how efficient they are.
|Constructor and Description|
Constructor that sets default values.
Constructor that sets the given values.
|Modifier and Type||Method and Description|
Decrypts the ciphertext.
This method used the individual
This method generates a single
This method is provided with individual
Returns the size of the ciphertext.
Checks if the key for this
Sets the key to the specified
See Garbling Schemes by Mihir Bellare, Viet Tung Hoang, and Phillip Rogaway.
public HashingMultiKeyEncryption(int keySize, CryptographicHash hash, java.security.SecureRandom random) throws InvalidKeySizeException
public byte encrypt(byte plaintext) throws KeyNotSetException, PlaintextTooLongException
SecretKeys that make up the
MultiSecretKeyto encrypt the plaintext.
public byte decrypt(byte ciphertext) throws KeyNotSetException, CiphertextTooLongException
public javax.crypto.SecretKey generateKey()
This is necessary since the user will often need to generate single keys first and then combine them to a single
Consider the following problem: Say we want to garble and compute a gate in Yao's protocol.
Consider a 2 input gate. Each input Wire will have two possible garbled values--corresponding to a 0 value and a 1 value.
These values are <@code SecretKey}s NOTMultiSecretKeys. When we encrypt the truth table, we combine the single
keys to create
MultiSecretKeys. So, if we want to encrypt the 0-0 entry of the truth table, we will take the 0 key from
GarbledWire and combine them to a
MultiSecretKey (using the
Then if we want to encrypt the 0-1 entry, we will use the 0-key from the first wire and the 1-key from the second wire.
We will combine these 2 keys into a single
MultiSecretKey and use this to encrypt. Note that in this example,
the 0-key from the first Wire is combined from 2 different
MultiSecretKeys. First we combined it with the 0-key of the second
wire and then we combined it with the 1-key.
Thus, it is necessary to have a method to generate individual keys and a separate method to combine different single keys into
public MultiSecretKey generateMultiKey(javax.crypto.SecretKey... keys)
SecretKeys and combines them into a
MultiSecretKeythat can be used for encryption and decryption with the
keys- The individual
SecretKeys that make up the
SecretKeyobjects can be passed in an array or as individual parameters.
MultiSecretKeymade up of the
SecretKeys that were passed as parameters.
public boolean isKeySet()
MultiKeyEncryptionSchemehas been set.
true if it has been and
false if it has not been.
Before encrypting and decrypting, the key must be set.
public void setKey(MultiSecretKey key)
The key that it is currently set to, will be used for encryption and decryption until
setKey() is called again.
public void setTweak(byte tweak)
Some encryption schemes use a tweak and instead of encrypting directly the entry of the plaintext, encrypt the tweak and then XOR the result with the plaintext.
Some encryption schemes do not make use of a tweak, in which case calls to set the tweak have no effect. If you are implementing an encryption scheme that does not use a tweak, just leave the body of this method blank.