def createSTP(self, stp_filename, parameters):
        """
        Creates an STP file to find a linear characteristic for SIMON with
        the given parameters.
        """

        wordsize = parameters["wordsize"]
        rounds = parameters["rounds"]
        weight = parameters["sweight"]

        # Replace with custom if set in parameters.
        if "rotationconstants" in parameters:
            self.rot_alpha = parameters["rotationconstants"][0] 
            self.rot_beta = parameters["rotationconstants"][1]
            self.rot_gamma = parameters["rotationconstants"][2]

        with open(stp_filename, 'w') as stp_file:
            header = ("% Input File for STP\n% Simon w={} alpha={} beta={}"
                      " gamma={} rounds={}\n\n\n".format(wordsize,
                                                         self.rot_alpha,
                                                         self.rot_beta,
                                                         self.rot_gamma,
                                                         rounds))
            stp_file.write(header)

            # Setup variable
            # x = left, y = right
            x = ["x{}".format(i) for i in range(rounds + 1)]
            y = ["y{}".format(i) for i in range(rounds + 1)]
            b = ["b{}".format(i) for i in range(rounds + 1)]
            c = ["c{}".format(i) for i in range(rounds + 1)]
            and_out = ["andout{}".format(i) for i in range(rounds + 1)]
            abits = ["abits{}".format(i) for i in range(rounds + 1)]

            #Create tmp variables for weight computation
            tmpWeight = ["tmp{}r{}".format(j, i) for i in range(rounds) 
                         for j in range(wordsize)]

            #Tmp variables for parity checks
            sbits = ["sbits{}r{}".format(j, i) for i in range(rounds) 
                     for j in range(wordsize)]
            pbits = ["pbits{}r{}".format(j, i) for i in range(rounds) 
                     for j in range(wordsize)]

            # w = weight
            w = ["w{}".format(i) for i in range(rounds)]

            stpcommands.setupVariables(stp_file, x, wordsize)
            stpcommands.setupVariables(stp_file, y, wordsize)
            stpcommands.setupVariables(stp_file, and_out, wordsize)
            stpcommands.setupVariables(stp_file, b, wordsize)
            stpcommands.setupVariables(stp_file, c, wordsize)
            stpcommands.setupVariables(stp_file, abits, wordsize)
            stpcommands.setupVariables(stp_file, w, wordsize)
            stpcommands.setupVariables(stp_file, tmpWeight, wordsize)
            stpcommands.setupVariables(stp_file, sbits, wordsize)
            stpcommands.setupVariables(stp_file, pbits, wordsize)

            stpcommands.setupWeightComputation(stp_file, weight, w, wordsize)

            for i in range(rounds):
                indicesFrom = i*wordsize
                indicesTo = (i+1)*wordsize
                self.setupSimonRound(stp_file, x[i], y[i], x[i+1], y[i+1], 
                                     and_out[i], b[i], c[i], abits[i], w[i],
                                     tmpWeight[indicesFrom:indicesTo],
                                     sbits[indicesFrom:indicesTo],
                                     pbits[indicesFrom:indicesTo],
                                     wordsize)

            # No all zero characteristic
            stpcommands.assertNonZero(stp_file, x + y, wordsize)

            # Iterative characteristics only
            # Input difference = Output difference
            if parameters["iterative"]:
                stpcommands.assertVariableValue(stp_file, x[0], x[rounds])
                stpcommands.assertVariableValue(stp_file, y[0], y[rounds])

            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)

        return
dataset/ETHPy150Open kste/cryptosmt/ciphers/simonlinear.py/SimonLinearCipher.createSTP/original