This is about the verification of sui wallet.
import {useWallet} from '@suiet/wallet-kit'
import * as tweetnacl from 'tweetnacl'
function App() {
const wallet = useWallet();
async function handleSignMsg() {
try {
const msg = 'Hello world!'
// convert string to Uint8Array
const msgBytes = new TextEncoder().encode(msg)
// call wallet's signMessage function
const result = await wallet.signMessage({
message: msgBytes
})
// verify signature with publicKey and SignedMessage (params are all included in result)
const verifyResult = await wallet.verifySignedMessage(result, wallet.account.publicKey)
if (!verifyResult) {
console.log('signMessage succeed, but verify signedMessage failed')
} else {
console.log('signMessage succeed, and verify signedMessage succeed!')
}
} catch (e) {
console.error('signMessage failed', e)
}
}
return (
<button onClick={handleSignMsg}> Sign Message </button>
)
}
Using the js wallet.signMessage, you can check out two pieces of data, as follows.
APr0hJEXc9s9FKHeubNzLkiOJd03thIJs9dnvL4M5dzEfPmzUXWrV57AM1w2k4xHdk6+R+GebKyK30Ob5oFMJQQv/sC0XycR6VEJ+JMYVNj00LdzN2XnylAv6rLwUDov/g==
messageBytes: "SGVsbG8gd29ybGQh"
Using the wallet. VerifySignedMessage to verify these two data are correct.Because I am a golang developer, how to verify in golang. I just want to verify the result of wallet.signMessage in golang.