Browse Source

PKEY lookup for config-defined root zones added.

Bernd Fix 3 months ago
parent
commit
9b64495946
1 changed files with 17 additions and 2 deletions
  1. 17
    2
      src/gnunet/config/config.go

+ 17
- 2
src/gnunet/config/config.go View File

@@ -7,7 +7,9 @@ import (
7 7
 	"regexp"
8 8
 	"strings"
9 9
 
10
+	"github.com/bfix/gospel/crypto/ed25519"
10 11
 	"github.com/bfix/gospel/logger"
12
+	"gnunet/util"
11 13
 )
12 14
 
13 15
 ///////////////////////////////////////////////////////////////////////
@@ -15,8 +17,21 @@ import (
15 17
 
16 18
 // GNSConfig
17 19
 type GNSConfig struct {
18
-	Endpoint     string `json:"endpoint"`     // end-point of GNS service
19
-	DHTReplLevel int    `json:"dhtReplLevel"` // DHT replication level
20
+	Endpoint     string            `json:"endpoint"`     // end-point of GNS service
21
+	DHTReplLevel int               `json:"dhtReplLevel"` // DHT replication level
22
+	RootZones    map[string]string `json:"rootZones"`    // pre-configured root zones
23
+}
24
+
25
+// GetRootZoneKey returns the zone key (PKEY) for a pre-configured root with given name.
26
+func (gns *GNSConfig) GetRootZoneKey(name string) *ed25519.PublicKey {
27
+	// lookup key in the dictionary
28
+	if dStr, ok := gns.RootZones[name]; ok {
29
+		if data, err := util.DecodeStringToBinary(dStr, 32); err == nil {
30
+			return ed25519.NewPublicKeyFromBytes(data)
31
+		}
32
+	}
33
+	// no pkey found.
34
+	return nil
20 35
 }
21 36
 
22 37
 ///////////////////////////////////////////////////////////////////////

Loading…
Cancel
Save