From 7626dc4218cacf6bb70a1b2bcee668c82919227c Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Sat, 22 Jun 2024 20:42:27 -0400
Subject: [PATCH] Add converter for the private -> public key for prc servers

---
 bindings/rpc.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/bindings/rpc.go b/bindings/rpc.go
index a61a583e7..0022f313a 100644
--- a/bindings/rpc.go
+++ b/bindings/rpc.go
@@ -163,6 +163,16 @@ func GenerateRandomRPCKey(cMixID int) ([]byte, error) {
 	return prk.Bytes(), nil
 }
 
+// DeriveRPCPublicKey derives the public key from the given private key
+func DeriveRPCPublicKey(privateKey []byte) ([]byte, error) {
+	prk := ecdh.ECDHNIKE.NewEmptyPrivateKey()
+	err := prk.FromBytes(privateKey)
+	if err != nil {
+		return nil, err
+	}
+	return ecdh.ECDHNIKE.DerivePublicKey(prk).Bytes(), nil
+}
+
 // LoadRPCServer load key and id from disk and return an RPC server
 func LoadRPCServer(cMixID int, callback RPCServerCallback) (
 	RPCServer, error) {
-- 
GitLab