MCPcopy Create free account
hub / github.com/daodst/chat / localKeys

Function localKeys

federationapi/routing/keys.go:141–178  ·  view source on GitHub ↗
(cfg *config.FederationAPI, validUntil time.Time)

Source from the content-addressed store, hash-verified

139}
140
141func localKeys(cfg *config.FederationAPI, validUntil time.Time) (*gomatrixserverlib.ServerKeys, error) {
142 var keys gomatrixserverlib.ServerKeys
143
144 keys.ServerName = cfg.Matrix.ServerName
145 keys.ValidUntilTS = gomatrixserverlib.AsTimestamp(validUntil)
146
147 publicKey := cfg.Matrix.PrivateKey.Public().(ed25519.PublicKey)
148
149 keys.VerifyKeys = map[gomatrixserverlib.KeyID]gomatrixserverlib.VerifyKey{
150 cfg.Matrix.KeyID: {
151 Key: gomatrixserverlib.Base64Bytes(publicKey),
152 },
153 }
154
155 keys.OldVerifyKeys = map[gomatrixserverlib.KeyID]gomatrixserverlib.OldVerifyKey{}
156 for _, oldVerifyKey := range cfg.Matrix.OldVerifyKeys {
157 keys.OldVerifyKeys[oldVerifyKey.KeyID] = gomatrixserverlib.OldVerifyKey{
158 VerifyKey: gomatrixserverlib.VerifyKey{
159 Key: gomatrixserverlib.Base64Bytes(oldVerifyKey.PrivateKey.Public().(ed25519.PublicKey)),
160 },
161 ExpiredTS: oldVerifyKey.ExpiredAt,
162 }
163 }
164
165 toSign, err := json.Marshal(keys.ServerKeyFields)
166 if err != nil {
167 return nil, err
168 }
169
170 keys.Raw, err = gomatrixserverlib.SignJSON(
171 string(cfg.Matrix.ServerName), cfg.Matrix.KeyID, cfg.Matrix.PrivateKey, toSign,
172 )
173 if err != nil {
174 return nil, err
175 }
176
177 return &keys, nil
178}
179
180func NotaryKeys(
181 httpReq *http.Request, cfg *config.FederationAPI,

Callers 2

LocalKeysFunction · 0.85
NotaryKeysFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected