INNER CODE UNIT · Python

ineq_weight

rkm0959/Inequality_Solving_with_CVP · Example Challenge 6 - GoogleCTF 2021 - H1/solve_challenge_6.py:71

		ineq_weight = weight if lb[i] == ub[i] else max_diff // (ub[i] - lb[i])
		applied_weights.append(ineq_weight)
		for j in range(num_var):
			mat[j, i] *= ineq_weight
		lb[i] *= ineq_weight
		ub[i] *= ineq_weight

	# Solve CVP
	target = vector([(lb[i] + ub[i]) // 2 for i in range(num_ineq)])
	result = Babai_CVP(mat, target)

	for i in range(num_ineq):
		if (lb[i] <= result[i] <= ub[i]) == False:
			print("Fail : inequality does not hold after solving")
			break
    
    	# recover x
	fin = None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…