diff --git a/infrastructure/blindvote/src/crypto/pedersen.ts b/infrastructure/blindvote/src/crypto/pedersen.ts index 8404f7f2..4b32f66b 100644 --- a/infrastructure/blindvote/src/crypto/pedersen.ts +++ b/infrastructure/blindvote/src/crypto/pedersen.ts @@ -286,7 +286,16 @@ function addPoints(arr: any[]) { * Helper function to compare encodings */ function encEq(A: any, B: any) { - return Buffer.from(A.toRawBytes()).equals(Buffer.from(B.toRawBytes())); + const bytesA = A.toRawBytes(); + const bytesB = B.toRawBytes(); + + if (bytesA.length !== bytesB.length) return false; + + for (let i = 0; i < bytesA.length; i++) { + if (bytesA[i] !== bytesB[i]) return false; + } + + return true; } export function verifyFinal(C_aggb: Uint8Array, H_Sb: Uint8Array, M: number): boolean { diff --git a/infrastructure/control-panel/src/routes/+layout.svelte b/infrastructure/control-panel/src/routes/+layout.svelte index dc43ad8f..6d243a27 100644 --- a/infrastructure/control-panel/src/routes/+layout.svelte +++ b/infrastructure/control-panel/src/routes/+layout.svelte @@ -31,7 +31,25 @@ size="sm" class="whitespace-nowrap" variant="solid" - callback={() => goto('/monitoring')}>Start Monitoring { + // Get selected items from the current page + const evaultsData = sessionStorage.getItem('selectedEVaults'); + const platformsData = sessionStorage.getItem('selectedPlatforms'); + + // If no items selected, show alert + if ( + (!evaultsData || JSON.parse(evaultsData).length === 0) && + (!platformsData || JSON.parse(platformsData).length === 0) + ) { + alert( + 'Please select eVaults and/or platforms first before starting monitoring.' + ); + return; + } + + // Navigate to monitoring + goto('/monitoring'); + }}>Start Monitoring {:else} diff --git a/infrastructure/control-panel/src/routes/+page.svelte b/infrastructure/control-panel/src/routes/+page.svelte index 059a7932..d4295749 100644 --- a/infrastructure/control-panel/src/routes/+page.svelte +++ b/infrastructure/control-panel/src/routes/+page.svelte @@ -69,6 +69,10 @@ } else { selectedEVaults = selectedEVaults.filter((i) => i !== index); } + + // Store selections immediately in sessionStorage + const selectedEVaultData = selectedEVaults.map((i) => evaults[i]); + sessionStorage.setItem('selectedEVaults', JSON.stringify(selectedEVaultData)); } // Handle platform selection changes @@ -78,6 +82,10 @@ } else { selectedPlatforms = selectedPlatforms.filter((i) => i !== index); } + + // Store selections immediately in sessionStorage + const selectedPlatformData = selectedPlatforms.map((i) => platforms[i]); + sessionStorage.setItem('selectedPlatforms', JSON.stringify(selectedPlatformData)); } // Navigate to monitoring with selected items @@ -247,15 +255,4 @@ /> {/if} - - -
- -
diff --git a/infrastructure/control-panel/src/routes/monitoring/+page.svelte b/infrastructure/control-panel/src/routes/monitoring/+page.svelte index bb4fd8ec..babe8cfc 100644 --- a/infrastructure/control-panel/src/routes/monitoring/+page.svelte +++ b/infrastructure/control-panel/src/routes/monitoring/+page.svelte @@ -37,9 +37,20 @@ if (evaultsData) { selectedEVaults = JSON.parse(evaultsData); + console.log('Loaded selectedEVaults from sessionStorage:', selectedEVaults); } if (platformsData) { selectedPlatforms = JSON.parse(platformsData); + console.log('Loaded selectedPlatforms from sessionStorage:', selectedPlatforms); + } + + // Check if any items are selected, if not show selection interface + if ( + (!selectedEVaults || selectedEVaults.length === 0) && + (!selectedPlatforms || selectedPlatforms.length === 0) + ) { + // Don't redirect, just show empty state + return; } // Create nodes from selected items @@ -168,6 +179,8 @@ } function handleFlowEvent(data: any) { + console.log('handleFlowEvent received:', data); + switch (data.type) { case 'evault_sync_event': handleEvaultSyncEvent(data); @@ -188,10 +201,21 @@ } function handleEvaultSyncEvent(data: any) { + console.log('handleEvaultSyncEvent received data:', data); + console.log('selectedEVaults:', selectedEVaults); + console.log('selectedPlatforms:', selectedPlatforms); + // Map the real data to visualization indices const platformIndex = getPlatformIndex(data.platform); const evaultIndex = getEvaultIndex(data.w3id); + console.log('Mapped indices:', { + platformIndex, + evaultIndex, + platform: data.platform, + w3id: data.w3id + }); + // Step 1: Platform creates entry locally currentFlowStep = 1; flowMessages = [ @@ -469,74 +493,114 @@ } function getEvaultIndex(w3id: string): number { - const index = selectedEVaults.findIndex((e) => e.evaultId === w3id || e.w3id === w3id); - return index >= 0 ? index : 0; + console.log('getEvaultIndex called with w3id:', w3id); + console.log('selectedEVaults:', selectedEVaults); + + // Since evaultId is the same as w3id, prioritize that match + const index = selectedEVaults.findIndex((e) => { + const matches = e.evaultId === w3id; + + if (matches) { + console.log('Found matching eVault by evaultId:', e); + } + + return matches; + }); + + console.log('getEvaultIndex result:', { + w3id, + foundIndex: index, + selectedEVaultsLength: selectedEVaults.length + }); + + // If no match found, log all available evaultIds for debugging + if (index === -1) { + console.log('No match found for w3id:', w3id); + console.log('Available evaultIds:'); + selectedEVaults.forEach((evault, i) => { + console.log(`eVault ${i}: evaultId = "${evault.evaultId}"`); + }); + + // Fall back to index 0 if no match found + console.log('Falling back to index 0'); + return 0; + } + + return index; } -
-
-
-
-

Live Monitoring

-

- Monitoring {selectedEVaults.length} eVault{selectedEVaults.length !== 1 - ? 's' - : ''} and {selectedPlatforms.length} platform{selectedPlatforms.length !== 1 - ? 's' - : ''} -

- {#if currentFlowStep > 0} -
-
- - {currentFlowStep === 1 - ? 'Platform creating entry locally' - : currentFlowStep === 2 - ? 'Syncing to eVault' - : currentFlowStep === 3 - ? 'eVault created metaenvelope' - : currentFlowStep === 4 - ? 'Awareness Protocol' - : currentFlowStep === 5 - ? 'All platforms notified' - : 'Complete'} - -
- {/if} -
-
- - +
+
+{:else} +
+
+
+
+

Live Monitoring

+

+ Monitoring {selectedEVaults.length} eVault{selectedEVaults.length !== 1 + ? 's' + : ''} and {selectedPlatforms.length} platform{selectedPlatforms.length !== + 1 + ? 's' + : ''} +

+ {#if currentFlowStep > 0} +
+
+ + {currentFlowStep === 1 + ? 'Platform creating entry locally' + : currentFlowStep === 2 + ? 'Syncing to eVault' + : currentFlowStep === 3 + ? 'eVault created metaenvelope' + : currentFlowStep === 4 + ? 'Awareness Protocol' + : currentFlowStep === 5 + ? 'All platforms notified' + : 'Complete'} + +
{/if} - {isPaused ? 'Resume Live Feed' : 'Pause Live Feed'} - +
+
+ + +
-
- {#if SvelteFlowComponent} - {#if selectedEVaults.length === 0 && selectedPlatforms.length === 0} -
-
-

No Items Selected

-

- Go back to the main page and select eVaults and platforms to monitor. -

-
-
- {:else} + {#if SvelteFlowComponent}
+ {:else} +
+ Loading flow chart... +
{/if} - {:else} -
- Loading flow chart... -
- {/if} -
- - -
-
-

Data Flow

-
- Current Step: {currentFlowStep === 0 - ? 'Waiting for events...' - : currentFlowStep === 1 - ? 'Platform creating entry locally' - : currentFlowStep === 2 - ? 'Syncing to eVault' - : currentFlowStep === 3 - ? 'eVault created metaenvelope' - : currentFlowStep === 4 - ? 'Awareness Protocol' - : currentFlowStep === 5 - ? 'All platforms notified' - : 'Complete'} -
-
- {#each flowMessages as message, i} -
- {message} + +
+
+

Data Flow

+
+ Current Step: {currentFlowStep === 0 + ? 'Waiting for events...' + : currentFlowStep === 1 + ? 'Platform creating entry locally' + : currentFlowStep === 2 + ? 'Syncing to eVault' + : currentFlowStep === 3 + ? 'eVault created metaenvelope' + : currentFlowStep === 4 + ? 'Awareness Protocol' + : currentFlowStep === 5 + ? 'All platforms notified' + : 'Complete'}
- {/each} +
+ +
+ {#each flowMessages as message, i} +
+ {message} +
+ {/each} +
-
-
+ +{/if}