Skip to content

Commit

Permalink
fix: styling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wout committed Apr 19, 2024
1 parent 5a97c9e commit fa0bd0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/bech32/base.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ module Bech32

private def prefix_check(prefix : String)
words = prefix.to_slice
check = words.reduce(1) do |memo, w|
w >= 33 && w <= 126 || raise PrefixException.new("Invalid prefix '#{prefix}'")
polymod_step(memo) ^ (w >> 5)
check = words.reduce(1) do |memo, word|
word >= 33 && word <= 126 ||
raise PrefixException.new("Invalid prefix '#{prefix}'")
polymod_step(memo) ^ (word >> 5)
end
words.reduce(polymod_step(check)) do |memo, w|
polymod_step(memo) ^ (w & 31)
words.reduce(polymod_step(check)) do |memo, word|
polymod_step(memo) ^ (word & 31)
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/bech32/decode.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module Bech32
prefix, data, upcase = sanitize_and_parse_parts(value, limit)
check, data_size, words = prefix_check(prefix), data.size, IO::Memory.new

data.each_char.with_index do |c, i|
raise CharException.new("Unknown character #{c}") unless v = ALPHABET_MAP[c]?
data.each_char.with_index do |char, i|
raise CharException.new("Unknown character #{char}") unless v = ALPHABET_MAP[char]?
check = polymod_step(check) ^ v
words.write_byte v if i + 6 < data_size
end
Expand Down

0 comments on commit fa0bd0d

Please sign in to comment.