Additions for client side dev

This commit is contained in:
ycc 2022-10-29 20:07:35 +02:00
parent 279d5d2257
commit 7fe7892764
5 changed files with 61 additions and 6 deletions

View File

@ -9,6 +9,38 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
var privateKeyECC = `-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: openpgp-mobile
xVgEY1j9rBYJKwYBBAHaRw8BAQdAk3jWTLSrUqL+vyeEv63DTLlp03IcMExucmFE
RG+IbZgAAQDgQazOcCioSeZWQ16Vn/TMYiAgXgsAlL5b5NZWgyTNzA/+zSFUZXN0
IChzYW1wbGUpIDxzYW1wbGVAc2FtcGxlLmNvbT7CiwQTFggAPQUCY1j9rAmQCUTp
H7mMc3UWIQSDHOWl4MeCw6GJdvkJROkfuYxzdQIbAwIeAQIZAQILBwIVCAMWAAIC
IgEAAKj5AP4x9KvZFpriLd2K97CaZs5Mzb4r4jeL/q0pMV6d6SvJ+QEAtrqfQovO
hEtadCopy1R3gepIdeX4Fh7tHNYi3pOO5wjHXQRjWP2sEgorBgEEAZdVAQUBAQdA
j48HXuKTfojSYLslNmAtCj6MkwFpj4TR2b5KkKD29kgDAQoJAAD/SulDoAyVe/VR
6dY5Xe887TZSOCKCk5KNTzBtfMj0nhAQzMJ4BBgWCAAqBQJjWP2sCZAJROkfuYxz
dRYhBIMc5aXgx4LDoYl2+QlE6R+5jHN1AhsMAAB0gAEAz9sGgXtTsfJiEMZhKNj8
XAbymYPQCrsmEBea1uqbB8UA/iKqk0cOabVYTzwBA53G0Tx0C67Xqy46mAtR+W4O
CfMK
=CJ/U
-----END PGP PRIVATE KEY BLOCK-----`
var publicKeyECC = `-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: openpgp-mobile
xjMEY1j9rBYJKwYBBAHaRw8BAQdAk3jWTLSrUqL+vyeEv63DTLlp03IcMExucmFE
RG+IbZjNIVRlc3QgKHNhbXBsZSkgPHNhbXBsZUBzYW1wbGUuY29tPsKLBBMWCAA9
BQJjWP2sCZAJROkfuYxzdRYhBIMc5aXgx4LDoYl2+QlE6R+5jHN1AhsDAh4BAhkB
AgsHAhUIAxYAAgIiAQAAqPkA/jH0q9kWmuIt3Yr3sJpmzkzNviviN4v+rSkxXp3p
K8n5AQC2up9Ci86ES1p0KinLVHeB6kh15fgWHu0c1iLek47nCM44BGNY/awSCisG
AQQBl1UBBQEBB0CPjwde4pN+iNJguyU2YC0KPoyTAWmPhNHZvkqQoPb2SAMBCgnC
eAQYFggAKgUCY1j9rAmQCUTpH7mMc3UWIQSDHOWl4MeCw6GJdvkJROkfuYxzdQIb
DAAAdIABAM/bBoF7U7HyYhDGYSjY/FwG8pmD0Aq7JhAXmtbqmwfFAP4iqpNHDmm1
WE88AQOdxtE8dAuu16suOpgLUfluDgnzCg==
=oWIw
-----END PGP PUBLIC KEY BLOCK-----`
func TestNewKeyPair(t *testing.T) { func TestNewKeyPair(t *testing.T) {
kp := NewKeyPair() kp := NewKeyPair()
fmt.Println(kp.Public) fmt.Println(kp.Public)
@ -60,3 +92,16 @@ func TestAsymEncryptDecryptSigned(t *testing.T) {
} }
assert.Equal(t, foo, string(decMess), "The two messages should be the same.") assert.Equal(t, foo, string(decMess), "The two messages should be the same.")
} }
func TestFlutterCompat(t *testing.T) {
pub := base64.StdEncoding.EncodeToString([]byte(publicKeyECC))
priv := base64.StdEncoding.EncodeToString([]byte(privateKeyECC))
encMess, sign, err := AsymEncryptAndSign(pub, priv, []byte("Hello"))
if err != nil {
log.Println(err.Error())
}
println(base64.StdEncoding.EncodeToString(encMess))
println(base64.StdEncoding.EncodeToString(sign))
}

View File

@ -17,8 +17,11 @@ type Identity struct {
Peers PeerList `json:"peers,omitempty"` Peers PeerList `json:"peers,omitempty"`
KnownServers InternalServerList `json:"known_servers,omitempty"` KnownServers InternalServerList `json:"known_servers,omitempty"`
MessageServers InternalServerList `json:"message_servers,omitempty"` MessageServers InternalServerList `json:"message_servers,omitempty"`
ArchiveServers InternalServerList `json:"archive_servers,omitempty"`
OwnedServers InternalServerList `json:"owned_servers,omitempty"`
DefaultDbPassword string `json:"default_db_password,omitempty"` DefaultDbPassword string `json:"default_db_password,omitempty"`
DbPasswordStore bool `json:"db_password_store,omitempty"` DbPasswordStore bool `json:"db_password_store,omitempty"`
OwnedDevices PeerList `json:"owned_devices,omitempty"`
} }
func CreateIdentity(nickname string) *Identity { func CreateIdentity(nickname string) *Identity {

View File

@ -5,6 +5,7 @@ import (
"time" "time"
"forge.redroom.link/yves/meowlib" "forge.redroom.link/yves/meowlib"
"github.com/google/uuid"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -59,6 +60,7 @@ func (p *Peer) BuildSimpleUserUMessage(message []byte) (*meowlib.UserMessage, er
msg.From = p.Me.Public msg.From = p.Me.Public
msg.Data = message msg.Data = message
msg.Type = "1" msg.Type = "1"
msg.Status.LocalUuid = uuid.New().String()
return &msg, nil return &msg, nil
} }

View File

@ -2,3 +2,5 @@
protoc -I=. --go_out=.. messages.proto protoc -I=. --go_out=.. messages.proto
mv ../forge.redroom.link/yves/meowlib/messages.pb.go ../ mv ../forge.redroom.link/yves/meowlib/messages.pb.go ../
rm -rf ../forge.redroom.link rm -rf ../forge.redroom.link
protoc -I=. --dart_out=../../../flutter/meowlib/lib/ messages.proto

View File

@ -13,11 +13,14 @@ import (
const key = "3pw0c8#6ZG8{75b5;3?fe80$2" const key = "3pw0c8#6ZG8{75b5;3?fe80$2"
type Identity struct { type Identity struct {
ServerName string `json:"servername,omitempty"` ServerName string `json:"servername,omitempty"`
ServerDesc string `json:"serverdesc,omitempty"` ServerDesc string `json:"serverdesc,omitempty"`
ServerKp meowlib.KeyPair `json:"server_kp,omitempty"` ServerKp meowlib.KeyPair `json:"server_kp,omitempty"`
Status string `json:"status,omitempty"` Status string `json:"status,omitempty"`
// KnownServers ServerList `json:"known_servers,omitempty"` OwnerName string `json:"owner_name,omitempty"`
OwnerPublicKey string `json:"owner_public_key,omitempty"`
ArchiveClients []string `json:"archive_clients,omitempty"`
KnownServers []meowlib.Server `json:"known_servers,omitempty"`
} }
func CreateIdentity(ServerName string, ServerDesc string) *Identity { func CreateIdentity(ServerName string, ServerDesc string) *Identity {