auditor
Class Crypto

java.lang.Object
  extended by auditor.Crypto

public class Crypto
extends java.lang.Object

Class responsible for performing cryptographic operations - mainly for checking commitments

Author:
felippo

Field Summary
static javax.crypto.Cipher cipherNoPaddingNoKey
           
static javax.crypto.Cipher cipherPkcs5Padding
           
(package private) static java.security.MessageDigest sha
           
 
Constructor Summary
Crypto()
           
 
Method Summary
static boolean checkDrowCommitment(java.lang.String slt, int prid, java.lang.String perm, java.lang.String cmt, int partitionID, int instanceID, int rowID, java.lang.String c)
          Checks if commitment cmt is correct for given data
static boolean checkProwCommitment(java.lang.String slt, java.lang.String p1, int pid, java.lang.String cmt, java.lang.String c)
          Checks if cmt is a correct commitment to message (pi, pid) with given salt slt
private static byte[] computeCommitment(byte[] slt, byte[] c, byte[] m)
          given a salt slt, election constant c, computes commitment to the message m
static byte[] computeCommitment(java.lang.String slt, java.lang.String c, byte[] m)
          Given a message m, salt skm, commitment cmt to m and public constant C it returnes if the commitment to the message m is valid sak=Encrypt C with skm h1 = SHA256(m, sak).
private static byte[] makeDMessage(byte partitionId, byte instanceId, byte[] rowId, int prid, byte[] perm)
          Prepares a message for commitment
private static byte[] makePMessage(byte[] serial, byte[] p)
          Returns a byte array of "message" for ballot serial and p
protected static byte[] parse(java.lang.String permutation)
          Changes permutation string into a byte array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cipherNoPaddingNoKey

public static javax.crypto.Cipher cipherNoPaddingNoKey

cipherPkcs5Padding

public static javax.crypto.Cipher cipherPkcs5Padding

sha

static java.security.MessageDigest sha
Constructor Detail

Crypto

public Crypto()
Method Detail

computeCommitment

public static byte[] computeCommitment(java.lang.String slt,
                                       java.lang.String c,
                                       byte[] m)
                                throws java.lang.Exception
Given a message m, salt skm, commitment cmt to m and public constant C it returnes if the commitment to the message m is valid sak=Encrypt C with skm h1 = SHA256(m, sak). h2 = SHA256(m, Encrypt h1 with sak) the commitment is h1h2 (h1 concatenated with h2) where E stands for Encrypt. The encryption scheme used is AES/ECB/NoPadding

Parameters:
slt - - the salt used in the commitment
m - - the message to be commited to
c - - public constant
Returns:
- commitment to m
Throws:
java.lang.Exception

computeCommitment

private static byte[] computeCommitment(byte[] slt,
                                        byte[] c,
                                        byte[] m)
                                 throws java.lang.Exception
given a salt slt, election constant c, computes commitment to the message m

Parameters:
slt - - salt used in commitment
c - - public constant
m - - message
Returns:
- commitment to m
Throws:
java.lang.Exception

checkProwCommitment

public static boolean checkProwCommitment(java.lang.String slt,
                                          java.lang.String p1,
                                          int pid,
                                          java.lang.String cmt,
                                          java.lang.String c)
Checks if cmt is a correct commitment to message (pi, pid) with given salt slt

Parameters:
slt - - salt
p1 - - message
pid - - p id
cmt - - commitment
c - - public constant
Throws:
java.lang.Exception - if the commitment does not checks.

makePMessage

private static byte[] makePMessage(byte[] serial,
                                   byte[] p)
Returns a byte array of "message" for ballot serial and p

Parameters:
serial - - ballot id
p - - permutation
Returns:
- byte array that represents a message

checkDrowCommitment

public static boolean checkDrowCommitment(java.lang.String slt,
                                          int prid,
                                          java.lang.String perm,
                                          java.lang.String cmt,
                                          int partitionID,
                                          int instanceID,
                                          int rowID,
                                          java.lang.String c)
                                   throws java.lang.Exception
Checks if commitment cmt is correct for given data

Parameters:
slt - - salt
prid - - pid or rid
perm - - permutation (d2 or d4) transformation
cmt - - commitment (cl or cr)
partitionID - - partition id
instanceID - - instance id
c - - public constant
Throws:
java.lang.Exception - if the commitment does not checks. The commitment is constructed using computeCommitment

makeDMessage

private static byte[] makeDMessage(byte partitionId,
                                   byte instanceId,
                                   byte[] rowId,
                                   int prid,
                                   byte[] perm)
Prepares a message for commitment

Parameters:
partitionId - - id of the partition
instanceId - - id ot the instance
rowId - - id of the row
prid - - id (pid or rid)
perm - - permutation (d2 or d4)
Returns:
- byte array that represents a message

parse

protected static byte[] parse(java.lang.String permutation)
Changes permutation string into a byte array

Parameters:
permutation - - string representing permutation
Returns:
- byte array