# Path: parser/stpcommands.py
# def blockCharacteristic(stpfile, characteristic, wordsize):
# def setupQuery(stpfile):
# def setupVariables(stpfile, variables, wordsize):
# def assertVariableValue(stpfile, a, b):
# def getStringForVariables(variables, wordsize):
# def assertNonZero(stpfile, variables, wordsize):
# def getStringForNonZero(variables, wordsize):
# def limitWeight(stpfile, weight, p, wordsize, ignoreMSBs=0):
# def setupWeightComputationSum(stpfile, weight, p, wordsize, ignoreMSBs=0):
# def setupWeightComputation(stpfile, weight, p, wordsize, ignoreMSBs=0):
# def getWeightString(variables, wordsize, ignoreMSBs=0, weightVariable="weight"):
# def getStringEq(a, b, c):
# def getStringAdd(a, b, c, wordsize):
# def getStringForAndDifferential(a, b, c):
# def getStringLeftRotate(value, rotation, wordsize):
# def getStringRightRotate(value, rotation, wordsize):
# def add4bitSbox(sbox, variables):
#     DDT = [[0]*16 for i in range(16)]
# 
# Path: ciphers/cipher.py
# class AbstractCipher(object, metaclass=ABCMeta):
#     """
#     Abstract Class for Ciphers
#     """
# 
#     @abstractmethod
#     def createSTP(self, filename, cipherParameters):
#         """
#         Each cipher need to define how it creates an instance for the
#         SMT solver.
#         """
#         pass
# 
#     @abstractmethod
#     def getFormatString(self):
#         """
#         Each cipher needs to specify the format it should be printed.
#         """
#         pass
# 
# Path: parser/stpcommands.py
# def getStringLeftRotate(value, rotation, wordsize):
#     if rotation % wordsize == 0:
#         return "{0}".format(value)
#     command = "((({0} << {1})[{2}:0]) | (({0} >> {3})[{2}:0]))".format(
#         value, (rotation % wordsize), wordsize - 1, (wordsize - rotation) % wordsize)
# 
#     return command
# 
# Path: parser/stpcommands.py
# def getStringRightRotate(value, rotation, wordsize):
#     if rotation % wordsize == 0:
#         return "{0}".format(value)
#     command = "((({0} >> {1})[{2}:0]) | (({0} << {3})[{2}:0]))".format(
#         value, (rotation % wordsize), wordsize - 1, (wordsize - rotation) % wordsize)
#     return command


from parser import stpcommands
from ciphers.cipher import AbstractCipher
from parser.stpcommands import getStringLeftRotate as rotl
from parser.stpcommands import getStringRightRotate as rotr
            # stpcommands.assertVariableValue(stp_file, v1[0], v2[0])
            # stp_file.write(self.getStringForCollision(v0[rounds], v1[rounds],
            #                v2[rounds], v3[rounds], wordsize))

            ## Uncomment to search for message collision
            stpcommands.assertNonZero(stp_file, m, wordsize)
            zero_string = "0hex" + "0"*(wordsize / 4)
            stpcommands.assertVariableValue(stp_file, v0[0], zero_string)
            stpcommands.assertVariableValue(stp_file, v1[0], zero_string)
            stpcommands.assertVariableValue(stp_file, v2[0], zero_string)
            stpcommands.assertVariableValue(stp_file, v3[0], zero_string)
            stp_file.write(self.getStringForCollision(v0[rounds*self.num_messages],
                                                      v1[rounds*self.num_messages],
                                                      v2[rounds*self.num_messages],
                                                      v3[rounds*self.num_messages],
                                                      wordsize))

            ## Uncomment to search for characteristic / distinguisher
            # for i in m:
            #     zero_string = "0hex" + "0"*(wordsize / 4)
            #     stpcommands.assertVariableValue(stp_file, i, zero_string)

            # stpcommands.assertNonZero(stp_file, v0 + v1 + v2 + v3, wordsize)

            for key, value in parameters["fixedVariables"].items():
                stpcommands.assertVariableValue(stp_file, key, value)

            for char in parameters["blockedCharacteristics"]:
                stpcommands.blockCharacteristic(stp_file, char, wordsize)


