aboutsummaryrefslogtreecommitdiff
path: root/server/user.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/user.go')
-rw-r--r--server/user.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/server/user.go b/server/user.go
new file mode 100644
index 0000000..37ceee5
--- /dev/null
+++ b/server/user.go
@@ -0,0 +1,37 @@
+package main
+
+import (
+ "crypto/ed25519"
+ "encoding/base64"
+ "errors"
+ "net/http"
+)
+
+func verify(id string, body []byte) error {
+ b, err := base64.RawURLEncoding.DecodeString(id)
+ if err != nil {
+ return err
+ }
+ if len(body) < ed25519.SignatureSize {
+ return errors.New("body too short")
+ }
+ message := body[:len(body)-ed25519.SignatureSize]
+ sig := body[len(body)-ed25519.SignatureSize:]
+ if !ed25519.Verify(ed25519.PublicKey(b), message, sig) {
+ return errors.New("signature verification failed")
+ }
+ return nil
+}
+
+// Create user
+func createHandler(w http.ResponseWriter, r *http.Request) {
+ r.ParseForm()
+ id := r.Form.Get("id")
+ dhtGet(id)
+
+}
+
+// Delete user
+func deleteHandler(w http.ResponseWriter, r *http.Request) {
+
+}