Cleanup
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
package peer
|
||||
|
||||
import (
|
||||
"golang.org/x/crypto/nacl/box"
|
||||
)
|
||||
|
||||
func encryptPacket(sharedKey, nonce, packet, out []byte) []byte {
|
||||
out = box.SealAfterPrecomputation(out[:0], packet, (*[24]byte)(nonce), (*[32]byte)(sharedKey))
|
||||
return append(out, nonce...)
|
||||
}
|
||||
|
||||
func decryptPacket(sharedKey, packet, out []byte) (decrypted []byte, ok bool) {
|
||||
cut := len(packet) - NONCE_SIZE
|
||||
decrypted, ok = box.OpenAfterPrecomputation(out[:0], packet[:cut], (*[24]byte)(packet[cut:]), (*[32]byte)(sharedKey))
|
||||
return decrypted, ok
|
||||
}
|
||||
|
||||
func computeSharedKey(peerPubKey, privKey []byte) []byte {
|
||||
shared := [32]byte{}
|
||||
box.Precompute(&shared, (*[32]byte)(peerPubKey), (*[32]byte)(privKey))
|
||||
return shared[:]
|
||||
}
|
||||
Reference in New Issue
Block a user