我正在尝试集成KMS (亚马逊)和以太签署typedData,并在智能合同中验证签名者。
私钥作为环境变量保存。因为这可能是一个安全问题,而且可能会失去锁定在其中的资金。签字人也是smart合同的所有者。
我不想用存储在服务器中的私钥对msg进行签名,而是使用存储在KMS中的私钥对数据进行签名。我以前已经集成了KMS来签署事务和发送,但是我不知道如何处理输入的数据。
const { ethers } = require("ethers");
let privateKey = "";
let signer = new ethers.Wallet(privateKey);
let signature = await signer._signTypedData( {
name: "name",
version: "1.0.0",
chainId: 4,
verifyingContract: ""
},
{
Request: [
{
name: "id",
type: "string",
},
{
name: "amount",
type: "uint256",
},
{
name: "wallet",
type: "address",
},
],
},
{
id: "id",
amount: 1,
wallet: ""
});签名样本输出:
0x8dea897d8a25b32a354d41c1c6d96aa6c19466a8a743fc41c3c3da97d7cd9fb131f0e905b96c4bfb560a74fb52ae454ca1a73b7189710fc6a35236d0bc11d1d51c以下是我迄今尝试过的:
"KeyId在params中失踪“
有人能告诉我如何做到这一点吗?我不能更改类型化数据的JSON模式,因为契约已经部署。
感谢你的时间。请评论一下。
谢谢!
发布于 2022-06-25 21:06:08
您可以使用这个回购程序,它是PRs https://github.com/rjchow/ethers-aws-kms-signer
https://ethereum.stackexchange.com/questions/121467
复制相似问题