lib/stribog/create_hash.rb in stribog-0.1.1 vs lib/stribog/create_hash.rb in stribog-0.1.2

- old
+ new

@@ -51,21 +51,22 @@ "digest length must be equal to 256 or 512, not #{digest_length}" end end def compact_message(sum:, n:, message_vector:, hash_vector:, message_head: nil) + current_vector = message_head || message_vector if message_vector.size < HASH_LENGTH || !message_head.nil? && message_head.size < HASH_LENGTH - return { sum: sum, n: n, message_vector: message_head || message_vector, + return { sum: sum, n: n, message_vector: current_vector, hash_vector: hash_vector } end compact_message( - sum: addition_in_ring_to_binary(sum.to_dec, message_vector.to_dec), - n: addition_in_ring_to_binary(n.to_dec, slice_message_tail(message_vector).size), + sum: addition_in_ring_to_binary(sum.to_dec, current_vector.to_dec), + n: addition_in_ring_to_binary(n.to_dec, slice_message_tail(current_vector).size), message_vector: message_vector, - hash_vector: compress(n: n, message: slice_message_tail(message_vector), + hash_vector: compress(n: n, message: slice_message_tail(current_vector), hash_vector: hash_vector), - message_head: slice_message_head(message_vector) + message_head: slice_message_head(current_vector) ) end def slice_message_head(message_vector) binary_vector_from_array(message_vector.vector[0...-HASH_LENGTH])