0.3.4
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Sudo-Ivan/reticulum-go/pkg/identity"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -206,3 +208,29 @@ func (p *Packet) Serialize() ([]byte, error) {
|
||||
|
||||
return p.Raw, nil
|
||||
}
|
||||
|
||||
func NewAnnouncePacket(destHash []byte, identity *identity.Identity, appData []byte, transportID []byte) (*Packet, error) {
|
||||
// Create combined public key
|
||||
pubKey := identity.GetPublicKey()
|
||||
|
||||
// Create signed data
|
||||
signedData := append(destHash, pubKey...)
|
||||
signedData = append(signedData, appData...)
|
||||
|
||||
// Sign the data
|
||||
signature := identity.Sign(signedData)
|
||||
|
||||
// Combine all data
|
||||
data := append(pubKey, appData...)
|
||||
data = append(data, signature...)
|
||||
|
||||
p := &Packet{
|
||||
HeaderType: HeaderType2,
|
||||
PacketType: PacketTypeAnnounce,
|
||||
TransportID: transportID,
|
||||
DestinationHash: destHash,
|
||||
Data: data,
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user