Add SendEthicalPacket method for secure packet sending
Implemented SendEthicalPacket method to send packets securely using a shared secret.
This commit is contained in:
parent
6ffcb353c0
commit
dbd36374b2
1 changed files with 22 additions and 0 deletions
|
|
@ -704,3 +704,25 @@ func (r *PeerRegistry) load() error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Example usage inside a connection handler
|
||||||
|
func (n *NodeManager) SendEthicalPacket(peerID string, intent uint8, data []byte) error {
|
||||||
|
// 1. Get the shared secret for this specific peer (derived from ECDH)
|
||||||
|
secret, err := n.DeriveSharedSecret(peerID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Construct the UEPS frame
|
||||||
|
// Intent 0x20 = e.g., "Distributed Compute"
|
||||||
|
pkt := ueps.NewBuilder(intent, data)
|
||||||
|
|
||||||
|
// 3. Seal it
|
||||||
|
wireBytes, err := pkt.MarshalAndSign(secret)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Send wireBytes over your TCP connection...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue