Re-work signature data (#557)

This commit is contained in:
Franck R 2022-02-23 13:06:13 +11:00 committed by GitHub
parent c1c1858175
commit 1867617acf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -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,
});

View File

@ -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,
});