From b18d9bc6f1ebba0138e4928af5533872672a92f7 Mon Sep 17 00:00:00 2001 From: doesnm Date: Thu, 6 Jun 2024 22:42:55 +0300 Subject: [PATCH] i want to ed25519 key being as actor primary key --- actor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actor.go b/actor.go index 9385bf8..1d90888 100644 --- a/actor.go +++ b/actor.go @@ -271,7 +271,7 @@ func (a *Actor) save() error { // check if we already have a directory to save actors // and if not, create it - dir := storage + slash + "actors" + slash + a.Name + slash + "items" + dir := storage + slash + "actors" + slash + base64.StdEncoding.EncodeToString(a.ed25519PublicKey) + slash + "items" if _, err := os.Stat(dir); os.IsNotExist(err) { os.MkdirAll(dir, 0755) } @@ -299,7 +299,7 @@ func (a *Actor) save() error { } //log.Info(actorToSave) //log.Info(string(actorJSON)) - err = ioutil.WriteFile(storage+slash+"actors"+slash+a.Name+slash+a.Name+".json", actorJSON, 0644) + err = ioutil.WriteFile(storage+slash+"actors"+slash+(base64.StdEncoding.EncodeToString(a.ed25519PublicKey))+slash+"actor.json", actorJSON, 0644) if err != nil { log.Printf("WriteFileJson ERROR: %+v", err) return err @@ -309,7 +309,7 @@ func (a *Actor) save() error { } func (a *Actor) whoAmI() string { - encoded := base64.StdEncoding.EncodeToString(a.ed25519PublicKey) + encoded := "did:key:" + base64.StdEncoding.EncodeToString(a.ed25519PublicKey) self := make(map[string]interface{}) self["@context"] = context() self["type"] = a.actorType