Class: Cryptos::Der
- Inherits:
-
Struct
- Object
- Struct
- Cryptos::Der
- Includes:
- Utils::Hashes, Utils::Hexas
- Defined in:
- lib/cryptos/der.rb
Instance Attribute Summary collapse
-
#der ⇒ Object
Returns the value of attribute der.
-
#length ⇒ Object
Returns the value of attribute length.
-
#r ⇒ Object
Returns the value of attribute r.
-
#ri ⇒ Object
Returns the value of attribute ri.
-
#rl ⇒ Object
Returns the value of attribute rl.
-
#s ⇒ Object
Returns the value of attribute s.
-
#si ⇒ Object
Returns the value of attribute si.
-
#sighash_type ⇒ Object
Returns the value of attribute sighash_type.
-
#sl ⇒ Object
Returns the value of attribute sl.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(der: 0x30, length: 0x44, ri: 0x02, rl: 0x20, r: nil, si: 0x02, sl: 0x20, s: nil, sighash_type: 0x01) ⇒ Der
constructor
A new instance of Der.
- #serialize ⇒ Object
Methods included from Utils::Hashes
#hash160, #hash256, #ripemd160, #sha256
Methods included from Utils::Hexas
#bignum_to_hex, #bin_to_hex, #byte_to_hex, #bytes_to_hex, #hex_size, #hex_to_little, #int_to_hex, #long_to_hex
Methods included from Utils::Bytes
#bignum_to_bytes, #bytes_to_bignum
Constructor Details
#initialize(der: 0x30, length: 0x44, ri: 0x02, rl: 0x20, r: nil, si: 0x02, sl: 0x20, s: nil, sighash_type: 0x01) ⇒ Der
Returns a new instance of Der.
5 6 7 |
# File 'lib/cryptos/der.rb', line 5 def initialize(der: 0x30, length: 0x44, ri: 0x02, rl: 0x20, r: nil, si: 0x02, sl: 0x20, s: nil, sighash_type: 0x01) super der, length, ri, rl, r, si, sl, s, sighash_type end |
Instance Attribute Details
#der ⇒ Object
Returns the value of attribute der
2 3 4 |
# File 'lib/cryptos/der.rb', line 2 def der @der end |
#length ⇒ Object
Returns the value of attribute length
2 3 4 |
# File 'lib/cryptos/der.rb', line 2 def length @length end |
#r ⇒ Object
Returns the value of attribute r
2 3 4 |
# File 'lib/cryptos/der.rb', line 2 def r @r end |
#ri ⇒ Object
Returns the value of attribute ri
2 3 4 |
# File 'lib/cryptos/der.rb', line 2 def ri @ri end |
#rl ⇒ Object
Returns the value of attribute rl
2 3 4 |
# File 'lib/cryptos/der.rb', line 2 def rl @rl end |
#s ⇒ Object
Returns the value of attribute s
2 3 4 |
# File 'lib/cryptos/der.rb', line 2 def s @s end |
#si ⇒ Object
Returns the value of attribute si
2 3 4 |
# File 'lib/cryptos/der.rb', line 2 def si @si end |
#sighash_type ⇒ Object
Returns the value of attribute sighash_type
2 3 4 |
# File 'lib/cryptos/der.rb', line 2 def sighash_type @sighash_type end |
#sl ⇒ Object
Returns the value of attribute sl
2 3 4 |
# File 'lib/cryptos/der.rb', line 2 def sl @sl end |
Class Method Details
Instance Method Details
#serialize ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cryptos/der.rb', line 9 def serialize r_bytes = bignum_to_bytes(r, 32, false) if r_bytes.first & 0x80 == 128 r_bytes = [0x00] + r_bytes self.length += 1 self.rl += 1 end byte_to_hex(der) + byte_to_hex(length) + byte_to_hex(ri) + byte_to_hex(rl) + bytes_to_hex(r_bytes) + byte_to_hex(si) + byte_to_hex(sl) + bignum_to_hex(s) + byte_to_hex(sighash_type) end |