Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ import (
"fmt"
"io"

"golang.org/x/crypto/salsa20/salsa"

"golang.org/x/crypto/curve25519"

"golang.org/x/crypto/ed25519"
"golang.org/x/crypto/salsa20/salsa"
)

const ztIdentityGenMemory = 2097152
Expand Down Expand Up @@ -105,7 +103,7 @@ type ZeroTierIdentity struct {
}

// NewZeroTierIdentity creates a new ZeroTier Identity.
// This can be a little bit time consuming due to one way proof of work requirements (usually a few hundred milliseconds).
// This can be a little bit time-consuming due to one way proof of work requirements (usually a few hundred milliseconds).
func NewZeroTierIdentity() (id ZeroTierIdentity) {
for {
pub, priv := generateDualPair()
Expand Down Expand Up @@ -133,22 +131,19 @@ func NewZeroTierIdentity() (id ZeroTierIdentity) {
// PrivateKeyString returns the full identity.secret if the private key is set, or an empty string if no private key is set.
func (id *ZeroTierIdentity) PrivateKeyString() string {
if id.privateKey != nil {
s := fmt.Sprintf("%.10x:0:%x:%x", id.address, id.publicKey, *id.privateKey)
return s
return fmt.Sprintf("%.10x:0:%x:%x", id.address, id.publicKey, *id.privateKey)
}
return ""
}

// PublicKeyString returns identity.public contents.
func (id *ZeroTierIdentity) PublicKeyString() string {
s := fmt.Sprintf("%.10x:0:%x", id.address, id.publicKey)
return s
return fmt.Sprintf("%.10x:0:%x", id.address, id.publicKey)
}

// IDString returns the NodeID as a 10-digit hex string
func (id *ZeroTierIdentity) IDString() string {
s := fmt.Sprintf("%.10x", id.address)
return s
return fmt.Sprintf("%.10x", id.address)
}

// ID returns the ZeroTier address as a uint64
Expand Down