# Path: parser/stpcommands.py
# def blockCharacteristic(stpfile, characteristic, wordsize):
# def setupQuery(stpfile):
# def setupVariables(stpfile, variables, wordsize):
# def assertVariableValue(stpfile, a, b):
# def getStringForVariables(variables, wordsize):
# def assertNonZero(stpfile, variables, wordsize):
# def getStringForNonZero(variables, wordsize):
# def limitWeight(stpfile, weight, p, wordsize, ignoreMSBs=0):
# def setupWeightComputationSum(stpfile, weight, p, wordsize, ignoreMSBs=0):
# def setupWeightComputation(stpfile, weight, p, wordsize, ignoreMSBs=0):
# def getWeightString(variables, wordsize, ignoreMSBs=0, weightVariable="weight"):
# def getStringEq(a, b, c):
# def getStringAdd(a, b, c, wordsize):
# def getStringForAndDifferential(a, b, c):
# def getStringLeftRotate(value, rotation, wordsize):
# def getStringRightRotate(value, rotation, wordsize):
# def add4bitSbox(sbox, variables):
#     DDT = [[0]*16 for i in range(16)]
# 
# Path: ciphers/cipher.py
# class AbstractCipher(object, metaclass=ABCMeta):
#     """
#     Abstract Class for Ciphers
#     """
# 
#     @abstractmethod
#     def createSTP(self, filename, cipherParameters):
#         """
#         Each cipher need to define how it creates an instance for the
#         SMT solver.
#         """
#         pass
# 
#     @abstractmethod
#     def getFormatString(self):
#         """
#         Each cipher needs to specify the format it should be printed.
#         """
#         pass
# 
# Path: parser/stpcommands.py
# def getStringLeftRotate(value, rotation, wordsize):
#     if rotation % wordsize == 0:
#         return "{0}".format(value)
#     command = "((({0} << {1})[{2}:0]) | (({0} >> {3})[{2}:0]))".format(
#         value, (rotation % wordsize), wordsize - 1, (wordsize - rotation) % wordsize)
# 
#     return command
# 
# Path: parser/stpcommands.py
# def getStringRightRotate(value, rotation, wordsize):
#     if rotation % wordsize == 0:
#         return "{0}".format(value)
#     command = "((({0} >> {1})[{2}:0]) | (({0} << {3})[{2}:0]))".format(
#         value, (rotation % wordsize), wordsize - 1, (wordsize - rotation) % wordsize)
#     return command


# Path: ciphers/siphash.py
from parser import stpcommands
from ciphers.cipher import AbstractCipher
from parser.stpcommands import getStringLeftRotate as rotl
from parser.stpcommands import getStringRightRotate as rotr

            # stpcommands.assertVariableValue(stp_file, v1[0], v2[0])
            # stp_file.write(self.getStringForCollision(v0[rounds], v1[rounds],
            #                v2[rounds], v3[rounds], wordsize))

            ## Uncomment to search for message collision
            stpcommands.assertNonZero(stp_file, m, wordsize)
            zero_string = "0hex" + "0"*(wordsize / 4)
            stpcommands.assertVariableValue(stp_file, v0[0], zero_string)
            stpcommands.assertVariableValue(stp_file, v1[0], zero_string)
            stpcommands.assertVariableValue(stp_file, v2[0], zero_string)
            stpcommands.assertVariableValue(stp_file, v3[0], zero_string)
            stp_file.write(self.getStringForCollision(v0[rounds*self.num_messages],
                                                      v1[rounds*self.num_messages],
                                                      v2[rounds*self.num_messages],
                                                      v3[rounds*self.num_messages],
                                                      wordsize))

            ## Uncomment to search for characteristic / distinguisher
            # for i in m:
            #     zero_string = "0hex" + "0"*(wordsize / 4)
            #     stpcommands.assertVariableValue(stp_file, i, zero_string)

            # stpcommands.assertNonZero(stp_file, v0 + v1 + v2 + v3, wordsize)

            for key, value in parameters["fixedVariables"].items():
                stpcommands.assertVariableValue(stp_file, key, value)

            for char in parameters["blockedCharacteristics"]:
                stpcommands.blockCharacteristic(stp_file, char, wordsize)


            stpcommands.setupQuery(stp_file)