Commit 5577de89 authored by Luc Libralesso's avatar Luc Libralesso
Browse files

correct bug in subbytes node + add test for subbytesnode

parent 342b0e33
......@@ -16,12 +16,6 @@ class SubBytesNode < CryptoDagNode
@subtable
))
end
@y_size.times do |y|
@x_size.times do |x|
row, col = permuted_indices(y, x)
operators.push(EqualityOperator.new(input[row][col], output[y][x]))
end
end
super(inputs: [input], outputs: [output], operators: operators, name: name)
super(inputs: [input], outputs: [output], operators: operators, name: name)
end
end
#!/usr/bin/ruby
## test XorNode
require_relative "../../nodes/input.rb"
require_relative "../../nodes/subbytes.rb"
require_relative "../../simulate_cryptodag.rb"
require "minitest/autorun"
require "pry"
class TestExecXorNode < Minitest::Unit::TestCase
def test_simple22s()
subtable_1 = 256.times.map{|i|(i*2) % 256}.to_a
subtable_2 = 256.times.map{|i|(i+1) % 256}.to_a
a_node = InputNode.new(name:"input_a",dimensions:[2,2])
s1_node = SubBytesNode.new(name:"s1", input:a_node.outputs[0], subtable:subtable_1)
s2_node = SubBytesNode.new(name:"s2", input:s1_node.outputs[0], subtable:subtable_2)
computed_outputs = compute_set_of_operators(
[0,1,2,3], # input values
a_node.flatten_output(0), # input variables
s2_node.flatten_output(0), # output variables
s1_node.operators+s2_node.operators
)
assert_equal(computed_outputs, [1,3,5,7])
end
end
\ No newline at end of file
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