Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Luc Libralesso
cryptodag
Commits
3d9f5516
Commit
3d9f5516
authored
Dec 26, 2020
by
Luc Libralesso
Browse files
rewrite graphviz viz interface + add graphviz output to test model shaving
parent
d3a947b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests/writers/graphviz.rb
View file @
3d9f5516
...
...
@@ -14,7 +14,7 @@ class TestWriterGraphviz < Minitest::Unit::TestCase
def
test_a
()
dag
=
Midori128_Dag
.
new
(
nb_rounds
=
3
)
# p get_graphviz(dag)
writefile_graphviz
(
dag
,
"test.dot"
)
writefile_graphviz
(
dag
.
atoms
(),
dag
.
operators
()
,
"test.dot"
)
assert_equal
(
true
,
true
)
end
end
\ No newline at end of file
writers/abstract_constraints_atomic.rb
View file @
3d9f5516
...
...
@@ -2,11 +2,14 @@ require_relative '../cryptodag.rb'
require_relative
'../operators/elementary.rb'
require_relative
'../constraints/all.rb'
require_relative
'./graphviz_atomic.rb'
def
get_abstract_constraint_model
(
dag
)
atoms
=
dag
.
atoms
()
operators
=
dag
.
operators
()
# shave dag to remove useless inputs and outputs
atoms2
,
operators2
=
shave_dag
(
atoms
,
operators
)
atoms2
,
operators2
=
*
shave_dag
(
atoms
,
operators
)
writefile_graphviz
(
atoms2
,
operators2
,
"test.dot"
)
# create model
model
=
create_abstract_model
(
atoms
,
operators
)
return
model
...
...
writers/graphviz_atomic.rb
View file @
3d9f5516
...
...
@@ -18,7 +18,7 @@ def get_shorthand_op_classname(c)
end
end
def
get_graphviz
(
dag
)
def
get_graphviz
(
atoms
,
operators
)
res
=
""
res
+=
"digraph {
\n
"
# digraph options
...
...
@@ -28,7 +28,6 @@ def get_graphviz(dag)
# display operators
op_to_id
=
{}
id_to_op
=
{}
operators
=
dag
.
operators
()
id
=
0
operators
.
each
do
|
op
|
op_to_id
[
op
]
=
id
...
...
@@ -40,7 +39,6 @@ def get_graphviz(dag)
atom_to_id
=
{}
id_to_atom
=
{}
id
=
0
atoms
=
dag
.
atoms
()
atoms
.
each
do
|
atom
|
if
!
atom_to_id
.
key?
(
atom
)
atom_to_id
[
atom
]
=
id
...
...
@@ -62,8 +60,8 @@ def get_graphviz(dag)
end
def
writefile_graphviz
(
dag
,
filename
)
def
writefile_graphviz
(
atoms
,
operators
,
filename
)
file
=
File
.
open
(
filename
,
"w"
)
file
.
puts
(
get_graphviz
(
dag
))
file
.
puts
(
get_graphviz
(
atoms
,
operators
))
file
.
close
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment