From 05e8308ef05bd657cca1fb07e683f8f8a6571929 Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Mon, 12 Dec 2022 13:34:41 +0530 Subject: [PATCH] chore: update signature message and use single const --- rln-js/index.html | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/rln-js/index.html b/rln-js/index.html index e72b571..f658084 100644 --- a/rln-js/index.html +++ b/rln-js/index.html @@ -83,7 +83,6 @@

Key

none -

Commitment

@@ -209,6 +208,9 @@ let retrievedRLNEvents = false; const rlnInstancePromise = create(); + const signatureMessage = + "The signature of this message will be used to generate your RLN credentials. Anyone accessing it may send messages on your behalf, please only share with the RLN dApp"; + // Load zero-kit WASM blob. statusSpan.innerText = "WASM Blob download in progress..."; @@ -254,7 +256,6 @@ ); importManually.disabled = !( - membershipIdInput.value && identityKeyInput.value && commitmentKeyInput.value @@ -275,10 +276,9 @@ generateCredsButton.onclick = async () => { // sign message with ethers const signer = provider.getSigner(); - const message = - "The signature of this message will be used to generate your RLN credentials. Ensure that this signature is only shared with the RLN dApp."; - const signature = await signer.signMessage(message); - console.log({ signature }); + + const signature = await signer.signMessage(signatureMessage); + // provide the signature as a seed membershipKey = rlnInstance.generateSeededMembershipKey(signature); @@ -290,7 +290,6 @@ commitmentKeyInput.onchange = updateFields; importManually.onclick = () => { - const idKey = utils.hexToBytes(identityKeyInput.value); const idCommitment = utils.hexToBytes(commitmentKeyInput.value); membershipKey = new MembershipKey(idKey, idCommitment); @@ -301,9 +300,7 @@ importFromWalletButton.onclick = async () => { const signer = provider.getSigner(); - const message = - "The signature of this message will be used to generate your RLN credentials. Ensure that this signature is only shared with the RLN dApp."; - const signature = await signer.signMessage(message); + const signature = await signer.signMessage(signatureMessage); membershipKey = await rlnInstance.generateSeededMembershipKey( signature @@ -386,7 +383,6 @@ checkChain(network.chainId); importFromWalletButton.disabled = false; - } catch (e) { console.log("No web3 provider available", e); }