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.
Args:
signable_request: request for signing.
signer_id: authority id.
private_key: authority private key to sign with.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/virgil/sdk/client/request_signer.rb', line 73 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.
Args:
signable_request: request for signing.
private_key: private key to sign with.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/virgil/sdk/client/request_signer.rb', line 52 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 |