Working crypto

This commit is contained in:
2026-08-16 07:30:55 +02:00
parent e7dd632633
commit c32c3702d2
3 changed files with 58 additions and 9 deletions
+33
View File
@@ -8,6 +8,9 @@
"name": "enclave", "name": "enclave",
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@noble/ed25519": "^3.1.0",
"@noble/hashes": "^2.3.0",
"@scure/base": "^2.3.0",
"@tauri-apps/api": "^2", "@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2", "@tauri-apps/plugin-opener": "^2",
"react": "^19.1.0", "react": "^19.1.0",
@@ -816,6 +819,27 @@
"node": "^22.20 || ^24.12 || >=25" "node": "^22.20 || ^24.12 || >=25"
} }
}, },
"node_modules/@noble/ed25519": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-3.1.0.tgz",
"integrity": "sha512-pfcObRY3CtvwfaG9Mt5XqZdKmAQppl37tHUeuBhDUbiwJBCVY4/A4lbMvb1xKhMDx96AqAqZpMWuBX1HulhX4g==",
"license": "MIT",
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/hashes": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.3.0.tgz",
"integrity": "sha512-oN+QwyX7VSHotibwubG3kpzbwKrfnyR6OOO+3Nk/53ADL7FmgHHz4TgrbaYKvvOw09u6QTx0oiH1cNCIOuN0CQ==",
"license": "MIT",
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@rolldown/pluginutils": { "node_modules/@rolldown/pluginutils": {
"version": "1.0.0-beta.27", "version": "1.0.0-beta.27",
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz", "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz",
@@ -1212,6 +1236,15 @@
"win32" "win32"
] ]
}, },
"node_modules/@scure/base": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@scure/base/-/base-2.3.0.tgz",
"integrity": "sha512-NsG6Y03tY6R5BUis4FdVtHVkur0U6FOzskgs9ZXNl78CUc9fkZ78HmENUle1nSOkCasDmbubmWD9qwB7mm4PZA==",
"license": "MIT",
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@tauri-apps/api": { "node_modules/@tauri-apps/api": {
"version": "2.11.1", "version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-2.11.1.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-2.11.1.tgz",
+8 -5
View File
@@ -10,17 +10,20 @@
"tauri": "tauri" "tauri": "tauri"
}, },
"dependencies": { "dependencies": {
"react": "^19.1.0", "@noble/ed25519": "^3.1.0",
"react-dom": "^19.1.0", "@noble/hashes": "^2.3.0",
"@scure/base": "^2.3.0",
"@tauri-apps/api": "^2", "@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2" "@tauri-apps/plugin-opener": "^2",
"react": "^19.1.0",
"react-dom": "^19.1.0"
}, },
"devDependencies": { "devDependencies": {
"@tauri-apps/cli": "^2",
"@types/react": "^19.1.8", "@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6", "@types/react-dom": "^19.1.6",
"@vitejs/plugin-react": "^4.6.0", "@vitejs/plugin-react": "^4.6.0",
"typescript": "~5.8.3", "typescript": "~5.8.3",
"vite": "^7.0.4", "vite": "^7.0.4"
"@tauri-apps/cli": "^2"
} }
} }
+17 -4
View File
@@ -3,6 +3,11 @@ import reactLogo from "./assets/react.svg";
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
import "./App.css"; import "./App.css";
import { EnclaveWebSocket } from "./protocol/ws"; import { EnclaveWebSocket } from "./protocol/ws";
import * as ed from "@noble/ed25519";
import { base58 } from "@scure/base";
import { sha512 } from "@noble/hashes/sha2.js";
ed.hashes.sha512 = sha512;
function App() { function App() {
const [greetMsg, setGreetMsg] = useState(""); const [greetMsg, setGreetMsg] = useState("");
@@ -17,12 +22,20 @@ function App() {
(async () => { (async () => {
const ws = new EnclaveWebSocket("ws://localhost:3415"); const ws = new EnclaveWebSocket("ws://localhost:3415");
const timestamp = Date.now();
const hostname = "localhost:3415";
const msg = new TextEncoder().encode(`${timestamp}@${hostname}`);
const PRIVATE_KEY = ed.utils.randomSecretKey();
ws.send({ ws.send({
method: "Initialize", method: "Initialize",
public_key: "", public_key: base58.encode(ed.getPublicKey(PRIVATE_KEY)),
signature: "", signature: base58.encode(ed.sign(msg, PRIVATE_KEY)),
timestamp: 0,
hostname: "", timestamp,
hostname,
}); });
console.log(await ws.read()); console.log(await ws.read());