class Zold::Signature
A signature
Public Class Methods
new(network = 'test')
click to toggle source
# File lib/zold/signature.rb, line 36 def initialize(network = 'test') @network = network end
Public Instance Methods
sign(pvt, id, txn)
click to toggle source
Sign the trasnsaction and return the signature.
pvt
-
Private RSA key
id
-
Paying wallet ID
txn
-
The transaction
# File lib/zold/signature.rb, line 44 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)
click to toggle source
The transaction is valid? Returns true if it is.
pub
-
Public key of the wallet
id
-
Paying wallet ID
txn
: Transaction to validate
# File lib/zold/signature.rb, line 55 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)) && (@network != Wallet::MAINET || !id.root? || pub.root?) end