mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-08 03:58:05 +02:00
flesh out comment for generateHeaderPadding
This commit is contained in:
parent
4efb397ade
commit
037b1f47ee
19
sphinx.go
19
sphinx.go
@ -179,15 +179,16 @@ func GenerateSphinxHeader(dest []byte, identifier [securityParameter]byte,
|
||||
return header, hopSharedSecrets, nil
|
||||
}
|
||||
|
||||
// generateHeaderPadding...
|
||||
// At each step, we add 2*securityParameter padding of zeroes, concatenate it
|
||||
// to the previous filler, then decrypt it (XOR) with the secret key of the
|
||||
// current hop. When encrypting the mix header we essentially do the reverse of
|
||||
// this operation: we "encrypt" the padding, and drop 2*k number of zeroes. As
|
||||
// nodes process the mix header they add the padding (2*k) and then decrypt
|
||||
// eventually leaving only the original "filler" bytes produced by this function
|
||||
// at the last hop. Using this methodology, the size of the mix header stays
|
||||
// constant at each hop.
|
||||
// generateHeaderPadding derives the bytes for padding the mix header to ensure
|
||||
// it remains fixed sized throughout route transit. At each step, we add
|
||||
// 2*securityParameter padding of zeroes, concatenate it to the previous
|
||||
// filler, then decrypt it (XOR) with the secret key of the current hop. When
|
||||
// encrypting the mix header we essentially do the reverse of this operation:
|
||||
// we "encrypt" the padding, and drop 2*k number of zeroes. As nodes process
|
||||
// the mix header they add the padding (2*k) in order to check the MAC and
|
||||
// decrypt the next routing information eventually leaving only the original
|
||||
// "filler" bytes produced by this function at the last hop. Using this
|
||||
// methodology, the size of the mix header stays constant at each hop.
|
||||
func generateHeaderPadding(numHops int, sharedSecrets [][sharedSecretSize]byte) []byte {
|
||||
var filler []byte
|
||||
for i := 1; i < numHops; i++ {
|
||||
|
Loading…
x
Reference in New Issue
Block a user