-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Example for signMessage #434
Comments
So, in building this functionality out for Meteor, I've figured out I can verify the returned payload like so: const owner = await wallet.verifyOwner({
message: "test message for verification",
});
const publicKeyString = `ed25519:${bs58.encode(
Buffer.from(owner.publicKey, "base64"),
)}`;
const createdPublicKey = utils.PublicKey.from(publicKeyString);
const recreatedMessage: any = {
...owner,
};
delete recreatedMessage.signature;
const stringified = JSON.stringify(recreatedMessage);
const verifiedSignature = createdPublicKey.verify(
new Uint8Array(sha256.array(stringified)),
Buffer.from(verifyResponse.payload.verifiedOwner.signature, "base64"),
); Here This is based off of the interfaces given inside the code here in Wallet Selector, and that of the Near Wallet github. I think there are some worries about this whole interface. The first one being that because the message that needs to be validated against is actually not the passed message itself, but its an object of the returned value without the signature applied to const data = {
accountId,
message,
blockId: blockInfo.header.hash,
publicKey: Buffer.from(publicKey.data).toString('base64'),
keyType: publicKey.keyType
}; This object has to be recreated again, perfectly and in the exact same property order to create the "payload" to verify that the message was signed correctly. If the properties are not in the exact same order, it will fail- because the I understand that the message is not encoded directly because of security concerns. But surely there could have been a more "stable" data structure to use in this case. Perhaps just an array with the interface of And on the next note- why are we not just sending the public key as a There is also another concern about the return {
...data,
signature: Buffer.from(signed.signed.signature).toString('base64'),
keyType: signed.signed.publicKey.keyType
}; As you can see, it is being overridden by All in all, it feels like this interface is quite important to get done in a future proof and standardized way for all future wallets and dapps to implement exactly the same way. I haven't seen too much about the standardization around the data structures here, besides some mentions inside github issues. |
NEP413 is ready to be reviewed. This means we could start implementing it, since no major changes are expected to the interface. |
@gagdiez, it's a bit confusing for us since the NEP changed from the initial proposal. We see that the name of the function has been changed from What will be the name of the function in wallets? This is going to be a breaking change either way in the wallet selector since even the arguments and their types this function takes have been changed. |
@kujtimprenkuSQA the name has changed to The new naming convention should be used, thus renaming it everywhere. |
Closing this issue as the PR for Yesterday a new version Currently only Meteor Wallet supports this feature as per NEP near/NEPs#413. |
Hi,
Could it be possible for the Guestbook example to do more than just alert out the result of the
verifyOwner()
API method, currently it looks like this:From what I can gather, this won't throw any errors if the signing was done incorrectly. It would be great if it actually ran some kind of authentication to make sure that the API is working as intended.
I'm busy building out the API for Meteor, and it seems like I can just use the
account.connection.signer.signMessage()
method which is provided by the Near JS library directly in our dapp-side code- but I think that its probably signing the message with the wrong private key (the local key for the Dapp)- and I'm guessing that thisverifyOwner()
method actually requires that the message is signed by a different private key- one that is only accessible from inside the Wallet application.If I could have some confirmation on this it would be great- and for our testing, it would be great if there was an easy way we could test this using the Guestbook application as well.
I'd be happy to make a PR for this as well, I just need to be pointed a bit in the right direction here.
Thanks!
The text was updated successfully, but these errors were encountered: