Commit 81f0c5f9 authored by Luc Libralesso's avatar Luc Libralesso
Browse files

update writers

parent 399c5be6
......@@ -14,7 +14,7 @@ require "pry"
class TestWriterGraphviz < Minitest::Unit::TestCase
def test_aes128()
# create dag
nb_rounds = 4
nb_rounds = 3
dag = AES128_Dag.new(nb_rounds = nb_rounds)
# shave dag
atoms,operators = *shave_dag(dag.atoms, dag.operators)
......@@ -39,9 +39,15 @@ class TestWriterGraphviz < Minitest::Unit::TestCase
puts("\tstarting with #{xor_clauses.length} clauses")
xor_clauses = generate_xors(atoms, operators, xor_clauses, max_size=4)
puts("\tnow having: #{xor_clauses.length} clauses")
xor_clauses_sizes = [0,0,0,0,0,0,0]
xor_clauses.each do |xor|
xor_clauses_sizes[xor.length] += 1
model.add_constraints(Diff1.new(*(xor.map{|v| variable_dict.fetch(v,v)})))
end
puts("\tXOReq sizes:")
for i in 1..5
puts("\t\t#{i}\t#{xor_clauses_sizes[i]}")
end
file = File.open("aes128_#{nb_rounds}.mzn", "w")
file.puts(Minizinc.new.generate_code(model))
......
......@@ -38,6 +38,7 @@ def generate_xors(atoms, operators, custom_xors, max_size=4)
if c.length >= 1 && c.length <= max_size
nb_diffs = c.filter{|v| v.name.name.start_with?("diff_")}.length
if nb_diffs <= 1 && !new_xors.include?(c)
# if !new_xors.include?(c)
new_xors.add(c)
new_xor_to_check.add(c)
to_continue = true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment