From 3aa988442f182c917b751d3a1d739eb8426eb03a Mon Sep 17 00:00:00 2001 From: Alexis Bruneteau Date: Fri, 7 Nov 2025 18:19:48 +0100 Subject: [PATCH] fix: Correct ElGamal public key serialization and .gitignore Python lib paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix ElGamalEncryption to generate keypair on initialization and provide public_key_bytes property with proper "p:g:h" UTF-8 format - Add ElGamal alias for backward compatibility with imports - Improve frontend error handling with detailed base64 decode error messages - Update .gitignore to specifically ignore backend/lib/ and backend/lib64/ instead of all lib directories, preserving frontend node_modules-style lib/ This fixes the "Invalid public key format" error that was preventing vote submission during testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../frontend-old/src/lib/ui/alert.jsx | 55 +++ .../frontend-old/src/lib/ui/badge.jsx | 41 ++ .../frontend-old/src/lib/ui/button.jsx | 57 +++ .../.backups/frontend-old/src/lib/ui/card.jsx | 54 +++ .../frontend-old/src/lib/ui/dialog.jsx | 100 +++++ .../frontend-old/src/lib/ui/dropdown-menu.jsx | 158 +++++++ .../.backups/frontend-old/src/lib/ui/index.js | 8 + .../frontend-old/src/lib/ui/input.jsx | 17 + .../frontend-old/src/lib/ui/label.jsx | 16 + .../.backups/frontend-old/src/lib/utils.js | 6 + e-voting-system/.gitignore | 4 +- e-voting-system/backend/crypto/encryption.py | 27 +- e-voting-system/frontend/lib/api-config.ts | 11 + e-voting-system/frontend/lib/crypto-client.ts | 409 ++++++++++++++++++ .../frontend/lib/theme-provider.tsx | 11 + e-voting-system/frontend/lib/utils.ts | 6 + 16 files changed, 974 insertions(+), 6 deletions(-) create mode 100644 e-voting-system/.backups/frontend-old/src/lib/ui/alert.jsx create mode 100644 e-voting-system/.backups/frontend-old/src/lib/ui/badge.jsx create mode 100644 e-voting-system/.backups/frontend-old/src/lib/ui/button.jsx create mode 100644 e-voting-system/.backups/frontend-old/src/lib/ui/card.jsx create mode 100644 e-voting-system/.backups/frontend-old/src/lib/ui/dialog.jsx create mode 100644 e-voting-system/.backups/frontend-old/src/lib/ui/dropdown-menu.jsx create mode 100644 e-voting-system/.backups/frontend-old/src/lib/ui/index.js create mode 100644 e-voting-system/.backups/frontend-old/src/lib/ui/input.jsx create mode 100644 e-voting-system/.backups/frontend-old/src/lib/ui/label.jsx create mode 100644 e-voting-system/.backups/frontend-old/src/lib/utils.js create mode 100644 e-voting-system/frontend/lib/api-config.ts create mode 100644 e-voting-system/frontend/lib/crypto-client.ts create mode 100644 e-voting-system/frontend/lib/theme-provider.tsx create mode 100644 e-voting-system/frontend/lib/utils.ts diff --git a/e-voting-system/.backups/frontend-old/src/lib/ui/alert.jsx b/e-voting-system/.backups/frontend-old/src/lib/ui/alert.jsx new file mode 100644 index 0000000..3ea3e28 --- /dev/null +++ b/e-voting-system/.backups/frontend-old/src/lib/ui/alert.jsx @@ -0,0 +1,55 @@ +import * as React from "react" +import { cva } from "class-variance-authority" +import { cn } from "../utils" + +const alertVariants = cva( + "relative w-full rounded-lg border p-4", + { + variants: { + variant: { + default: "bg-bg-secondary text-text-primary border-text-tertiary", + destructive: + "border-danger/50 text-danger dark:border-danger [&>svg]:text-danger", + success: + "border-success/50 text-success dark:border-success [&>svg]:text-success", + warning: + "border-warning/50 text-warning dark:border-warning [&>svg]:text-warning", + info: + "border-info/50 text-info dark:border-info [&>svg]:text-info", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +const Alert = React.forwardRef(({ className, variant, ...props }, ref) => ( +
+)) +Alert.displayName = "Alert" + +const AlertTitle = React.forwardRef(({ className, ...props }, ref) => ( +
+)) +AlertTitle.displayName = "AlertTitle" + +const AlertDescription = React.forwardRef(({ className, ...props }, ref) => ( +
+)) +AlertDescription.displayName = "AlertDescription" + +export { Alert, AlertTitle, AlertDescription } diff --git a/e-voting-system/.backups/frontend-old/src/lib/ui/badge.jsx b/e-voting-system/.backups/frontend-old/src/lib/ui/badge.jsx new file mode 100644 index 0000000..9a5b65d --- /dev/null +++ b/e-voting-system/.backups/frontend-old/src/lib/ui/badge.jsx @@ -0,0 +1,41 @@ +import * as React from "react" +import { cva } from "class-variance-authority" +import { cn } from "../utils" + +const badgeVariants = cva( + "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-accent-warm focus:ring-offset-2", + { + variants: { + variant: { + default: + "border-text-tertiary bg-bg-secondary text-text-primary hover:bg-bg-overlay-light", + secondary: + "border-text-tertiary text-text-secondary hover:bg-bg-overlay-light", + destructive: + "border-danger/50 bg-danger/10 text-danger hover:bg-danger/20", + outline: "text-text-primary border-text-tertiary", + success: + "border-success/50 bg-success/10 text-success hover:bg-success/20", + warning: + "border-warning/50 bg-warning/10 text-warning hover:bg-warning/20", + info: + "border-info/50 bg-info/10 text-info hover:bg-info/20", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +function Badge({ + className, + variant, + ...props +}) { + return ( +
+ ) +} + +export { Badge, badgeVariants } diff --git a/e-voting-system/.backups/frontend-old/src/lib/ui/button.jsx b/e-voting-system/.backups/frontend-old/src/lib/ui/button.jsx new file mode 100644 index 0000000..2c691df --- /dev/null +++ b/e-voting-system/.backups/frontend-old/src/lib/ui/button.jsx @@ -0,0 +1,57 @@ +import * as React from "react" +import { cva } from "class-variance-authority" +import { cn } from "../utils" + +const buttonVariants = cva( + "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-bg-secondary transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-warm focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", + { + variants: { + variant: { + default: + "bg-accent-warm text-white hover:bg-opacity-90 active:bg-opacity-80", + destructive: + "bg-danger text-white hover:bg-opacity-90 active:bg-opacity-80", + outline: + "border border-text-tertiary hover:bg-bg-overlay-light hover:text-text-primary", + secondary: + "bg-bg-secondary text-text-primary border border-text-tertiary hover:bg-bg-overlay-light", + ghost: + "hover:bg-bg-overlay-light hover:text-text-primary", + link: + "text-accent-warm underline-offset-4 hover:underline", + success: + "bg-success text-white hover:bg-opacity-90 active:bg-opacity-80", + }, + size: { + default: "h-10 px-4 py-2", + sm: "h-9 rounded-md px-3 text-xs", + lg: "h-11 rounded-md px-8", + icon: "h-10 w-10", + }, + }, + defaultVariants: { + variant: "default", + size: "default", + }, + } +) + +const Button = React.forwardRef(({ className, variant, size, asChild = false, ...props }, ref) => { + if (asChild && props.children && React.isValidElement(props.children)) { + return React.cloneElement(props.children, { + className: cn(buttonVariants({ variant, size }), props.children.props.className), + ref, + }) + } + + return ( +