318 lines
10 KiB
HTML
318 lines
10 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Rust WebAssembly Crypto Example</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
line-height: 1.6;
|
|
}
|
|
.container {
|
|
border: 1px solid #ddd;
|
|
padding: 20px;
|
|
border-radius: 5px;
|
|
margin-bottom: 20px;
|
|
}
|
|
button {
|
|
background-color: #4CAF50;
|
|
border: none;
|
|
color: white;
|
|
padding: 10px 20px;
|
|
text-align: center;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
font-size: 16px;
|
|
margin: 4px 2px;
|
|
cursor: pointer;
|
|
border-radius: 4px;
|
|
}
|
|
button.secondary {
|
|
background-color: #6c757d;
|
|
}
|
|
button.danger {
|
|
background-color: #dc3545;
|
|
}
|
|
input, textarea, select {
|
|
padding: 8px;
|
|
margin: 5px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
width: 80%;
|
|
}
|
|
.result {
|
|
margin-top: 10px;
|
|
padding: 10px;
|
|
background-color: #f5f5f5;
|
|
border-radius: 4px;
|
|
word-break: break-all;
|
|
}
|
|
.key-display {
|
|
font-family: monospace;
|
|
font-size: 12px;
|
|
word-break: break-all;
|
|
}
|
|
.note {
|
|
font-style: italic;
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 15px;
|
|
}
|
|
.form-group label {
|
|
display: block;
|
|
margin-bottom: 5px;
|
|
font-weight: bold;
|
|
}
|
|
.status {
|
|
padding: 10px;
|
|
margin-bottom: 15px;
|
|
border-radius: 4px;
|
|
}
|
|
.status.logged-in {
|
|
background-color: #d4edda;
|
|
color: #155724;
|
|
}
|
|
.status.logged-out {
|
|
background-color: #f8d7da;
|
|
color: #721c24;
|
|
}
|
|
.hidden {
|
|
display: none;
|
|
}
|
|
.nav-links {
|
|
margin-bottom: 20px;
|
|
}
|
|
.nav-links a {
|
|
margin-right: 15px;
|
|
text-decoration: none;
|
|
color: #007bff;
|
|
}
|
|
.nav-links a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
.pubkey-container {
|
|
margin-top: 15px;
|
|
padding: 10px;
|
|
background-color: #f8f9fa;
|
|
border-radius: 4px;
|
|
border: 1px solid #ddd;
|
|
}
|
|
.pubkey-label {
|
|
font-weight: bold;
|
|
margin-bottom: 5px;
|
|
}
|
|
.pubkey-value {
|
|
font-family: monospace;
|
|
word-break: break-all;
|
|
background-color: #e9ecef;
|
|
padding: 8px;
|
|
border-radius: 4px;
|
|
margin-bottom: 10px;
|
|
border: 1px solid #ced4da;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Rust WebAssembly Crypto Example</h1>
|
|
|
|
<div class="nav-links">
|
|
<a href="index.html">Main Crypto Demo</a>
|
|
<a href="ethereum.html">Ethereum Demo</a>
|
|
</div>
|
|
|
|
<!-- Login/Space Management Section -->
|
|
<div class="container" id="login-container">
|
|
<h2>Key Space Management</h2>
|
|
|
|
<div id="login-status" class="status logged-out">
|
|
Status: Not logged in
|
|
</div>
|
|
|
|
<div id="login-form">
|
|
<div class="form-group">
|
|
<label for="space-name">Space Name:</label>
|
|
<input type="text" id="space-name" placeholder="Enter space name" />
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="space-password">Password:</label>
|
|
<input type="password" id="space-password" placeholder="Enter password" />
|
|
</div>
|
|
|
|
<div>
|
|
<button id="login-button">Login</button>
|
|
<button id="create-space-button">Create New Space</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="logout-form" class="hidden">
|
|
<div class="form-group">
|
|
<label>Current Space: <span id="current-space-name"></span></label>
|
|
</div>
|
|
<div class="form-group">
|
|
<button id="logout-button" class="danger">Logout</button>
|
|
<button id="delete-space-button" class="danger">Delete Space</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="manage-spaces-form">
|
|
<h3>Manage Spaces</h3>
|
|
<div class="form-group">
|
|
<label for="space-list">Available Spaces:</label>
|
|
<select id="space-list">
|
|
<option value="">-- Select a space --</option>
|
|
</select>
|
|
<button id="delete-selected-space-button" class="danger">Delete Selected Space</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="result" id="space-result">Result will appear here</div>
|
|
</div>
|
|
|
|
<!-- Keypair Management Section -->
|
|
<div class="container" id="keypair-management-container">
|
|
<h2>Keypair Management</h2>
|
|
|
|
<div id="keypair-form">
|
|
<div class="form-group">
|
|
<label for="keypair-name">Keypair Name:</label>
|
|
<input type="text" id="keypair-name" placeholder="Enter keypair name" />
|
|
<button id="create-keypair-button">Create Keypair</button>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="select-keypair">Select Keypair:</label>
|
|
<select id="select-keypair">
|
|
<option value="">-- Select a keypair --</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="result" id="keypair-management-result">Result will appear here</div>
|
|
<div class="key-display" id="selected-pubkey-display"></div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Message Signing</h2>
|
|
<div>
|
|
<textarea id="sign-message" placeholder="Enter message to sign" rows="3">Hello, this is a test message to sign</textarea>
|
|
<button id="sign-button">Sign Message</button>
|
|
</div>
|
|
<div class="result" id="signature-result">Signature will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Signature Verification</h2>
|
|
<div>
|
|
<textarea id="verify-message" placeholder="Enter message to verify" rows="3"></textarea>
|
|
<textarea id="verify-signature" placeholder="Enter signature to verify" rows="3"></textarea>
|
|
<button id="verify-button">Verify Signature</button>
|
|
</div>
|
|
<div class="result" id="verify-result">Verification result will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Verify with Public Key Only</h2>
|
|
<div>
|
|
<div class="form-group">
|
|
<label for="pubkey-verify-pubkey">Public Key (hex):</label>
|
|
<input type="text" id="pubkey-verify-pubkey" placeholder="Enter public key in hex format" />
|
|
</div>
|
|
<textarea id="pubkey-verify-message" placeholder="Enter message to verify" rows="3"></textarea>
|
|
<textarea id="pubkey-verify-signature" placeholder="Enter signature to verify" rows="3"></textarea>
|
|
<button id="pubkey-verify-button">Verify with Public Key</button>
|
|
</div>
|
|
<div class="result" id="pubkey-verify-result">Verification result will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Derive Public Key from Private Key</h2>
|
|
<div>
|
|
<div class="form-group">
|
|
<label for="derive-pubkey-privkey">Private Key (hex):</label>
|
|
<input type="text" id="derive-pubkey-privkey" placeholder="Enter private key in hex format" />
|
|
</div>
|
|
<button id="derive-pubkey-button">Derive Public Key</button>
|
|
</div>
|
|
<div class="result" id="derive-pubkey-result">Public key will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Asymmetric Encryption</h2>
|
|
<div>
|
|
<div class="form-group">
|
|
<label for="asymmetric-encrypt-pubkey">Recipient's Public Key (hex):</label>
|
|
<input type="text" id="asymmetric-encrypt-pubkey" placeholder="Enter recipient's public key in hex format" />
|
|
</div>
|
|
<textarea id="asymmetric-encrypt-message" placeholder="Enter message to encrypt" rows="3">This is a secret message that will be encrypted with asymmetric encryption</textarea>
|
|
<button id="asymmetric-encrypt-button">Encrypt with Public Key</button>
|
|
</div>
|
|
<div class="result" id="asymmetric-encrypt-result">Encrypted data will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Asymmetric Decryption</h2>
|
|
<div>
|
|
<div class="note">Note: Uses the currently selected keypair for decryption</div>
|
|
<textarea id="asymmetric-decrypt-ciphertext" placeholder="Enter ciphertext (hex)" rows="3"></textarea>
|
|
<button id="asymmetric-decrypt-button">Decrypt with Private Key</button>
|
|
</div>
|
|
<div class="result" id="asymmetric-decrypt-result">Decrypted data will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Symmetric Encryption</h2>
|
|
<div>
|
|
<textarea id="encrypt-message" placeholder="Enter message to encrypt" rows="3">This is a secret message that will be encrypted</textarea>
|
|
<button id="encrypt-button">Generate Key & Encrypt</button>
|
|
</div>
|
|
<div class="key-display" id="sym-key-display"></div>
|
|
<div class="note" id="nonce-display">Note: Nonce is handled internally</div>
|
|
<div class="result" id="encrypt-result">Encrypted data will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Symmetric Decryption</h2>
|
|
<div>
|
|
<input type="text" id="decrypt-key" placeholder="Enter key (hex)" />
|
|
<div class="note">Note: Nonce is now extracted automatically from the ciphertext</div>
|
|
<textarea id="decrypt-ciphertext" placeholder="Enter ciphertext (hex)" rows="3"></textarea>
|
|
<button id="decrypt-button">Decrypt</button>
|
|
</div>
|
|
<div class="result" id="decrypt-result">Decrypted data will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Password-Based Encryption</h2>
|
|
<div>
|
|
<div class="form-group">
|
|
<label for="password-encrypt-password">Password:</label>
|
|
<input type="password" id="password-encrypt-password" placeholder="Enter password" />
|
|
</div>
|
|
<textarea id="password-encrypt-message" placeholder="Enter message to encrypt" rows="3">This message will be encrypted with a password</textarea>
|
|
<button id="password-encrypt-button">Encrypt with Password</button>
|
|
</div>
|
|
<div class="result" id="password-encrypt-result">Encrypted data will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Password-Based Decryption</h2>
|
|
<div>
|
|
<div class="form-group">
|
|
<label for="password-decrypt-password">Password:</label>
|
|
<input type="password" id="password-decrypt-password" placeholder="Enter password" />
|
|
</div>
|
|
<textarea id="password-decrypt-ciphertext" placeholder="Enter ciphertext (hex)" rows="3"></textarea>
|
|
<button id="password-decrypt-button">Decrypt with Password</button>
|
|
</div>
|
|
<div class="result" id="password-decrypt-result">Decrypted data will appear here</div>
|
|
</div>
|
|
|
|
<script type="module" src="./js/index.js"></script>
|
|
</body>
|
|
</html> |