Class: ECDSA::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/ecdsa/signature.rb

Overview

Instances of this class represents ECDSA signatures, which are simply a pair of integers named ‘r` and `s`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(r, s) ⇒ Signature

Returns a new instance of Signature.

Parameters:

  • r (Integer)

    the value of r.

  • s (Integer)

    the value of s.



13
14
15
16
17
# File 'lib/ecdsa/signature.rb', line 13

def initialize(r, s)
  @r, @s = r, s
  r.is_a?(Integer) or raise ArgumentError, 'r is not an integer.'
  s.is_a?(Integer) or raise ArgumentError, 's is not an integer.'
end

Instance Attribute Details

#rInteger (readonly)

Returns:

  • (Integer)


6
7
8
# File 'lib/ecdsa/signature.rb', line 6

def r
  @r
end

#sInteger (readonly)

Returns:

  • (Integer)


9
10
11
# File 'lib/ecdsa/signature.rb', line 9

def s
  @s
end

Instance Method Details

#componentsArray

Returns an array containing ‘r` first and `s` second.

Returns:

  • (Array)


21
22
23
# File 'lib/ecdsa/signature.rb', line 21

def components
  [r, s]
end