package server import ( "context" "crypto" "crypto/ed25519" "fmt" "github.com/common-fate/httpsig/alg_ed25519" "github.com/common-fate/httpsig/verifier" ) type KeyEntry struct { alg string publicKey crypto.PublicKey userId string } type InMemoryDirectory struct { records map[string]KeyEntry } func (dir *InMemoryDirectory) GetKey(ctx context.Context, keyId string, _ string) (verifier.Algorithm, error) { entry := dir.records[keyId] var alg verifier.Algorithm var err error switch entry.alg { case "ed25519": alg = alg_ed25519.Ed25519{ PublicKey: entry.publicKey.(ed25519.PublicKey), Attrs: entry.userId, } default: err = fmt.Errorf("unknown algoritm: %s", entry.alg) } return alg, err }