fix: resolve P2P data plane decrypt failure and improve test environment

- Fix key derivation in both sdk/agent.go and internal/vl1/noise.go:
  sort public keys before hashing, use shared key for send/recv
- Adjust docker-compose port mappings to 7150-7153 range (within 7000-7200)
- Add GOPROXY env to Dockerfiles for Go module download in restricted networks
- Verified: all 3 clients connect with 2 peers each, zero decrypt errors
This commit is contained in:
xieyao
2026-06-17 15:19:54 +08:00
parent e7f1c8e831
commit 196ec09e55
5 changed files with 21 additions and 31 deletions

View File

@@ -1,6 +1,7 @@
package vl1
import (
"bytes"
"crypto/cipher"
"crypto/rand"
"encoding/binary"
@@ -34,22 +35,17 @@ func NewNoiseCipher(sendKey, recvKey [32]byte) *NoiseCipher {
}
func DeriveKeysFromPSK(psk string, localPub, remotePub []byte) ([32]byte, [32]byte) {
first, second := localPub, remotePub
if bytes.Compare(localPub, remotePub) > 0 {
first, second = remotePub, localPub
}
h := sha3.New256()
h.Write([]byte(psk))
h.Write(localPub)
h.Write(remotePub)
sum := h.Sum(nil)
var sendKey, recvKey [32]byte
copy(sendKey[:], sum[:32])
h.Reset()
h.Write(sum)
h.Write([]byte("reverse"))
rev := h.Sum(nil)
copy(recvKey[:], rev[:32])
return sendKey, recvKey
h.Write(first)
h.Write(second)
var key [32]byte
copy(key[:], h.Sum(nil))
return key, key
}
func (nc *NoiseCipher) Encrypt(plaintext []byte) ([]byte, error) {