简体   繁体   English

GCP KMS 导入以太坊钱包私钥

[英]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.

相关问题 将公钥导入 Google KMS - Importing public Key to Google KMS 授予在 GCP 中使用特定 KMS 密钥的权限 - Grant permission to use specific KMS key in GCP 强制在 KMS 中使用 EKM(外部管理密钥)的 GCP 政策 - GCP policy to enforce to use EKM (externally managed key) in KMS GCP Cloud KMS - 自定义密钥,可以进行灾难恢复吗? - GCP Cloud KMS - custom key, disaster recovery possible? 使用 BYOK 解决方案使用 GCP_KMS 管理密钥轮换 - Managing key rotations with GCP_KMS with BYOK solution 使用 GCP KMS 自动解封 Vault - Autounseal Vault with GCP KMS 将预包装密钥导入 Cloud KMS 时出现问题 - Problem Importing a pre-wrapped key into Cloud KMS GCP - DLP - 解密失败:使用 KMS 封装的密钥时密文无效错误 - GCP - DLP - Decryption failed: the ciphertext is invalid error when using KMS wrapped key GCP KMS加密环境变量并将加密的密钥通过cloudbuild.yaml传递给Google App Engine - GCP kms encrypt env var and passing encrypted key through cloudbuild.yaml to google app engine 使用 helm 和 gcp_kms 加密 secrets.yml 文件时密钥的权限被拒绝 - Permission denied on key when encrypting secrets.yml file with helm and gcp_kms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM