Class: IOTA::Crypto::Hmac
- Inherits:
-
Object
- Object
- IOTA::Crypto::Hmac
- Defined in:
- lib/iota/crypto/hmac.rb
Constant Summary collapse
- ROUNDS =
27
Instance Method Summary collapse
- #addHMAC(bundle) ⇒ Object
-
#initialize(key) ⇒ Hmac
constructor
A new instance of Hmac.
Constructor Details
Instance Method Details
#addHMAC(bundle) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/iota/crypto/hmac.rb', line 10 def addHMAC(bundle) curl = Curl.new(ROUNDS) (0...bundle.bundle.length).step(1) do |i| if bundle.bundle[i].value > 0 bundleHashTrits = Converter.trits(bundle.bundle[i].bundle) hmac = Array.new(243, 0) curl.reset curl.absorb(@key) curl.absorb(bundleHashTrits) curl.squeeze(hmac) hmacTrytes = Converter.trytes(hmac) bundle.bundle[i].signatureMessageFragment = hmacTrytes + bundle.bundle[i].signatureMessageFragment[81...2187] end end end |