@@ -13,7 +13,7 @@ import (
1313// onionEncrypt obfuscates the data with compliance with BOLT#4. As we use a
1414// stream cipher, calling onionEncrypt on an already encrypted piece of data
1515// will decrypt it.
16- func onionEncrypt (sharedSecret [ sha256 . Size ] byte , data []byte ) []byte {
16+ func onionEncrypt (sharedSecret * Hash256 , data []byte ) []byte {
1717
1818 p := make ([]byte , len (data ))
1919
@@ -27,7 +27,7 @@ func onionEncrypt(sharedSecret [sha256.Size]byte, data []byte) []byte {
2727// OnionErrorEncrypter is a struct that's used to implement onion error
2828// encryption as defined within BOLT0004.
2929type OnionErrorEncrypter struct {
30- sharedSecret [ sha256 . Size ] byte
30+ sharedSecret Hash256
3131}
3232
3333// NewOnionErrorEncrypter creates new instance of the onion encryper backed by
@@ -59,14 +59,14 @@ func NewOnionErrorEncrypter(router *Router,
5959// failure and its origin.
6060func (o * OnionErrorEncrypter ) EncryptError (initial bool , data []byte ) []byte {
6161 if initial {
62- umKey := generateKey ("um" , o .sharedSecret )
62+ umKey := generateKey ("um" , & o .sharedSecret )
6363 hash := hmac .New (sha256 .New , umKey [:])
6464 hash .Write (data )
6565 h := hash .Sum (nil )
6666 data = append (h , data ... )
6767 }
6868
69- return onionEncrypt (o .sharedSecret , data )
69+ return onionEncrypt (& o .sharedSecret , data )
7070}
7171
7272// Encode writes the encrypter's shared secret to the provided io.Writer.
@@ -180,15 +180,15 @@ func (o *OnionErrorDecrypter) DecryptError(encryptedData []byte) (*btcec.PublicK
180180 var (
181181 sender * btcec.PublicKey
182182 msg []byte
183- dummySecret [ sha256 . Size ] byte
183+ dummySecret Hash256
184184 )
185185 copy (dummySecret [:], bytes .Repeat ([]byte {1 }, 32 ))
186186
187187 // We'll iterate a constant amount of hops to ensure that we don't give
188188 // away an timing information pertaining to the position in the route
189189 // that the error emanated from.
190190 for i := 0 ; i < NumMaxHops ; i ++ {
191- var sharedSecret [ sha256 . Size ] byte
191+ var sharedSecret Hash256
192192
193193 // If we've already found the sender, then we'll use our dummy
194194 // secret to continue decryption attempts to fill out the rest
@@ -202,7 +202,7 @@ func (o *OnionErrorDecrypter) DecryptError(encryptedData []byte) (*btcec.PublicK
202202
203203 // With the shared secret, we'll now strip off a layer of
204204 // encryption from the encrypted error payload.
205- encryptedData = onionEncrypt (sharedSecret , encryptedData )
205+ encryptedData = onionEncrypt (& sharedSecret , encryptedData )
206206
207207 // Next, we'll need to separate the data, from the MAC itself
208208 // so we can reconstruct and verify it.
@@ -211,7 +211,7 @@ func (o *OnionErrorDecrypter) DecryptError(encryptedData []byte) (*btcec.PublicK
211211
212212 // With the data split, we'll now re-generate the MAC using its
213213 // specified key.
214- umKey := generateKey ("um" , sharedSecret )
214+ umKey := generateKey ("um" , & sharedSecret )
215215 h := hmac .New (sha256 .New , umKey [:])
216216 h .Write (data )
217217
0 commit comments