4
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2025-06-15 15:36:06 +00:00

Experiment with new API

This commit is contained in:
Neil Alexander
2019-04-18 16:38:24 +01:00
parent 24fa8355f1
commit eef2a02d0a
2 changed files with 122 additions and 0 deletions

View File

@ -13,6 +13,7 @@ It also defines NodeID and TreeID as hashes of keys, and wraps hash functions
import (
"crypto/rand"
"crypto/sha512"
"encoding/hex"
"golang.org/x/crypto/ed25519"
"golang.org/x/crypto/nacl/box"
@ -32,6 +33,14 @@ type NodeID [NodeIDLen]byte
type TreeID [TreeIDLen]byte
type Handle [handleLen]byte
func (n *NodeID) String() string {
return hex.EncodeToString(n[:])
}
func (n *NodeID) Network() string {
return "nodeid"
}
func GetNodeID(pub *BoxPubKey) *NodeID {
h := sha512.Sum512(pub[:])
return (*NodeID)(&h)