mirror of
https://github.com/number571/go-peer.git
synced 2026-09-14 11:05:42 +05:00
update
This commit is contained in:
parent
9c747f634f
commit
79100b5914
@ -8,6 +8,10 @@
|
||||
|
||||
- Update `cmd/hidden_lake/adapters`: producer, consumer apps -> one app
|
||||
|
||||
### BUG FIXES
|
||||
|
||||
- Update `pkg/network/message`: fix GetVoid bytes method
|
||||
|
||||
## v1.6.8
|
||||
|
||||
*April 07, 2024*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -13,12 +13,18 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// Salt = 128bit
|
||||
cSaltSize = 16
|
||||
|
||||
// Salt(cipher) + Salt(auth) + IV + Hash + Proof + PayloadSize + PayloadHead
|
||||
cSaltSize = 16
|
||||
CMessageHeadSize = 2*cSaltSize +
|
||||
CMessageHeadSize = 0 +
|
||||
cSaltSize +
|
||||
cSaltSize +
|
||||
symmetric.CAESBlockSize +
|
||||
hashing.CSHA256Size +
|
||||
3*encoding.CSizeUint64
|
||||
encoding.CSizeUint64 +
|
||||
encoding.CSizeUint64 +
|
||||
encoding.CSizeUint64
|
||||
)
|
||||
|
||||
var (
|
||||
@ -131,17 +137,20 @@ func LoadMessage(pSett ISettings, pData interface{}) (IMessage, error) {
|
||||
return nil, ErrInvalidProofOfWork
|
||||
}
|
||||
|
||||
payloadVoidBytes := pphpBytes[hashIndex:]
|
||||
if (payloadLength + encoding.CSizeUint64) > uint64(len(payloadVoidBytes)) {
|
||||
lenPayloadVoidBytes := pphpBytes[hashIndex:]
|
||||
if (payloadLength + encoding.CSizeUint64) > uint64(len(lenPayloadVoidBytes)) {
|
||||
return nil, ErrInvalidPayloadSize
|
||||
}
|
||||
|
||||
newHash := getAuthHash(pSett.GetNetworkKey(), authSaltBytes, payloadVoidBytes)
|
||||
newHash := getAuthHash(pSett.GetNetworkKey(), authSaltBytes, lenPayloadVoidBytes)
|
||||
if !bytes.Equal(hash, newHash) {
|
||||
return nil, ErrInvalidAuthHash
|
||||
}
|
||||
|
||||
payloadBytes := payloadVoidBytes[encoding.CSizeUint64:][:payloadLength]
|
||||
payloadVoidBytes := lenPayloadVoidBytes[encoding.CSizeUint64:]
|
||||
payloadBytes := payloadVoidBytes[:payloadLength]
|
||||
voidBytes := payloadVoidBytes[payloadLength:]
|
||||
|
||||
payload := payload.LoadPayload(payloadBytes)
|
||||
if payload == nil {
|
||||
return nil, ErrDecodePayload
|
||||
@ -154,7 +163,7 @@ func LoadMessage(pSett ISettings, pData interface{}) (IMessage, error) {
|
||||
},
|
||||
fEncPPHP: encPPHPBytes,
|
||||
fHash: hash,
|
||||
fVoid: payloadVoidBytes[payloadLength:],
|
||||
fVoid: voidBytes,
|
||||
fProof: proof,
|
||||
fPayload: payload,
|
||||
}, nil
|
||||
|
||||
@ -66,6 +66,11 @@ func TestMessage(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
if (len(msg.ToBytes()) - len(voidBytes)) != len(msg.GetPayload().GetBody())+CMessageHeadSize {
|
||||
t.Error("invalid message size in bytes with void")
|
||||
return
|
||||
}
|
||||
|
||||
payloadSize := encoding.Uint64ToBytes(uint64(len(pld.ToBytes())))
|
||||
payloadRandBytes := bytes.Join(
|
||||
[][]byte{payloadSize[:], pld.ToBytes(), voidBytes},
|
||||
|
||||
21486
test/result/coverage.out
21486
test/result/coverage.out
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user