mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-02 00:52:13 +02:00
properly calculate filler bytes for header padding
* Number of filler bytes should decrease for each hop in the path. Not remain constant.
This commit is contained in:
parent
7d3ce833a7
commit
e7def0be20
@ -203,10 +203,10 @@ func NewMixHeader(dest LightningAddress, identifier [securityParameter]byte,
|
||||
// "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 {
|
||||
fillerSize := (2*(numMaxHops-1) + 3) * securityParameter
|
||||
filler := make([]byte, fillerSize)
|
||||
filler := make([]byte, 2*(numHops-1)*securityParameter)
|
||||
|
||||
for i := 1; i < numHops; i++ {
|
||||
totalFillerSize := (2*(numMaxHops-i) + 3) * securityParameter
|
||||
padding := bytes.Repeat([]byte{0}, 2*securityParameter)
|
||||
|
||||
var tempBuf bytes.Buffer
|
||||
@ -216,7 +216,7 @@ func generateHeaderPadding(numHops int, sharedSecrets [][sharedSecretSize]byte)
|
||||
streamBytes := generateCipherStream(generateKey("rho", sharedSecrets[i-1]),
|
||||
numStreamBytes)
|
||||
|
||||
xor(filler, tempBuf.Bytes(), streamBytes[fillerSize:])
|
||||
xor(filler, tempBuf.Bytes(), streamBytes[totalFillerSize:])
|
||||
}
|
||||
|
||||
return filler
|
||||
|
Loading…
x
Reference in New Issue
Block a user