Class: Virgil::Crypto::VirgilCardCrypto
- Inherits:
-
Object
- Object
- Virgil::Crypto::VirgilCardCrypto
- Defined in:
- lib/virgil/crypto/card_crypto.rb
Overview
Provides a cryptographic operations in applications, such as hashing, signature generation and verification, and encryption and decryption.
Instance Attribute Summary collapse
-
#virgil_crypto ⇒ Object
readonly
Returns the value of attribute virgil_crypto.
Instance Method Summary collapse
-
#export_public_key(public_key) ⇒ Crypto::Bytes
Exports the Public key into material representation.
-
#generate_SHA512(bytes) ⇒ Crypto::Bytes
Calculates the fingerprint.
-
#generate_signature(bytes, private_key) ⇒ Crypto::Bytes
Signs the specified data using Private key.
-
#import_public_key(key_bytes) ⇒ VirgilPublicKey
Imports the Public key from material representation.
-
#initialize ⇒ VirgilCardCrypto
constructor
Initializes a new instance of the [VirgilCardCrypto] class.
-
#verify_signature(signature, bytes, signer_public_key) ⇒ Boolean
Verifies the specified signature using original data and signer's public key.
Constructor Details
#initialize ⇒ VirgilCardCrypto
Initializes a new instance of the [VirgilCardCrypto] class.
43 44 45 |
# File 'lib/virgil/crypto/card_crypto.rb', line 43 def initialize @virgil_crypto = VirgilCrypto.new end |
Instance Attribute Details
#virgil_crypto ⇒ Object (readonly)
Returns the value of attribute virgil_crypto.
40 41 42 |
# File 'lib/virgil/crypto/card_crypto.rb', line 40 def virgil_crypto @virgil_crypto end |
Instance Method Details
#export_public_key(public_key) ⇒ Crypto::Bytes
Exports the Public key into material representation.
69 70 71 |
# File 'lib/virgil/crypto/card_crypto.rb', line 69 def export_public_key(public_key) @virgil_crypto.export_public_key(public_key) end |
#generate_SHA512(bytes) ⇒ Crypto::Bytes
Calculates the fingerprint.
110 111 112 |
# File 'lib/virgil/crypto/card_crypto.rb', line 110 def generate_SHA512(bytes) @virgil_crypto.generate_hash(bytes) end |
#generate_signature(bytes, private_key) ⇒ Crypto::Bytes
Signs the specified data using Private key.
85 86 87 |
# File 'lib/virgil/crypto/card_crypto.rb', line 85 def generate_signature(bytes, private_key) @virgil_crypto.generate_signature(bytes, private_key) end |
#import_public_key(key_bytes) ⇒ VirgilPublicKey
Imports the Public key from material representation. representation bytes.
56 57 58 |
# File 'lib/virgil/crypto/card_crypto.rb', line 56 def import_public_key(key_bytes) @virgil_crypto.import_public_key(key_bytes) end |
#verify_signature(signature, bytes, signer_public_key) ⇒ Boolean
Verifies the specified signature using original data and signer's public key. key for verification. bytes using Public key.
include Virgil::Crypto
card_crypto = VirgilCardCrypto.new
public_key = crypto.import_public_key(exported_public_key)
data = Bytes.from_string('Hello Bob, How are you?')
is_valid = card_crypto.verify_signature(signature, data, public_key)
103 104 105 |
# File 'lib/virgil/crypto/card_crypto.rb', line 103 def verify_signature(signature, bytes, signer_public_key) @virgil_crypto.verify_signature(signature, bytes, signer_public_key) end |