Implement geo backend, TS client, frontend, and CI tests.
Add a Go HTTP API with Ed25519 auth and invitation onboarding, user-scoped GeoJSON Point management, a Bun-tested @noble/ed25519 TypeScript client, static Vue/Vuetify frontend integration, and a Gitea CI workflow running both Go and Bun test suites. Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { getPublicKeyAsync, signAsync } from "@noble/ed25519";
|
||||
import { base64UrlToBytes, bytesToBase64Url, textToBytes } from "./encoding";
|
||||
import type { StoredKeys } from "./types";
|
||||
|
||||
function randomPrivateKey(): Uint8Array {
|
||||
const out = new Uint8Array(32);
|
||||
crypto.getRandomValues(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
export async function generateKeyPair(): Promise<StoredKeys> {
|
||||
const privateKey = randomPrivateKey();
|
||||
const publicKey = await getPublicKeyAsync(privateKey);
|
||||
return {
|
||||
publicKey: bytesToBase64Url(publicKey),
|
||||
privateKey: bytesToBase64Url(privateKey),
|
||||
};
|
||||
}
|
||||
|
||||
export async function signMessage(privateKeyBase64: string, message: string): Promise<string> {
|
||||
const privateKey = base64UrlToBytes(privateKeyBase64);
|
||||
const signature = await signAsync(textToBytes(message), privateKey);
|
||||
return bytesToBase64Url(signature);
|
||||
}
|
||||
Reference in New Issue
Block a user