wireguard-helpers.go raw

   1  package app
   2  
   3  import (
   4  	"golang.org/x/crypto/curve25519"
   5  
   6  	"next.orly.dev/pkg/nostr/crypto/keys"
   7  )
   8  
   9  // derivePublicKey derives a Curve25519 public key from a private key.
  10  func derivePublicKey(privateKey []byte) ([]byte, error) {
  11  	publicKey := make([]byte, 32)
  12  	curve25519.ScalarBaseMult((*[32]byte)(publicKey), (*[32]byte)(privateKey))
  13  	return publicKey, nil
  14  }
  15  
  16  // deriveSecp256k1PublicKey derives a secp256k1 public key from a secret key.
  17  func deriveSecp256k1PublicKey(secretKey []byte) ([]byte, error) {
  18  	return keys.SecretBytesToPubKeyBytes(secretKey)
  19  }
  20