[英]GCP KMS Importing Ethereum Wallet private key
I have an Ethereum private key which consists of 64 bytes.我有一个由 64 个字节组成的以太坊私钥。 I need to use this key for asymmetric encryption using p256k1 elliptic curve (the signing algorithm used on Ethereum).
我需要使用 p256k1 椭圆曲线(以太坊上使用的签名算法)将此密钥用于非对称加密。
This is supported on KMS now in the process of importing my key, I came across the following section in the GCP KMS documentation.现在在导入我的密钥的过程中,KMS 支持这一点,我在 GCP KMS 文档中遇到了以下部分。
It stipulates the key must be in PKCS#8 format.它规定密钥必须是 PKCS#8 格式。 I have tried a couple of commands using openssl.
我已经尝试了几个使用 openssl 的命令。 like the following
像下面这样
openssl pkcs8 -topk8 -in ./private.pem -outform DER -out ./private.key
Here is my private.pem
format这是我的
private.pem
格式
-----BEGIN PRIVATE KEY-----
64_CHAR_PRIVATE_KEY_PASTED_HERE
-----END PRIVATE KEY-----
I understand this might not be the correct way to convert as errors happen when I run this command.我知道这可能不是正确的转换方式,因为在我运行此命令时会发生错误。
unable to load key
4456490668:error:0DFFF07B:asn1 encoding routines:CRYPTO_internal:header too long:/System/Volumes/Data/SWE/macOS/BuildRoots/b8ff8433dc/Library/Caches/com.apple.xbs/Sources/libressl/libressl-75/libressl-2.8/crypto/asn1/asn1_lib.c:152:
4456490668:error:0DFFF066:asn1 encoding routines:CRYPTO_internal:bad object header:/System/Volumes/Data/SWE/macOS/BuildRoots/b8ff8433dc/Library/Caches/com.apple.xbs/Sources/libressl/libressl-75/libressl-2.8/crypto/asn1/tasn_dec.c:1132:
4456490668:error:0DFFF03A:asn1 encoding routines:CRYPTO_internal:nested asn1 error:/System/Volumes/Data/SWE/macOS/BuildRoots/b8ff8433dc/Library/Caches/com.apple.xbs/Sources/libressl/libressl-75/libressl-2.8/crypto/asn1/tasn_dec.c:317:Type=PKCS8_PRIV_KEY_INFO
4456490668:error:09FFF00D:PEM routines:CRYPTO_internal:ASN1 lib:/System/Volumes/Data/SWE/macOS/BuildRoots/b8ff8433dc/Library/Caches/com.apple.xbs/Sources/libressl/libressl-75/libressl-2.8/crypto/pem/pem_pkey.c:143:
My goal remains to be able to import the key into KMS as securely as possible.我的目标仍然是能够尽可能安全地将密钥导入 KMS。 Thank you in advance for your responses :D
提前感谢您的回复:D
So for anyone, who might deal with something similar.所以对于任何可能处理类似事情的人来说。 John Hanley pointed me to this link which describes the process of basically converting a Ethereum private key into a EC PEM or DER encoded key file.
John Hanley向我指出这个链接,它描述了将以太坊私钥基本上转换为 EC PEM 或 DER 编码的密钥文件的过程。
A couple of strings need to be added (The linked answer does a good job at explaining it).需要添加几个字符串(链接的答案很好地解释了它)。 I was able to then convert EC PEM to PKCS#8 DER format which is what I needed for importing the key to GCP KMS.
然后,我能够将 EC PEM 转换为 PKCS#8 DER 格式,这是将密钥导入 GCP KMS 所需的格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.