gmessages/libgm/payload/registerPhoneRelay.go

39 lines
899 B
Go
Raw Normal View History

2023-06-30 09:54:08 +00:00
package payload
import (
2023-07-16 10:23:44 +00:00
"github.com/google/uuid"
2023-07-15 17:43:28 +00:00
"google.golang.org/protobuf/proto"
2023-06-30 09:54:08 +00:00
"go.mau.fi/mautrix-gmessages/libgm/binary"
"go.mau.fi/mautrix-gmessages/libgm/crypto"
)
func RegisterPhoneRelay(jwk *crypto.JWK) ([]byte, *binary.AuthenticationContainer, error) {
key, err := jwk.MarshalX509PublicKey()
if err != nil {
return nil, nil, err
}
payloadData := &binary.AuthenticationContainer{
2023-07-15 22:56:11 +00:00
AuthMessage: &binary.AuthMessage{
2023-07-16 10:23:44 +00:00
RequestID: uuid.NewString(),
2023-07-15 22:56:11 +00:00
Network: &Network,
ConfigVersion: ConfigMessage,
},
BrowserDetails: BrowserDetailsMessage,
Data: &binary.AuthenticationContainer_KeyData{
KeyData: &binary.KeyData{
EcdsaKeys: &binary.ECDSAKeys{
Field1: 2,
EncryptedKeys: key,
},
},
},
}
2023-07-15 17:43:28 +00:00
encoded, err4 := proto.Marshal(payloadData)
if err4 != nil {
return nil, payloadData, err4
}
return encoded, payloadData, nil
}