Clarify gen cmd example with reverse public key lookup

This commit is contained in:
lash 2024-12-08 21:57:53 +00:00
parent 890f50704f
commit a3e821fb16
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746

View File

@ -2,6 +2,7 @@ package main
import (
"context"
"crypto/sha1"
"flag"
"fmt"
"os"
@ -46,7 +47,18 @@ func main() {
}
userStore := common.UserDataStore{store}
err = userStore.WriteEntry(ctx, sessionId, common.DATA_AMOUNT, []byte("1.0"))
h := sha1.New()
h.Write([]byte(sessionId))
address := h.Sum(nil)
addressString := fmt.Sprintf("%x", address)
err = userStore.WriteEntry(ctx, sessionId, common.DATA_PUBLIC_KEY, []byte(addressString))
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
}
err = userStore.WriteEntry(ctx, addressString, common.DATA_PUBLIC_KEY_REVERSE, []byte(sessionId))
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)