diff --git a/handlers/EventSigning.jsx b/handlers/EventSigning.jsx index 8dc3916..4d0bedf 100644 --- a/handlers/EventSigning.jsx +++ b/handlers/EventSigning.jsx @@ -33,6 +33,11 @@ export default function EventSigning({value}) { return null } }, [value, privateKey]) + let eventHash = useComputedState(() => getEventHash(evt), [value]) + let isValidHash = useComputedState( + () => evt.id === eventHash, + [value, eventHash] + ) let isValidSignature = useComputedState(async () => { if (evt.id && evt.sig) { try { @@ -54,28 +59,35 @@ export default function EventSigning({value}) { {serializeEvent(evt)} - {getEventHash(evt)} + {eventHash} - {evt.sig ? ( - - {isValidSignature?.toString() || ''} - - ) : ( - <> - - setPrivateKey(e.target.value.toLowerCase())} - />{' '} - {privateKeyIsValid ? 'valid' : 'invalid'} + + {isValidHash?.toString()} + + {isValidHash && + (evt.sig ? ( + + {isValidSignature?.toString() || ''} - {publicKey} - {privateKeyIsValid ? signature : ''} - - )} + ) : ( + <> + + setPrivateKey(e.target.value.toLowerCase())} + />{' '} + {privateKeyIsValid ? 'valid' : 'invalid'} + + {publicKey} + {privateKeyIsValid ? signature : ''} + + ))} ) }