From 1d4f7c7a4312c431bf73a90457e9521aa98e1d3e Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Sun, 11 Jul 2021 09:59:42 +0200 Subject: [PATCH] avoid borrow, breaks logging (#604) --- libp2p/crypto/secp.nim | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/libp2p/crypto/secp.nim b/libp2p/crypto/secp.nim index 70f8e9b45..97c5ddb49 100644 --- a/libp2p/crypto/secp.nim +++ b/libp2p/crypto/secp.nim @@ -201,14 +201,18 @@ proc verify*[T: byte|char](sig: SkSignature, msg: openarray[T], let h = sha256.digest(msg) verify(secp256k1.SkSignature(sig), SkMessage(h.data), secp256k1.SkPublicKey(key)) -func clear*(key: var SkPrivateKey) {.borrow.} +func clear*(key: var SkPrivateKey) = clear(secp256k1.SkSecretKey(key)) -proc `$`*(key: SkPrivateKey): string {.borrow.} -proc `$`*(key: SkPublicKey): string {.borrow.} -proc `$`*(key: SkSignature): string {.borrow.} -proc `$`*(key: SkKeyPair): string {.borrow.} +func `$`*(key: SkPrivateKey): string = $secp256k1.SkSecretKey(key) +func `$`*(key: SkPublicKey): string = $secp256k1.SkPublicKey(key) +func `$`*(key: SkSignature): string = $secp256k1.SkSignature(key) +func `$`*(key: SkKeyPair): string = $secp256k1.SkKeyPair(key) -proc `==`*(a, b: SkPrivateKey): bool {.borrow.} -proc `==`*(a, b: SkPublicKey): bool {.borrow.} -proc `==`*(a, b: SkSignature): bool {.borrow.} -proc `==`*(a, b: SkKeyPair): bool {.borrow.} \ No newline at end of file +func `==`*(a, b: SkPrivateKey): bool = + secp256k1.SkSecretKey(a) == secp256k1.SkSecretKey(b) +func `==`*(a, b: SkPublicKey): bool = + secp256k1.SkPublicKey(a) == secp256k1.SkPublicKey(b) +func `==`*(a, b: SkSignature): bool = + secp256k1.SkSignature(a) == secp256k1.SkSignature(b) +func `==`*(a, b: SkKeyPair): bool = + secp256k1.SkKeyPair(a) == secp256k1.SkKeyPair(b) \ No newline at end of file