From 797c2ad89cf9b075716275713d80f16f5fbb2f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Frade?= <106541307+beatt83@users.noreply.github.com> Date: Wed, 21 Feb 2024 16:38:52 +0000 Subject: [PATCH] fix: secp256k1 was creating compressed keys and should be uncompressed (#7) removed some prints that should not be there --- .../CryptoImplementation/JWKCryptoPresentation.swift | 5 ----- .../KeyGeneration/EC/secp256k1+KeyGeneration.swift | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Sources/JSONWebAlgorithms/CryptoImplementation/JWKCryptoPresentation.swift b/Sources/JSONWebAlgorithms/CryptoImplementation/JWKCryptoPresentation.swift index 5e62074..a29793d 100644 --- a/Sources/JSONWebAlgorithms/CryptoImplementation/JWKCryptoPresentation.swift +++ b/Sources/JSONWebAlgorithms/CryptoImplementation/JWKCryptoPresentation.swift @@ -60,11 +60,6 @@ public extension JWK { throw JWK.Error.missingYComponent } let data = x + y - print(self.keyID) - print(x.toHexString()) - print(x.count) - print(y.toHexString()) - print(y.count) switch type { case is P256.KeyAgreement.PublicKey.Type: return try P256.KeyAgreement.PublicKey(rawRepresentation: data) as! T diff --git a/Sources/JSONWebAlgorithms/CryptoImplementation/KeyGeneration/EC/secp256k1+KeyGeneration.swift b/Sources/JSONWebAlgorithms/CryptoImplementation/KeyGeneration/EC/secp256k1+KeyGeneration.swift index 648d5db..08f748d 100644 --- a/Sources/JSONWebAlgorithms/CryptoImplementation/KeyGeneration/EC/secp256k1+KeyGeneration.swift +++ b/Sources/JSONWebAlgorithms/CryptoImplementation/KeyGeneration/EC/secp256k1+KeyGeneration.swift @@ -36,9 +36,9 @@ struct Secp256k1KeyGeneration: KeyGeneration { public func generateKeyPairJWK(purpose: KeyGenerationPurpose) throws -> JWK { switch purpose { case .signing: - return try secp256k1.Signing.PrivateKey().jwkRepresentation + return try secp256k1.Signing.PrivateKey(format: .uncompressed).jwkRepresentation case .keyAgreement: - return try secp256k1.KeyAgreement.PrivateKey().jwkRepresentation + return try secp256k1.KeyAgreement.PrivateKey(format: .uncompressed).jwkRepresentation } } }