summaryrefslogtreecommitdiffhomepage
path: root/src/noise_types.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/noise_types.go')
-rw-r--r--src/noise_types.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/noise_types.go b/src/noise_types.go
index 5508f9a..5ebc130 100644
--- a/src/noise_types.go
+++ b/src/noise_types.go
@@ -3,18 +3,18 @@ package main
import (
"encoding/hex"
"errors"
+ "golang.org/x/crypto/chacha20poly1305"
)
const (
- NoisePublicKeySize = 32
- NoisePrivateKeySize = 32
- NoiseSymmetricKeySize = 32
+ NoisePublicKeySize = 32
+ NoisePrivateKeySize = 32
)
type (
NoisePublicKey [NoisePublicKeySize]byte
NoisePrivateKey [NoisePrivateKeySize]byte
- NoiseSymmetricKey [NoiseSymmetricKeySize]byte
+ NoiseSymmetricKey [chacha20poly1305.KeySize]byte
NoiseNonce uint64 // padded to 12-bytes
)
@@ -30,6 +30,15 @@ func loadExactHex(dst []byte, src string) error {
return nil
}
+func (key NoisePrivateKey) IsZero() bool {
+ for _, b := range key[:] {
+ if b != 0 {
+ return false
+ }
+ }
+ return true
+}
+
func (key *NoisePrivateKey) FromHex(src string) error {
return loadExactHex(key[:], src)
}