From 7dfe22396e0c5a6b13a2212dafee922fdf71190b Mon Sep 17 00:00:00 2001 From: metalurgical <97008724+metalurgical@users.noreply.github.com> Date: Thu, 18 Jan 2024 05:00:18 +0200 Subject: [PATCH] fix: use non-standard ecdh --- Sources/TorusUtils/Extensions/secp256k1+Extension.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/TorusUtils/Extensions/secp256k1+Extension.swift b/Sources/TorusUtils/Extensions/secp256k1+Extension.swift index 35a8346f..dda2668b 100644 --- a/Sources/TorusUtils/Extensions/secp256k1+Extension.swift +++ b/Sources/TorusUtils/Extensions/secp256k1+Extension.swift @@ -7,7 +7,10 @@ public struct secp256k1 {} extension secp256k1 { public static func ecdh(publicKey: PublicKey, privateKey: SecretKey) throws -> [UInt8] { - return try Data(hex: ECDH.ecdh(sk: privateKey, pk: publicKey)).bytes.sha512() + let shared = try publicKey.mul(key: privateKey) + let serialized = try shared.serialize(compressed: true) + let data = Data(hex: serialized).dropFirst() + return data.bytes.sha512() } public static func ecdhWithHex(pubKeyHex: String, privateKeyHex: String) throws -> [UInt8] {