Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
update zkgroup + improve group handling
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Dec 31, 2021
1 parent 04e83ca commit 0deacab
Show file tree
Hide file tree
Showing 21 changed files with 2,183 additions and 240 deletions.
22 changes: 17 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,30 @@ type Config struct {
AccountCapabilities AccountCapabilities `yaml:"accountCapabilities"` // Account Attrributes are used in order to track the support of different function for signal
DiscoverableByPhoneNumber bool `yaml:"discoverableByPhoneNumber"` // If the user should be found by his phone number
ProfileKey []byte `yaml:"profileKey"` // The profile key is used in many places to encrypt the avatar, name etc and also in groupsv2 context
ProfileKeyCredential []byte `yaml:"profileKeyCredential"` // The profile key is used in many places to encrypt the avatar, name etc and also in groupsv2 context
Name string `yaml:"name"` // The username
UnidentifiedAccessKey []byte `yaml:"unidentifiedAccessKey"` // The access key for unidentified users
Certificate []byte `yaml:"certificate"` // The access key for unidentified users
CrayfishSupport bool `yaml:"crayfishSupport"` // weather the client uses crayfish or not
CrayfishSupport bool `yaml:"crayfishSupport"`
Group struct {
MaxGroupSize int
MaxGroupTitleLengthBytes int
MaxGroupDescriptionLengthBytes int
ExternalServiceSecret string
} // weather the client uses crayfish or not
}

const (
ZKGROUP_SERVER_PUBLIC_PARAMS = "AMhf5ywVwITZMsff/eCyudZx9JDmkkkbV6PInzG4p8x3VqVJSFiMvnvlEKWuRob/1eaIetR31IYeAbm0NdOuHH8Qi+Rexi1wLlpzIo1gstHWBfZzy1+qHRV5A4TqPp15YzBPm0WSggW6PbSn+F4lf57VCnHF7p8SvzAA2ZZJPYJURt8X7bbg+H3i+PEjH9DXItNEqs2sNcug37xZQDLm7X36nOoGPs54XsEGzPdEV+itQNGUFEjY6X9Uv+Acuks7NpyGvCoKxGwgKgE5XyJ+nNKlyHHOLb6N1NuHyBrZrgtY/JYJHRooo5CEqYKBqdFnmbTVGEkCvJKxLnjwKWf+fEPoWeQFj5ObDjcKMZf2Jm2Ae69x+ikU5gBXsRmoF94GXQ=="
)

// AccountCapabilities describes what functions axolotl supports
type AccountCapabilities struct {
UUID bool `json:"uuid" yaml:"uuid"`
Gv2 bool `json:"gv2-3" yaml:"gv2"`
Storage bool `json:"storage" yaml:"storage"`
Gv1Migration bool `json:"gv1-migration" yaml:"gv1-migration"`
Gv2 bool `json:"gv2" yaml:"gv2"`
SenderKey bool `json:"senderKey" yaml:"senderKey"`
AnnouncementGroup bool `json:"announcementGroup" yaml:"announcementGroup"`
ChangeNumber bool `json:"changeNumber" yaml:"changeNumber"`
Gv1Migration bool `json:"gv1-migration" yaml:"gv1-migration"`
}

var (
Expand Down
29 changes: 15 additions & 14 deletions contacts/contacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ import (

// Contact contains information about a contact.
type Contact struct {
UUID string
Tel string
ProfileKey []byte
IdentityKey []byte
Name string
Username string
Avatar []byte
Color string
Blocked bool
Verified *signalservice.Verified
ExpireTimer uint32
InboxPosition uint32
Archived bool
Certificate []byte
UUID string
Tel string
ProfileKey []byte
ProfileKeyCredential []byte
IdentityKey []byte
Name string
Username string
Avatar []byte
Color string
Blocked bool
Verified *signalservice.Verified
ExpireTimer uint32
InboxPosition uint32
Archived bool
Certificate []byte
}

func (c *Contact) GetProfileKey() []byte {
Expand Down
20 changes: 20 additions & 0 deletions entities/groupUser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package entities

import (
"bytes"
)

type GroupUser struct {
UserCiphertext []byte
GroupPublicKey []byte
GroupId []byte
StrGroupId string
StrUserUUId string
}

func (user *GroupUser) IsMember(uuid, groupPublicKey []byte) bool {
f1 := bytes.Equal(user.GroupPublicKey, groupPublicKey)
f2 := bytes.Equal(user.UserCiphertext, uuid)
return f1 && f2

}
41 changes: 41 additions & 0 deletions entities/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package entities

import (
"encoding/json"
"net/http"
"path"
"runtime"

log "github.com/sirupsen/logrus"
)

type ResponseStatus struct {
Code int `json:"code" example:"200"`
Message string `json:"message" example:"OK"`
Reason string `json:"reason" example:"param error"`
File string `json:"file" example:"param error"`
Line int `json:"line" example:"param error"`
FuncName string `json:"func"`
}

func (rs *ResponseStatus) Error() string {
jsb, _ := json.Marshal(rs)
log.Errorln(string(jsb))
return string(jsb)
}

func Status(code int, reason string) error {
fname, file, line, _ := runtime.Caller(1)
return &ResponseStatus{
Code: code,
Message: http.StatusText(code),
Reason: reason,
File: path.Base(file),
Line: line,
FuncName: path.Base(runtime.FuncForPC(fname).Name()),
}
}

type Resp struct {
Obj interface{} `json:"obj"`
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ require (
github.com/google/go-cmp v0.5.1 // indirect
github.com/gorilla/websocket v1.4.2
github.com/kr/text v0.2.0 // indirect
github.com/nanu-c/zkgroup v0.8.8
github.com/nanu-c/zkgroup v0.9.0
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/onsi/ginkgo v1.12.0 // indirect
github.com/onsi/gomega v1.9.0 // indirect
github.com/pieterbork/ed25519 v0.0.0-20200301051623-f19b832d0d2e // indirect
github.com/satori/go.uuid v1.2.0
github.com/signal-golang/ed25519 v0.0.0-20200301051623-f19b832d0d2e
github.com/signal-golang/mimemagic v0.0.0-20200821045537-3f613cf2cd3f
github.com/sirupsen/logrus v1.7.0
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.6.1
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/text v0.3.3
Expand Down
Loading

0 comments on commit 0deacab

Please sign in to comment.