|
@@ -1,9 +1,9 @@
|
|
|
import { Button } from '@mui/material';
|
|
import { Button } from '@mui/material';
|
|
|
|
|
+import { ed25519 } from '@noble/curves/ed25519';
|
|
|
import { useWallet } from '@solana/wallet-adapter-react';
|
|
import { useWallet } from '@solana/wallet-adapter-react';
|
|
|
import bs58 from 'bs58';
|
|
import bs58 from 'bs58';
|
|
|
import type { FC } from 'react';
|
|
import type { FC } from 'react';
|
|
|
import React, { useCallback } from 'react';
|
|
import React, { useCallback } from 'react';
|
|
|
-import { sign } from 'tweetnacl';
|
|
|
|
|
import { useNotify } from './notify';
|
|
import { useNotify } from './notify';
|
|
|
|
|
|
|
|
export const SignMessage: FC = () => {
|
|
export const SignMessage: FC = () => {
|
|
@@ -17,12 +17,11 @@ export const SignMessage: FC = () => {
|
|
|
|
|
|
|
|
const message = new TextEncoder().encode('Hello, world!');
|
|
const message = new TextEncoder().encode('Hello, world!');
|
|
|
const signature = await signMessage(message);
|
|
const signature = await signMessage(message);
|
|
|
- if (!sign.detached.verify(message, signature, publicKey.toBytes()))
|
|
|
|
|
- throw new Error('Message signature invalid!');
|
|
|
|
|
|
|
+ if (!ed25519.verify(signature, message, publicKey.toBytes())) throw new Error('Message signature invalid!');
|
|
|
|
|
|
|
|
notify('success', `Message signature: ${bs58.encode(signature)}`);
|
|
notify('success', `Message signature: ${bs58.encode(signature)}`);
|
|
|
} catch (error: any) {
|
|
} catch (error: any) {
|
|
|
- notify('error', `Message signing failing: ${error?.message}`);
|
|
|
|
|
|
|
+ notify('error', `Sign Message failed: ${error?.message}`);
|
|
|
}
|
|
}
|
|
|
}, [publicKey, signMessage, notify]);
|
|
}, [publicKey, signMessage, notify]);
|
|
|
|
|
|