summaryrefslogtreecommitdiffhomepage
path: root/noise-helpers.go
diff options
context:
space:
mode:
Diffstat (limited to 'noise-helpers.go')
-rw-r--r--noise-helpers.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/noise-helpers.go b/noise-helpers.go
index 1b2746c..af11f09 100644
--- a/noise-helpers.go
+++ b/noise-helpers.go
@@ -78,12 +78,14 @@ func setZero(arr []byte) {
}
}
+func (sk *NoisePrivateKey) clamp() {
+ sk[0] &= 248
+ sk[31] = (sk[31] & 127) | 64
+}
+
func newPrivateKey() (sk NoisePrivateKey, err error) {
- // clamping: https://cr.yp.to/ecdh.html
_, err = rand.Read(sk[:])
- sk[0] &= 248
- sk[31] &= 127
- sk[31] |= 64
+ sk.clamp()
return
}