Skip to content

Commit

Permalink
Remove libolm dependency
Browse files Browse the repository at this point in the history
See #729 for more information.

This is a breaking change because it removes blueprint functionality.
Specifically, it removes:
 - the field `OneTimeKeys` from the `User` struct.
 - the performance blueprint `BlueprintPerfE2EERoom`.
  • Loading branch information
kegsay committed Sep 24, 2024
1 parent 5b72981 commit 659596a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 186 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: "Install Complement Dependencies"
run: |
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
- name: "Run internal Complement tests"
run: |
go test ./internal/...
Expand Down Expand Up @@ -69,7 +66,6 @@ jobs:
# servers which listen on random high numbered ports.
- name: "Install Complement Dependencies"
run: |
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
go install -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
mkdir .gotestfmt/github -p
cp .ci/complement_package.gotpl .gotestfmt/github/package.gotpl
Expand Down
5 changes: 0 additions & 5 deletions b/blueprints.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var KnownBlueprints = map[string]*Blueprint{
BlueprintOneToOneRoom.Name: &BlueprintOneToOneRoom,
BlueprintPerfManyMessages.Name: &BlueprintPerfManyMessages,
BlueprintPerfManyRooms.Name: &BlueprintPerfManyRooms,
BlueprintPerfE2EERoom.Name: &BlueprintPerfE2EERoom,
}

// Blueprint represents an entire deployment to make.
Expand Down Expand Up @@ -64,10 +63,6 @@ type User struct {
AvatarURL string
AccountData []AccountData
DeviceID *string
// Enable end-to end encryption for this user and upload the given
// amount of one-time keys. This requires the DeviceId to be set as
// well.
OneTimeKeys uint
}

type AccountData struct {
Expand Down
104 changes: 0 additions & 104 deletions b/perf_e2ee_room.go

This file was deleted.

1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/tidwall/sjson v1.2.5
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
gonum.org/v1/plot v0.11.0
maunium.net/go/mautrix v0.11.0
)

require (
Expand Down
63 changes: 0 additions & 63 deletions internal/instruction/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"time"

"github.com/tidwall/gjson"
"maunium.net/go/mautrix/crypto/olm"

"github.com/matrix-org/complement/b"
)
Expand Down Expand Up @@ -418,9 +417,6 @@ func calculateUserInstructionSets(r *Runner, hs b.Homeserver) [][]instruction {
}
createdUsers[user.Localpart] = true

if user.OneTimeKeys > 0 {
instrs = append(instrs, instructionOneTimeKeyUpload(hs, user))
}
sets[i] = instrs
}
return sets
Expand Down Expand Up @@ -636,65 +632,6 @@ func instructionLogin(hs b.Homeserver, user b.User) instruction {
}
}

func instructionOneTimeKeyUpload(hs b.Homeserver, user b.User) instruction {
account := olm.NewAccount()
ed25519Key, curveKey := account.IdentityKeys()

userID := fmt.Sprintf("@%s:%s", user.Localpart, hs.Name)
deviceID := *user.DeviceID

ed25519KeyID := fmt.Sprintf("ed25519:%s", deviceID)
curveKeyID := fmt.Sprintf("curve25519:%s", deviceID)

deviceKeys := map[string]interface{}{
"user_id": userID,
"device_id": deviceID,
"algorithms": []string{"m.olm.v1.curve25519-aes-sha2", "m.megolm.v1.aes-sha2"},
"keys": map[string]string{
ed25519KeyID: ed25519Key.String(),
curveKeyID: curveKey.String(),
},
}

signature, _ := account.SignJSON(deviceKeys)

deviceKeys["signatures"] = map[string]map[string]string{
userID: {
ed25519KeyID: signature,
},
}

account.GenOneTimeKeys(user.OneTimeKeys)

oneTimeKeys := map[string]interface{}{}

for kid, key := range account.OneTimeKeys() {
keyID := fmt.Sprintf("signed_curve25519:%s", kid)
keyMap := map[string]interface{}{
"key": key.String(),
}

signature, _ = account.SignJSON(keyMap)

keyMap["signatures"] = map[string]interface{}{
userID: map[string]string{
ed25519KeyID: signature,
},
}

oneTimeKeys[keyID] = keyMap
}
return instruction{
method: "POST",
path: "/_matrix/client/v3/keys/upload",
accessToken: fmt.Sprintf("user_@%s:%s", user.Localpart, hs.Name),
body: map[string]interface{}{
"device_keys": deviceKeys,
"one_time_keys": oneTimeKeys,
},
}
}

// indexFor hashes the input and returns a number % numEntries
func indexFor(input string, numEntries int) int {
hh := fnv.New32a()
Expand Down
16 changes: 7 additions & 9 deletions tests/csapi/device_lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/matrix-org/complement/match"
"github.com/matrix-org/complement/must"
"github.com/matrix-org/complement/runtime"
"maunium.net/go/mautrix/crypto/olm"

"github.com/tidwall/gjson"
)
Expand All @@ -23,12 +22,11 @@ func TestDeviceListUpdates(t *testing.T) {
// Returns a check function that can be passed to mustQueryKeys.
uploadNewKeys := func(t *testing.T, user *client.CSAPI) []match.JSON {
t.Helper()

account := olm.NewAccount()
ed25519Key, curve25519Key := account.IdentityKeys()

ed25519KeyID := fmt.Sprintf("ed25519:%s", user.DeviceID)
curve25519KeyID := fmt.Sprintf("curve25519:%s", user.DeviceID)
// valid keys generated by a client
ed25519Key := "aPtHi1NV5O66InHYyrAtjEBTP+Ua33St/3aS4PVR+IE"
curve25519Key := "BLTpDRieneXv24C4IVCAq6pte9u2qo1zT5Ee3jB0pzk"

user.MustDo(t, "POST", []string{"_matrix", "client", "v3", "keys", "upload"},
client.WithJSONBody(t, map[string]interface{}{
Expand All @@ -37,8 +35,8 @@ func TestDeviceListUpdates(t *testing.T) {
"device_id": user.DeviceID,
"algorithms": []interface{}{"m.olm.v1.curve25519-aes-sha2", "m.megolm.v1.aes-sha2"},
"keys": map[string]interface{}{
ed25519KeyID: ed25519Key.String(),
curve25519KeyID: curve25519Key.String(),
ed25519KeyID: ed25519Key,
curve25519KeyID: curve25519Key,
},
},
}),
Expand All @@ -49,8 +47,8 @@ func TestDeviceListUpdates(t *testing.T) {
curve25519Path := fmt.Sprintf("device_keys.%s.%s.keys.%s", user.UserID, user.DeviceID, curve25519KeyID)
return []match.JSON{
match.JSONKeyEqual(algorithmsPath, []interface{}{"m.olm.v1.curve25519-aes-sha2", "m.megolm.v1.aes-sha2"}),
match.JSONKeyEqual(ed25519Path, ed25519Key.String()),
match.JSONKeyEqual(curve25519Path, curve25519Key.String()),
match.JSONKeyEqual(ed25519Path, ed25519Key),
match.JSONKeyEqual(curve25519Path, curve25519Key),
}
}

Expand Down

0 comments on commit 659596a

Please sign in to comment.