Class: Zold::Signature

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

Overview

A signature

Instance Method Summary collapse

Instance Method Details

#sign(pvt, id, txn) ⇒ Object

Sign the trasnsaction and return the signature.

pvt

Private RSA key

id

Paying wallet ID

txn

The transaction


38
39
40
41
42
43
# File 'lib/zold/signature.rb', line 38

def sign(pvt, id, txn)
  raise 'pvt must be of type Key' unless pvt.is_a?(Key)
  raise 'id must be of type Id' unless id.is_a?(Id)
  raise 'txn must be of type Txn' unless txn.is_a?(Txn)
  pvt.sign(body(id, txn))
end

#valid?(pub, id, txn) ⇒ Boolean

The transaction is valid? Returns true if it is.

pub

Public key of the wallet

id

Paying wallet ID

txn: Transaction to validate

Returns:

  • (Boolean)

49
50
51
52
53
54
# File 'lib/zold/signature.rb', line 49

def valid?(pub, id, txn)
  raise 'pub must be of type Key' unless pub.is_a?(Key)
  raise 'id must be of type Id' unless id.is_a?(Id)
  raise 'txn must be of type Txn' unless txn.is_a?(Txn)
  pub.verify(txn.sign, body(id, txn))
end