Skip to content

Commit

Permalink
fix: use non-standard ecdh
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Jan 18, 2024
1 parent 83dd439 commit 7dfe223
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/TorusUtils/Extensions/secp256k1+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down

0 comments on commit 7dfe223

Please sign in to comment.