Class: Bitcoin::Script
- Inherits:
-
Object
- Object
- Bitcoin::Script
- Defined in:
- lib/coin-op/bit.rb
Instance Attribute Summary collapse
-
#chunks ⇒ Object
readonly
Returns the value of attribute chunks.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Class Method Summary collapse
-
.compare_big_endian(c1, c2) ⇒ Object
Compares two arrays of bytes.
-
.is_low_der_signature?(sig) ⇒ Boolean
Loosely correlates with IsLowDERSignature() from interpreter.cpp.
Instance Attribute Details
#chunks ⇒ Object (readonly)
Returns the value of attribute chunks.
191 192 193 |
# File 'lib/coin-op/bit.rb', line 191 def chunks @chunks end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
191 192 193 |
# File 'lib/coin-op/bit.rb', line 191 def debug @debug end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
191 192 193 |
# File 'lib/coin-op/bit.rb', line 191 def raw @raw end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
191 192 193 |
# File 'lib/coin-op/bit.rb', line 191 def stack @stack end |
Class Method Details
.compare_big_endian(c1, c2) ⇒ Object
Compares two arrays of bytes
215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/coin-op/bit.rb', line 215 def self.compare_big_endian(c1, c2) c1, c2 = c1.dup, c2.dup # Clone the arrays while c1.size > c2.size return 1 if c1.shift > 0 end while c2.size > c1.size return -1 if c2.shift > 0 end c1.size.times{|idx| return c1[idx] - c2[idx] if c1[idx] != c2[idx] } 0 end |
.is_low_der_signature?(sig) ⇒ Boolean
Loosely correlates with IsLowDERSignature() from interpreter.cpp
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/coin-op/bit.rb', line 194 def self.is_low_der_signature?(sig) s = sig.unpack("C*") length_r = s[3] length_s = s[5+length_r] s_val = s.slice(6 + length_r, length_s) # If the S value is above the order of the curve divided by two, its # complement modulo the order could have been used instead, which is # one byte shorter when encoded correctly. max_mod_half_order = [ 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x5d,0x57,0x6e,0x73,0x57,0xa4,0x50,0x1d, 0xdf,0xe9,0x2f,0x46,0x68,0x1b,0x20,0xa0] compare_big_endian(s_val, [0]) > 0 && compare_big_endian(s_val, max_mod_half_order) <= 0 end |