Class: Virgil::SDK::Client::RequestSigner
- Inherits:
-
Object
- Object
- Virgil::SDK::Client::RequestSigner
- Defined in:
- lib/virgil/sdk/client/request_signer.rb
Overview
Class used for signing high_level requests.
Instance Attribute Summary collapse
-
#crypto ⇒ Object
readonly
Returns the value of attribute crypto.
Instance Method Summary collapse
-
#authority_sign(signable_request, signer_id, private_key) ⇒ Object
Sign passed request with authority private key.
-
#initialize(crypto) ⇒ RequestSigner
constructor
Constructs new RequestSigner object.
-
#self_sign(signable_request, private_key) ⇒ Object
Sign passed request with private key.
Constructor Details
#initialize(crypto) ⇒ RequestSigner
Constructs new RequestSigner object
43 44 45 |
# File 'lib/virgil/sdk/client/request_signer.rb', line 43 def initialize(crypto) @crypto = crypto end |
Instance Attribute Details
#crypto ⇒ Object (readonly)
Returns the value of attribute crypto
40 41 42 |
# File 'lib/virgil/sdk/client/request_signer.rb', line 40 def crypto @crypto end |
Instance Method Details
#authority_sign(signable_request, signer_id, private_key) ⇒ Object
Sign passed request with authority private key.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/virgil/sdk/client/request_signer.rb', line 69 def (signable_request, signer_id, private_key) fingerprint = self.crypto.calculate_fingerprint( signable_request.snapshot ) signature = self.crypto.sign( fingerprint.value, private_key ) signable_request.sign_with( signer_id, signature ) end |
#self_sign(signable_request, private_key) ⇒ Object
Sign passed request with private key.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/virgil/sdk/client/request_signer.rb', line 50 def self_sign(signable_request, private_key) fingerprint = self.crypto.calculate_fingerprint( signable_request.snapshot ) signature = self.crypto.sign( fingerprint.value, private_key ) signable_request.sign_with( fingerprint.to_hex, signature ) end |