Class: Bitcoin::BIP324::FSChaCha20
- Inherits:
-
Object
- Object
- Bitcoin::BIP324::FSChaCha20
- Defined in:
- lib/bitcoin/bip324/fs_chacha20.rb
Overview
Rekeying wrapper stream cipher around ChaCha20.
Instance Attribute Summary collapse
-
#block_counter ⇒ Object
Returns the value of attribute block_counter.
-
#chunk_counter ⇒ Object
Returns the value of attribute chunk_counter.
-
#key ⇒ Object
Returns the value of attribute key.
-
#key_stream ⇒ Object
Returns the value of attribute key_stream.
-
#rekey_interval ⇒ Object
readonly
Returns the value of attribute rekey_interval.
Instance Method Summary collapse
-
#decrypt(chunk) ⇒ String
Decrypt a chunk.
-
#encrypt(chunk) ⇒ String
Encrypt a chunk.
-
#initialize(initial_key, rekey_interval = BIP324::REKEY_INTERVAL) ⇒ FSChaCha20
constructor
A new instance of FSChaCha20.
Constructor Details
#initialize(initial_key, rekey_interval = BIP324::REKEY_INTERVAL) ⇒ FSChaCha20
Returns a new instance of FSChaCha20.
80 81 82 83 84 85 86 |
# File 'lib/bitcoin/bip324/fs_chacha20.rb', line 80 def initialize(initial_key, rekey_interval = BIP324::REKEY_INTERVAL) @block_counter = 0 @chunk_counter = 0 @key = initial_key @rekey_interval = rekey_interval @key_stream = '' end |
Instance Attribute Details
#block_counter ⇒ Object
Returns the value of attribute block_counter.
77 78 79 |
# File 'lib/bitcoin/bip324/fs_chacha20.rb', line 77 def block_counter @block_counter end |
#chunk_counter ⇒ Object
Returns the value of attribute chunk_counter.
76 77 78 |
# File 'lib/bitcoin/bip324/fs_chacha20.rb', line 76 def chunk_counter @chunk_counter end |
#key ⇒ Object
Returns the value of attribute key.
74 75 76 |
# File 'lib/bitcoin/bip324/fs_chacha20.rb', line 74 def key @key end |
#key_stream ⇒ Object
Returns the value of attribute key_stream.
78 79 80 |
# File 'lib/bitcoin/bip324/fs_chacha20.rb', line 78 def key_stream @key_stream end |
#rekey_interval ⇒ Object (readonly)
Returns the value of attribute rekey_interval.
75 76 77 |
# File 'lib/bitcoin/bip324/fs_chacha20.rb', line 75 def rekey_interval @rekey_interval end |
Instance Method Details
#decrypt(chunk) ⇒ String
Decrypt a chunk
98 99 100 |
# File 'lib/bitcoin/bip324/fs_chacha20.rb', line 98 def decrypt(chunk) crypt(chunk) end |
#encrypt(chunk) ⇒ String
Encrypt a chunk
91 92 93 |
# File 'lib/bitcoin/bip324/fs_chacha20.rb', line 91 def encrypt(chunk) crypt(chunk) end |