@@ -26,6 +26,7 @@ import (
2626
2727 "github.com/google/uuid"
2828 "github.com/rs/zerolog"
29+ "go.mau.fi/util/exerrors"
2930 "google.golang.org/protobuf/proto"
3031 "google.golang.org/protobuf/reflect/protoreflect"
3132
@@ -860,18 +861,14 @@ type DecryptionResult struct {
860861 SealedSender bool
861862}
862863
863- func serverTrustRootKey () * libsignalgo.PublicKey {
864- // TODO: put this server's trust root in the config or DB or something
865- serverTrustRoot := "BXu6QIKVz5MA8gstzfOgRQGqyLqOwNKHL6INkv3IHWMF"
866- serverTrustRootBytes , err := base64 .StdEncoding .DecodeString (serverTrustRoot )
867- if err != nil {
868- panic (fmt .Errorf ("DecodeString error: %w" , err ))
869- }
870- serverTrustRootKey , err := libsignalgo .DeserializePublicKey (serverTrustRootBytes )
871- if err != nil {
872- panic (fmt .Errorf ("DeserializePublicKey error: %w" , err ))
873- }
874- return serverTrustRootKey
864+ const prodServerTrustRootStr = "BXu6QIKVz5MA8gstzfOgRQGqyLqOwNKHL6INkv3IHWMF"
865+
866+ var prodServerTrustRootBytes = exerrors .Must (base64 .StdEncoding .DecodeString (prodServerTrustRootStr ))
867+ var prodServerTrustRootKey = exerrors .Must (libsignalgo .DeserializePublicKey (prodServerTrustRootBytes ))
868+
869+ func init () {
870+ // It's never going to be freed anyway
871+ prodServerTrustRootKey .CancelFinalizer ()
875872}
876873
877874func (cli * Client ) sealedSenderDecrypt (ctx context.Context , envelope * signalpb.Envelope ) (* DecryptionResult , error ) {
@@ -885,7 +882,7 @@ func (cli *Client) sealedSenderDecrypt(ctx context.Context, envelope *signalpb.E
885882 ctx ,
886883 envelope .Content ,
887884 localAddress ,
888- serverTrustRootKey () ,
885+ prodServerTrustRootKey ,
889886 timestamp ,
890887 cli .Store .SessionStore ,
891888 cli .Store .IdentityStore ,
0 commit comments