Class: PQCrypto::Signature::SecretKey
- Inherits:
-
Object
- Object
- PQCrypto::Signature::SecretKey
- Defined in:
- lib/pq_crypto/signature.rb
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(algorithm, bytes) ⇒ SecretKey
constructor
A new instance of SecretKey.
- #sign(message) ⇒ Object
- #to_bytes ⇒ Object
- #to_pqc_container_der ⇒ Object
- #to_pqc_container_pem ⇒ Object
- #wipe! ⇒ Object
Constructor Details
#initialize(algorithm, bytes) ⇒ SecretKey
Returns a new instance of SecretKey.
151 152 153 154 155 |
# File 'lib/pq_crypto/signature.rb', line 151 def initialize(algorithm, bytes) @algorithm = algorithm @bytes = String(bytes).b validate_length! end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
149 150 151 |
# File 'lib/pq_crypto/signature.rb', line 149 def algorithm @algorithm end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
180 181 182 |
# File 'lib/pq_crypto/signature.rb', line 180 def ==(other) other.is_a?(SecretKey) && other.algorithm == algorithm && other.to_bytes == @bytes end |
#hash ⇒ Object
186 187 188 |
# File 'lib/pq_crypto/signature.rb', line 186 def hash [self.class, algorithm, @bytes].hash end |
#sign(message) ⇒ Object
169 170 171 172 173 |
# File 'lib/pq_crypto/signature.rb', line 169 def sign() PQCrypto.__send__(:native_sign, String().b, @bytes) rescue ArgumentError => e raise InvalidKeyError, e. end |
#to_bytes ⇒ Object
157 158 159 |
# File 'lib/pq_crypto/signature.rb', line 157 def to_bytes @bytes.dup end |
#to_pqc_container_der ⇒ Object
161 162 163 |
# File 'lib/pq_crypto/signature.rb', line 161 def to_pqc_container_der Serialization.secret_key_to_pqc_container_der(@algorithm, @bytes) end |
#to_pqc_container_pem ⇒ Object
165 166 167 |
# File 'lib/pq_crypto/signature.rb', line 165 def to_pqc_container_pem Serialization.secret_key_to_pqc_container_pem(@algorithm, @bytes) end |
#wipe! ⇒ Object
175 176 177 178 |
# File 'lib/pq_crypto/signature.rb', line 175 def wipe! PQCrypto.secure_wipe(@bytes) self end |