mirror of https://github.com/waku-org/js-waku.git
Re-work signature data (#557)
This commit is contained in:
parent
c1c1858175
commit
1867617acf
|
@ -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,
|
||||||
});
|
});
|
||||||
|
|
|
@ -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,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue