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) { function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) {
return JSON.stringify({ return JSON.stringify({
domain: { domain: {
chainId: 1,
name: "Ethereum Private Message over Waku", name: "Ethereum Private Message over Waku",
version: "1", version: "1",
}, },
message: { message: {
message:
"By signing this message you certify that messages addressed to `ownerAddress` must be encrypted with `encryptionPublicKey`",
encryptionPublicKey: bytesToHex(encryptionPublicKey), encryptionPublicKey: bytesToHex(encryptionPublicKey),
ownerAddress: fromAddress, ownerAddress: fromAddress,
}, },
@ -50,9 +51,9 @@ function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) {
EIP712Domain: [ EIP712Domain: [
{ name: "name", type: "string" }, { name: "name", type: "string" },
{ name: "version", type: "string" }, { name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
], ],
PublishEncryptionPublicKey: [ PublishEncryptionPublicKey: [
{ name: "message", type: "string" },
{ name: "encryptionPublicKey", type: "string" }, { name: "encryptionPublicKey", type: "string" },
{ name: "ownerAddress", type: "string" }, { name: "ownerAddress", type: "string" },
], ],
@ -72,7 +73,7 @@ export async function signEncryptionKey(
const msgParams = buildMsgParams(encryptionPublicKey, fromAddress); const msgParams = buildMsgParams(encryptionPublicKey, fromAddress);
const result = await providerRequest({ const result = await providerRequest({
method: "eth_signTypedData_v3", method: "eth_signTypedData_v4",
params: [fromAddress, msgParams], params: [fromAddress, msgParams],
from: fromAddress, from: fromAddress,
}); });

View File

@ -57,11 +57,12 @@ export async function createPublicKeyMessage(
function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) { function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) {
return JSON.stringify({ return JSON.stringify({
domain: { domain: {
chainId: 1,
name: "Ethereum Private Message over Waku", name: "Ethereum Private Message over Waku",
version: "1", version: "1",
}, },
message: { message: {
message:
"By signing this message you certify that messages addressed to `ownerAddress` must be encrypted with `encryptionPublicKey`",
encryptionPublicKey: bytesToHex(encryptionPublicKey), encryptionPublicKey: bytesToHex(encryptionPublicKey),
ownerAddress: fromAddress, ownerAddress: fromAddress,
}, },
@ -71,9 +72,9 @@ function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) {
EIP712Domain: [ EIP712Domain: [
{ name: "name", type: "string" }, { name: "name", type: "string" },
{ name: "version", type: "string" }, { name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
], ],
PublishEncryptionPublicKey: [ PublishEncryptionPublicKey: [
{ name: "message", type: "string" },
{ name: "encryptionPublicKey", type: "string" }, { name: "encryptionPublicKey", type: "string" },
{ name: "ownerAddress", type: "string" }, { name: "ownerAddress", type: "string" },
], ],
@ -93,7 +94,7 @@ export async function signEncryptionKey(
const msgParams = buildMsgParams(encryptionPublicKey, fromAddress); const msgParams = buildMsgParams(encryptionPublicKey, fromAddress);
const result = await providerRequest({ const result = await providerRequest({
method: "eth_signTypedData_v3", method: "eth_signTypedData_v4",
params: [fromAddress, msgParams], params: [fromAddress, msgParams],
from: fromAddress, from: fromAddress,
}); });