diff --git a/src/components/page/channel/TextChannel.tsx b/src/components/page/channel/TextChannel.tsx
index f20e413..33638e2 100644
--- a/src/components/page/channel/TextChannel.tsx
+++ b/src/components/page/channel/TextChannel.tsx
@@ -7,6 +7,7 @@ import { ClientMeta, StoredMessage } from "@/lib/types";
import { base58 } from "@scure/base";
import { useEffect, useRef, useState } from "react";
import * as ed from "@noble/ed25519";
+import { CircleXIcon } from "lucide-react";
export default function TextChannel({
appRef,
@@ -64,13 +65,13 @@ export default function TextChannel({
-
{messages &&
Object.entries(messages)
.sort((a, b) => b[1].timestamp - a[1].timestamp)
.map(([_, message]) => (
))}
+
@@ -107,15 +108,32 @@ export function TextMessage({
const [author, setAuthor] = useState
(null);
+ const [verified, setVerified] = useState(true);
+
useEffect(() => {
+ const serverPubKey =
+ appRef.current?.server?.serverPublicKey &&
+ base58.encode(appRef.current?.server?.serverPublicKey);
+
+ if (!serverPubKey) return;
+
+ const authorPubKey = base58.decode(message.author);
+
+ setVerified(
+ ed.verify(
+ base58.decode(message.signature),
+ new TextEncoder().encode(
+ `${message.timestamp}@${serverPubKey}@${message.content}`,
+ ),
+ authorPubKey,
+ ),
+ );
+
const currentAccount = appRef.current?.getAccount();
-
if (currentAccount) {
- const pubKey = base58.encode(
- ed.getPublicKey(base58.decode(currentAccount.privateKey)),
- );
+ const pubKey = ed.getPublicKey(base58.decode(currentAccount.privateKey));
- if (pubKey === message.author) {
+ if (pubKey === authorPubKey) {
setAuthor(currentAccount.meta);
}
}
@@ -134,7 +152,10 @@ export function TextMessage({
-
+
+ {!verified && (
+
+ )}
{author?.displayName || message.author.slice(0, 8)}
{time}