You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuweni.apache.org by to...@apache.org on 2020/11/24 07:23:39 UTC
[incubator-tuweni] branch master updated: Expose the bytes of the
public key
This is an automated email from the ASF dual-hosted git repository.
toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git
The following commit(s) were added to refs/heads/master by this push:
new 92e8dd3 Expose the bytes of the public key
new f7da8b3 Merge pull request #173 from atoulme/expose_public_key_bytes
92e8dd3 is described below
commit 92e8dd3323049f97b7d94982fb25c47505be1317
Author: Antoine Toulme <an...@lunar-ocean.com>
AuthorDate: Mon Nov 23 22:53:49 2020 -0800
Expose the bytes of the public key
---
.../main/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecord.kt | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecord.kt b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecord.kt
index 9e0d974..2ed1bca 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecord.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/EthereumNodeRecord.kt
@@ -264,9 +264,17 @@ class EthereumNodeRecord(
* @return the ENR public key
*/
fun publicKey(): SECP256K1.PublicKey {
+ return SECP256K1.PublicKey.fromBytes(publicKeyBytes())
+ }
+
+ /**
+ * The ENR public key entry bytes
+ * @return the ENR public key bytes
+ */
+ fun publicKeyBytes(): Bytes {
val keyBytes = data["secp256k1"] ?: throw InvalidNodeRecordException("Missing secp256k1 entry")
val ecPoint = SECP256K1.Parameters.CURVE.getCurve().decodePoint(keyBytes.toArrayUnsafe())
- return SECP256K1.PublicKey.fromBytes(Bytes.wrap(ecPoint.getEncoded(false)).slice(1))
+ return Bytes.wrap(ecPoint.getEncoded(false)).slice(1)
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tuweni.apache.org
For additional commands, e-mail: commits-help@tuweni.apache.org