From 1867617acf42f599a4ac2546818fcb45c26a5ff2 Mon Sep 17 00:00:00 2001 From: Franck R Date: Wed, 23 Feb 2022 13:06:13 +1100 Subject: [PATCH] Re-work signature data (#557) --- examples/eth-pm-wallet-encryption/src/crypto.ts | 7 ++++--- examples/eth-pm/src/crypto.ts | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/eth-pm-wallet-encryption/src/crypto.ts b/examples/eth-pm-wallet-encryption/src/crypto.ts index 1dd44f93aa..2d23b57da2 100644 --- a/examples/eth-pm-wallet-encryption/src/crypto.ts +++ b/examples/eth-pm-wallet-encryption/src/crypto.ts @@ -36,11 +36,12 @@ export async function createPublicKeyMessage( function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) { return JSON.stringify({ domain: { - chainId: 1, name: "Ethereum Private Message over Waku", version: "1", }, message: { + message: + "By signing this message you certify that messages addressed to `ownerAddress` must be encrypted with `encryptionPublicKey`", encryptionPublicKey: bytesToHex(encryptionPublicKey), ownerAddress: fromAddress, }, @@ -50,9 +51,9 @@ function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) { EIP712Domain: [ { name: "name", type: "string" }, { name: "version", type: "string" }, - { name: "chainId", type: "uint256" }, ], PublishEncryptionPublicKey: [ + { name: "message", type: "string" }, { name: "encryptionPublicKey", type: "string" }, { name: "ownerAddress", type: "string" }, ], @@ -72,7 +73,7 @@ export async function signEncryptionKey( const msgParams = buildMsgParams(encryptionPublicKey, fromAddress); const result = await providerRequest({ - method: "eth_signTypedData_v3", + method: "eth_signTypedData_v4", params: [fromAddress, msgParams], from: fromAddress, }); diff --git a/examples/eth-pm/src/crypto.ts b/examples/eth-pm/src/crypto.ts index a854c74a9e..18c42cb714 100644 --- a/examples/eth-pm/src/crypto.ts +++ b/examples/eth-pm/src/crypto.ts @@ -57,11 +57,12 @@ export async function createPublicKeyMessage( function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) { return JSON.stringify({ domain: { - chainId: 1, name: "Ethereum Private Message over Waku", version: "1", }, message: { + message: + "By signing this message you certify that messages addressed to `ownerAddress` must be encrypted with `encryptionPublicKey`", encryptionPublicKey: bytesToHex(encryptionPublicKey), ownerAddress: fromAddress, }, @@ -71,9 +72,9 @@ function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) { EIP712Domain: [ { name: "name", type: "string" }, { name: "version", type: "string" }, - { name: "chainId", type: "uint256" }, ], PublishEncryptionPublicKey: [ + { name: "message", type: "string" }, { name: "encryptionPublicKey", type: "string" }, { name: "ownerAddress", type: "string" }, ], @@ -93,7 +94,7 @@ export async function signEncryptionKey( const msgParams = buildMsgParams(encryptionPublicKey, fromAddress); const result = await providerRequest({ - method: "eth_signTypedData_v3", + method: "eth_signTypedData_v4", params: [fromAddress, msgParams], from: fromAddress, });