Пример #1
0
 def visit_eq_tst(self, node, data):
     # Restrict to only product nodes that we've introduced for 
     # iterating over the N signatures
     delta = BinaryNode("delta")
     _list = [ops.EXP, ops.PAIR, ops.ATTR]
     if str(node.left) != "1":
         node.left = AbstractTechnique.createExp2(BinaryNode.copy(node.left), delta, _list)            
     if str(node.right) != "1":
         node.right = AbstractTechnique.createExp2(BinaryNode.copy(node.right), BinaryNode.copy(delta), _list)
Пример #2
0
 def __init__(self, settingObj, sdl_data=None, variables=None, addIndex=True):
     if sdl_data:
         AbstractTechnique.__init__(self, sdl_data, variables)
     self.settingObj = settingObj
     self.inverse = BinaryNode("-1")
     self.finalAND   = [ ]
     self.attr_index = 0
     self.addIndex = addIndex
     self.debug      = False
Пример #3
0
 def visit_eq_tst(self, node, data):
     # Restrict to only product nodes that we've introduced for
     # iterating over the N signatures
     delta = BinaryNode("delta")
     _list = [ops.EXP, ops.PAIR, ops.ATTR]
     if str(node.left) != "1":
         node.left = AbstractTechnique.createExp2(
             BinaryNode.copy(node.left), delta, _list)
     if str(node.right) != "1":
         node.right = AbstractTechnique.createExp2(
             BinaryNode.copy(node.right), BinaryNode.copy(delta), _list)
Пример #4
0
 def __init__(self,
              settingObj,
              sdl_data=None,
              variables=None,
              addIndex=True):
     if sdl_data:
         AbstractTechnique.__init__(self, sdl_data, variables)
     self.settingObj = settingObj
     self.inverse = BinaryNode("-1")
     self.finalAND = []
     self.attr_index = 0
     self.addIndex = addIndex
     self.debug = False
Пример #5
0
 def checkForInverse(self, node):
     if self.extra_side.get(str(node)):
         if self.node_side != self.extra_side[str(node)]:
             if self.debug:
                 print('different side! take inverse')
                 print("node: ", node, self.extra_side[str(node)])
             if self.extra_inverted: 
                 #print("The CL fix: ", self.extra_inverted)
                 return node
                 # this means we shouldn't invert the node because we're combining from another node
             return AbstractTechnique.createInvExp(node)
     
     if self.debug: print('same side: ', self.node_side, node, self.extra_side)
     if self.extra_inverted: return AbstractTechnique.createInvExp(node) # ONLY DIFFERENCE BETWEEN SP2 and SP3
     return node
Пример #6
0
    def checkForInverse(self, node):
        if self.extra_side.get(str(node)):
            if self.node_side != self.extra_side[str(node)]:
                if self.debug:
                    print('different side! take inverse')
                    print("node: ", node, self.extra_side[str(node)])
                if self.extra_inverted:
                    #print("The CL fix: ", self.extra_inverted)
                    return node
                    # this means we shouldn't invert the node because we're combining from another node
                return AbstractTechnique.createInvExp(node)

        if self.debug:
            print('same side: ', self.node_side, node, self.extra_side)
        if self.extra_inverted:
            return AbstractTechnique.createInvExp(
                node)  # ONLY DIFFERENCE BETWEEN SP2 and SP3
        return node
Пример #7
0
 def combine(self, subtree1, subtree2, parentOfTarget=None):
     #print("DEBUG: Combining two subtrees: ", subtree1,"<= with =>" , subtree2)
     if Type(subtree1) == Type(subtree2) and Type(subtree1) == ops.ON:
         #print("Found ON node: ", subtree1)
         return self.combine(subtree1.right, subtree2.right)
     elif Type(subtree1) == Type(subtree2) and Type(subtree1) == ops.MUL:
         #print("Found MUL node: ", subtree1, subtree2)
         return AbstractTechnique.createMul(subtree1, subtree2)
     elif Type(subtree1) == Type(subtree2) and Type(subtree1) == ops.EXP:
         if str(subtree1.left) == str(subtree2.left):
             # print("Found EXP node bases that match: ", subtree1, subtree2)
             # this is for the situation where the bases are the same
             # e.g., g^x * g^y => g^(x + y)
             addNode = BinaryNode(ops.ADD)
             addNode.left = subtree1.right
             addNode.right = subtree2.right
             return AbstractTechnique.createExp(subtree1.left, addNode)
         return AbstractTechnique.createMul(subtree1, subtree2)
     else:
         #print("Found node: ", Type(subtree1), Type(subtree2))
         #print("Now combining these two: ", subtree1, "<= WITH => ", subtree2)
         return BinaryNode(ops.MUL, BinaryNode.copy(subtree1), BinaryNode.copy(subtree2))
Пример #8
0
 def combine(self, subtree1, subtree2, parentOfTarget=None):
     #print("DEBUG: Combining two subtrees: ", subtree1,"<= with =>" , subtree2)
     if Type(subtree1) == Type(subtree2) and Type(subtree1) == ops.ON:
         #print("Found ON node: ", subtree1)
         return self.combine(subtree1.right, subtree2.right)
     elif Type(subtree1) == Type(subtree2) and Type(subtree1) == ops.MUL:
         #print("Found MUL node: ", subtree1, subtree2)
         return AbstractTechnique.createMul(subtree1, subtree2)
     elif Type(subtree1) == Type(subtree2) and Type(subtree1) == ops.EXP:
         if str(subtree1.left) == str(subtree2.left):
             # print("Found EXP node bases that match: ", subtree1, subtree2)
             # this is for the situation where the bases are the same
             # e.g., g^x * g^y => g^(x + y)
             addNode = BinaryNode(ops.ADD)
             addNode.left = subtree1.right
             addNode.right = subtree2.right
             return AbstractTechnique.createExp(subtree1.left, addNode)
         return AbstractTechnique.createMul(subtree1, subtree2)
     else:
         #print("Found node: ", Type(subtree1), Type(subtree2))
         #print("Now combining these two: ", subtree1, "<= WITH => ", subtree2)
         return BinaryNode(ops.MUL, BinaryNode.copy(subtree1),
                           BinaryNode.copy(subtree2))
Пример #9
0
 def __init__(self, variables):
     AbstractTechnique.__init__(self, None, variables)
     self.missing_symbols = []
     self.exclude_list = []
Пример #10
0
 def __init__(self, variables, curve=pairing.Asymmetric):
     AbstractTechnique.__init__(self, None, variables)
     self.left_errors  = []
     self.right_errors = []
     self.curve_type   = curve