Skip to content

Commit

Permalink
Generates a public key from existing private key.
Browse files Browse the repository at this point in the history
  • Loading branch information
zelenko authored Dec 21, 2019
1 parent becbf70 commit 5fe5b4e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nacl/box/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ func GenerateKey(rand io.Reader) (publicKey, privateKey *[32]byte, err error) {
return
}

// GeneratePublicKey generates a public key from existing private key.
func GeneratePublicKey(privateKey *[32]byte) (publicKey *[32]byte) {
publicKey = new([32]byte)
curve25519.ScalarBaseMult(publicKey, privateKey)
return
}

var zeros [16]byte

// Precompute calculates the shared key between peersPublicKey and privateKey
Expand Down

0 comments on commit 5fe5b4e

Please sign in to comment.