コード例 #1
0
	def make_req(self, expr, type):
		if (isinstance(expr, Input)):
			result = ArithmeticInputReq(self, expr, type)
		elif (isinstance(expr, NIZKInput)):
			result = ArithmeticNIZKInputReq(self, expr, type)
		elif (isinstance(expr, Conditional)):
			result = ConditionalReq(self, expr, type)
		elif (isinstance(expr, CmpLT)):
			result = CmpLTReq(self, expr, type)
		elif (isinstance(expr, CmpLEQ)):
			result = CmpLEQReq(self, expr, type)
                elif (isinstance(expr, CmpEQ)):
                        result = CmpEQReqArith(self, expr, type)
		elif (isinstance(expr, Constant)):
			result = ConstantReq(self, expr, type)
		elif (isinstance(expr, Add)):
			result = AddReq(self, expr, type)
		elif (isinstance(expr, Subtract)):
			# NB trying something new here. expr factory does memoization
			# against existing graph, so rolling up a late expr ensures
			# we'll avoid generating a duplicate Negate. (Not that negate
			# costs any gates; eyeroll.)
			neg_expr = expr.factory.create(Negate, expr.right)
			add_expr = expr.factory.create(Add, expr.left, neg_expr)
			result = AddReq(self, add_expr, type)
		elif (isinstance(expr, Multiply)):
			result = MultiplyReq(self, expr, type)
		elif (isinstance(expr, Negate)):
			result = NegateReq(self, expr, type)
		else:
			result = ReqFactory.make_req(self, expr, type)
		return result
コード例 #2
0
	def make_req(self, expr, type):
		assert(type==BOOLEAN_TYPE)
		if (isinstance(expr, Input)):
			result = BooleanInputReq(self, expr, type)
		elif (isinstance(expr, Conditional)):
			result = ConditionalReq(self, expr, type)
		elif (isinstance(expr, CmpLT)):
			result = CmpReq(self, expr, type)
		elif (isinstance(expr, CmpLEQ)):
			result = CmpReq(self, expr, type)
		elif (isinstance(expr, Constant)):
			result = ConstantReq(self, expr, type)
		elif (isinstance(expr, Add)):
			result = AddReq(self, expr, type)
		elif (isinstance(expr, Subtract)):
			result = SubtractReq(self, expr, type)
		elif (isinstance(expr, Multiply)):
			result = MultiplyReq(self, expr, type)
		elif (isinstance(expr, Negate)):
			result = NegateReq(self, expr, type)
		else:
			result = ReqFactory.make_req(self, expr, type)
		return result
コード例 #3
0
	def __init__(self, output_filename, circuit_inputs, circuit_outputs, bit_width):
		ReqFactory.__init__(self, output_filename, circuit_inputs, circuit_outputs, bit_width)