proofmode 0.9.0

Capture, share, and preserve verifiable photos and videos
Documentation
// Example of using ProofMode library from Node.js
// This demonstrates integrating the ProofMode WASM module into your application

import { ProofMode } from '@guardianproject/proofmode';

async function main() {
    // Initialize ProofMode
    const proofmode = await ProofMode.init();
    
    // Example 1: Generate proof for a file
    try {
        const result = await proofmode.generate({
            filePath: './test-image.jpg',
            passphrase: 'my-secure-passphrase',
            deviceInfo: {
                manufacturer: 'Example Corp',
                model: 'Node.js App',
                osVersion: process.version
            }
        });
        
        console.log('Proof generated:', result.proofPath);
    } catch (error) {
        console.error('Error generating proof:', error);
    }
    
    // Example 2: Verify a media file
    try {
        const verification = await proofmode.check({
            filePath: './test-image.jpg'
        });

        console.log('Verification result:', verification);

        // Parse consistency discrepancies
        const { consistency } = verification;
        if (consistency) {
            console.log(`\nConsistency verified: ${consistency.verified}`);
            for (const fd of consistency.fileDiscrepancies || []) {
                console.log(`  File: ${fd.fileName} (${fd.flagCount} flags)`);
                for (const flag of fd.flags || []) {
                    console.log(`    [${flag.severity}/${flag.kind}] ${flag.field}: ${flag.message}`);
                }
            }
            const { summary } = consistency;
            if (summary) {
                console.log(`  Summary: ${summary.filesWithFlags}/${summary.totalFiles} files flagged, ${summary.totalFlags} total flags`);
            }
        }

        // Parse synchrony temporal analysis
        const { synchrony } = verification;
        if (synchrony?.temporal) {
            const { temporal } = synchrony;
            console.log('\nTemporal analysis:');
            console.log(`  Range: ${temporal.earliest} to ${temporal.latest}`);
            console.log(`  Elapsed: ${temporal.elapsedSeconds.toFixed(1)}s across ${temporal.fileCount} files`);
            if (temporal.patterns) {
                const p = temporal.patterns;
                console.log(`  Mean interval: ${p.meanIntervalSeconds.toFixed(1)}s (std ${p.stdIntervalSeconds.toFixed(1)}s)`);
                console.log(`  Bursts: ${p.burstCount}, Gaps: ${p.gapCount}`);
            }
        }

        // Parse synchrony spatial analysis
        if (synchrony?.spatial) {
            const { spatial } = synchrony;
            console.log('\nSpatial analysis:');
            console.log(`  Max distance: ${spatial.maxDistanceKm.toFixed(2)} km`);
            console.log(`  Coverage area: ${spatial.areaKm2.toFixed(2)} km^2`);
            console.log(`  Centroid: [${spatial.centroid[0].toFixed(4)}, ${spatial.centroid[1].toFixed(4)}]`);
            for (const pd of spatial.pairwiseDistances || []) {
                console.log(`    ${pd.fileA} <-> ${pd.fileB}: ${pd.distanceKm.toFixed(2)} km`);
            }
        }

    } catch (error) {
        console.error('Error verifying file:', error);
    }
}

// Run the example
main().catch(console.error);