From 47e876032d8c5f1fe6ebd8ef163e7ab8a574c592 Mon Sep 17 00:00:00 2001 From: Auqib92 Date: Wed, 28 Jun 2023 15:50:38 +0100 Subject: [PATCH 1/2] support for accepting Secret Key in Hex --- ellipticcurve/privateKey.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ellipticcurve/privateKey.js b/ellipticcurve/privateKey.js index fcd469e..cf3671a 100644 --- a/ellipticcurve/privateKey.js +++ b/ellipticcurve/privateKey.js @@ -106,6 +106,10 @@ class PrivateKey { static fromString (string, curve=EcdsaCurve.secp256k1) { return new PrivateKey(curve, BinaryAscii.numberFromString(string)); }; + // Support for Accepting Secert Key in Hex + static fromHexString(string, curve=EcdsaCurve.secp256k1) { + return new PrivateKey(curve, BinaryAscii.numberFromHex(string)); + }; }; From 2676959d78c50f15188e362555a24910fcc3d797 Mon Sep 17 00:00:00 2001 From: Auqib92 Date: Wed, 28 Jun 2023 16:40:50 +0100 Subject: [PATCH 2/2] Added support to view Private Key in hex --- ellipticcurve/privateKey.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ellipticcurve/privateKey.js b/ellipticcurve/privateKey.js index cf3671a..8cf7598 100644 --- a/ellipticcurve/privateKey.js +++ b/ellipticcurve/privateKey.js @@ -28,7 +28,9 @@ class PrivateKey { toString () { return BinaryAscii.stringFromNumber(this.secret, this.curve.length()); }; - + toHexString () { + return this.secret.toString(16); + }; toDer () { let encodedPublicKey = this.publicKey().toString(true);