Class: Lightning::Onion::ChaCha20::OpenSSL
- Inherits:
-
Object
- Object
- Lightning::Onion::ChaCha20::OpenSSL
- Defined in:
- lib/lightning/onion/chacha20/openssl.rb
Class Method Summary collapse
Class Method Details
.chacha20_encrypt(key, counter, nonce, plaintext) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/lightning/onion/chacha20/openssl.rb', line 7 def self.chacha20_encrypt(key, counter, nonce, plaintext) cipher = ::OpenSSL::Cipher.new("ChaCha20") cipher.encrypt cipher.iv = [counter].pack('V*') + nonce cipher.key = key cipher.update(plaintext) + cipher.final end |