Skip to content
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

Verify personal message simply verify bytes, do not parse as bcs #1

Merged
merged 6 commits into from
Feb 8, 2024

Conversation

nikos-terzo
Copy link
Contributor

@nikos-terzo nikos-terzo commented Feb 7, 2024

Trying to verify a personal message, I would get an error:

{
  "error": "Parsing error"
}

After searching it seems that in zklogin signature verification tries to parse message data as bcs instead of directly constructing the message from data.
"Externally" tested with the following code here.

// use wallet to sign personal message
    useEffect(() => {
        async function signTestMessage() {
            if (!account) {
                return;
            }
            const inputString = "ABCD";
            const encoder = new TextEncoder();
            const bytes = encoder.encode(inputString);

            const input = {
                message: bytes,
                account
            }
            if (wallet.isConnected) {
                let signed = await wallet.currentWallet.features["sui:signPersonalMessage"]?.signPersonalMessage(input);
                console.log(signed);
            }
        }
        signTestMessage();
    }, []);

using a zklogin account and manually constructing the curl request from the console.log output.
curl request:

curl -X POST 0.0.0.0:3000/verify -H 'Content-Type: application/json' -d '{"signature": "BQNNMTE3NDQ0MDk1NTQ2NTgwOTcxMTczNDQ0MDQzMzE0MzY4MTY3NjMwMzExMjc2NjQwMTE4Nzc5NzIyMjg1NzAxMTkxMDA5Njg3NDQ5OTdMODY0OTUyOTc0OTcxMzQ1NDA4MDAxOTE5NjMwNzY3ODM2NjI2NzE1NzI4MDA2MDI2NTU0OTg0MzE0MDY0ODk4OTg3MzY5MDU0NTIzNgExAwJMMTI5NjMzOTgyNTYzODI1MzU3MjczNTUyNzMxNzY2MzkwNDcwNTIyNjc2MzMwMDkyMzY0MjY4NjM4MzkyNTcyMDQwOTMyNDA5OTk0Nk0yMTE4MTc1NzczNjU5MjQ4NDk1MzA3NTk0MzY2NTQyMDcxMjQ3NjY3Mjc1NTE1MjcyOTU4NTAzNTg0NjgwNTc4MTM1MDE1MTAwMzA3MgJNMTQ0MTcxODA5MTg0NDg3MzEzNzk1OTQ5NTUwOTU2NzEyNDMxODk5NDc4NzYyMTQzNjgwNjg4MDczMzM2NzkwMzE4NTkxNzEyNjQwNzZNMTczNTk2MTE2NzUxMTkxMTQyNDEzMzMxNTE5Mzc5NjI0OTA5NDAwMTMxMTk2OTg3OTkzMzYyMzA5MDg2ODMwNTE5NzE4Njk5NDkzNDACATEBMANNMTE5NDQ1MTM0NjY2MjUwNDU1MTE3MTgyMjU4NDc2NjQ5MDQxMzIxMjQwNDIwMjc1NjgzMDE1NjIxODYyODkzNDUyNzk1NzQzMDEzODVNMTgwNDYwMjYzMTQyODI3NTAxMzQxNDQxMDAyOTM1OTMyNTI3NDkwNzYwNDUwMzE3Nzc2MjkwOTAwNjM3NjEwNTcyOTA2MjI1MzY3OTgBMTF5SnBjM01pT2lKb2RIUndjem92TDJGalkyOTFiblJ6TG1kdmIyZHNaUzVqYjIwaUxDAWZleUpoYkdjaU9pSlNVekkxTmlJc0ltdHBaQ0k2SW1Ka1l6UmxNVEE1T0RFMVpqUTJPVFEyTUdVMk0yUXpOR05rTmpnME1qRTFNVFE0WkRkaU5Ua2lMQ0owZVhBaU9pSktWMVFpZlFMNTE4NjI2OTEwMDE2NTU4ODIwMTA3MzgwOTYyOTQxMDAxNTY5MDYxNTMzNzA3OTMxNTcyOTgzMTI4MzE5NzM1Mjg4ODMwMjUzNjU4NxIBAAAAAAAAYQCpZbY+oPW/Lt2ohkZxVmy0HW9VY4gYw9D7wQAqyuUlmIXpR4CChRXOOCXYFVb3DQ9g2R7CAwUUp57hWVbKkvIAzxWxPUz5w6fv8GuE2ZrJXl/STltjQJ4NOAhSBgDISHo=", "bytes": "QUJDRA==", "intent_scope": 3, "curr_epoch": 272, "network": "Testnet", "author": "0x1933a3f2f6599e0b0aa459c9bb8c0a711bc41ee147c7e5c95cfc895542c1b95d"}' | jq

@nikos-terzo
Copy link
Contributor Author

Closed as message should indeed be bcs-serialized.

@nikos-terzo nikos-terzo deleted the nikost/fix-personal-message branch February 7, 2024 14:12
@nikos-terzo nikos-terzo restored the nikost/fix-personal-message branch February 7, 2024 15:02
@nikos-terzo nikos-terzo reopened this Feb 7, 2024
@joyqvq joyqvq force-pushed the nikost/fix-personal-message branch from 6732d5b to 0c0e4cf Compare February 8, 2024 15:49
@joyqvq joyqvq merged commit 3139027 into main Feb 8, 2024
5 of 6 checks passed
@joyqvq joyqvq deleted the nikost/fix-personal-message branch February 8, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants