Experiment with new API

This commit is contained in:
Neil Alexander 2019-04-18 16:38:24 +01:00
parent 24fa8355f1
commit eef2a02d0a
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
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)