Skip to content

Commit

Permalink
rm redundant check for num bytes read
Browse files Browse the repository at this point in the history
  • Loading branch information
yusefnapora committed Dec 12, 2019
1 parent c67695a commit 8a5063a
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions p2p/security/noise/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package noise
import (
"context"
"crypto/rand"
"fmt"
"net"

"golang.org/x/crypto/curve25519"
Expand All @@ -28,13 +27,10 @@ type Keypair struct {
func GenerateKeypair() (*Keypair, error) {
var public_key [32]byte
var private_key [32]byte
c, err := rand.Read(private_key[:])
_, err := rand.Read(private_key[:])
if err != nil {
return nil, err
}
if c != 32 {
return nil, fmt.Errorf("unable to generate 32 bytes of random data, got %d", c)
}
curve25519.ScalarBaseMult(&public_key, &private_key)
return &Keypair{public_key, private_key}, nil
}
Expand Down

0 comments on commit 8a5063a

Please sign in to comment.