diff --git a/.gitignore b/.gitignore index 582161d..6f0e388 100644 --- a/.gitignore +++ b/.gitignore @@ -89,4 +89,9 @@ nitrogen/ cpp/botan_generated/ # Eslint -.eslintcache \ No newline at end of file +.eslintcache + +# Example projects (noble, js-sha3 etc.) +/*-example/ +/*-master/ +/*-main/ diff --git a/.prettierignore b/.prettierignore index 1ee1dac..fd3a9ac 100644 --- a/.prettierignore +++ b/.prettierignore @@ -13,4 +13,12 @@ build/ nitrogen/ # Dependencies -node_modules/ \ No newline at end of file +node_modules/ + +# Example projects (noble, js-sha3 etc.) +/*-example/ +/*-master/ +/*-main/ + +# Example vectors +example/src/vectors/ \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs index fed946f..04eb32f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -26,6 +26,16 @@ export default defineConfig([ }, }, { - ignores: ['node_modules/', 'lib/', '.yarn/', 'eslint.config.mjs', 'cpp/'], + ignores: [ + 'node_modules/', + 'lib/', + '.yarn/', + 'eslint.config.mjs', + 'cpp/', + '*-example/', + '*-master/', + '*-main/', + 'example/src/vectors', + ], }, ]); diff --git a/example/package.json b/example/package.json index 4ad27d9..052cfd2 100644 --- a/example/package.json +++ b/example/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "@ethereumjs/util": "^10.0.0", + "@noble/curves": "^1.8.0", "@noble/hashes": "^1.8.0", "@noble/secp256k1": "^2.3.0", "react": "19.0.0", diff --git a/example/src/App.tsx b/example/src/App.tsx index 16be2f5..24109b9 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -48,11 +48,33 @@ import { runAllKeccak256Benchmarks, type BenchmarkResult as Keccak256BenchmarkResult, } from './benchmarks/keccak256Benchmark'; +import { + runAllEd25519Benchmarks, + type BenchmarkResult as Ed25519BenchmarkResult, +} from './benchmarks/ed25519Benchmark'; +import { + testEd25519BasicFunctionality, + testEd25519PublicKeyFormat, + testEd25519KnownVectors, + testEd25519InputVariants, + testEd25519Uint8ArrayEdgeCases, + testEd25519NobleComparison, + testEd25519ErrorHandling, +} from './tests/ed25519Tests'; +import { runAllEd25519NobleExtractedTests } from './tests/ed25519NobleExtractedTests'; +import { + verifyMultipleEd25519Vectors, + type Ed25519VerificationResult, +} from './tests/ed25519NobleCompatibilityTests'; // Define test suite configuration interface TestSuite { name: string; - runner: () => TestResult[] | ValidationResult[] | VerificationResult[]; + runner: () => + | TestResult[] + | ValidationResult[] + | VerificationResult[] + | Ed25519VerificationResult[]; key: string; } @@ -66,6 +88,9 @@ export default function App() { verification: VerificationResult[]; pubToAddress: TestResult[]; keccak256: TestResult[]; + ed25519: TestResult[]; + ed25519Noble: TestResult[]; + ed25519Verification: Ed25519VerificationResult[]; }>({ basic: [], noble: [], @@ -75,6 +100,9 @@ export default function App() { verification: [], pubToAddress: [], keccak256: [], + ed25519: [], + ed25519Noble: [], + ed25519Verification: [], }); const [benchmarkResults, setBenchmarkResults] = useState<{ @@ -82,11 +110,13 @@ export default function App() { hmacSuite: HmacBenchmarkResult[] | null; pubToAddressSuite: PubToAddressBenchmarkResult[] | null; keccak256Suite: Keccak256BenchmarkResult[] | null; + ed25519Suite: Ed25519BenchmarkResult[] | null; }>({ suite: null, hmacSuite: null, pubToAddressSuite: null, keccak256Suite: null, + ed25519Suite: null, }); const [isRunning, setIsRunning] = useState(false); @@ -148,6 +178,29 @@ export default function App() { key: 'keccak256', runner: () => runAllKeccak256Tests(), }, + { + name: 'getPublicKeyEd25519', + key: 'ed25519', + runner: () => [ + ...testEd25519BasicFunctionality(), + ...testEd25519PublicKeyFormat(), + ...testEd25519KnownVectors(), + ...testEd25519InputVariants(), + ...testEd25519Uint8ArrayEdgeCases(), + ...testEd25519NobleComparison(), + ...testEd25519ErrorHandling(), + ], + }, + { + name: 'getPublicKeyEd25519 - converted test cases from noble/curves', + key: 'ed25519Noble', + runner: () => runAllEd25519NobleExtractedTests(), + }, + { + name: 'getPublicKeyEd25519 - custom noble/curves compatibility tests', + key: 'ed25519Verification', + runner: () => verifyMultipleEd25519Vectors(), + }, ]; const clearAllResults = () => { @@ -161,12 +214,16 @@ export default function App() { verification: [], pubToAddress: [], keccak256: [], + ed25519: [], + ed25519Noble: [], + ed25519Verification: [], }); setBenchmarkResults({ suite: null, hmacSuite: null, pubToAddressSuite: null, keccak256Suite: null, + ed25519Suite: null, }); }; @@ -217,6 +274,15 @@ export default function App() { nobleCompressed: '', }, ]; + } else if (suite.key === 'ed25519Verification') { + (newResults as any)[suite.key] = [ + { + matches: false, + privateKey: '', + nativePublicKey: '', + noblePublicKey: '', + }, + ]; } else { (newResults as any)[suite.key] = [errorResult]; } @@ -271,6 +337,9 @@ export default function App() { ...testResults.verification.map((r) => ({ success: r.matches })), ...testResults.pubToAddress.map((r) => ({ success: r.success })), ...testResults.keccak256.map((r) => ({ success: r.success })), + ...testResults.ed25519.map((r) => ({ success: r.success })), + ...testResults.ed25519Noble.map((r) => ({ success: r.success })), + ...testResults.ed25519Verification.map((r) => ({ success: r.matches })), ]; const totalTests = allResults.length; @@ -294,6 +363,10 @@ export default function App() { passed = results.filter((r: ValidationResult) => r.success).length; } else if (key === 'verification') { passed = results.filter((r: VerificationResult) => r.matches).length; + } else if (key === 'ed25519Verification') { + passed = results.filter( + (r: Ed25519VerificationResult) => r.matches, + ).length; } else if (key === 'pubToAddress') { passed = results.filter((r: TestResult) => r.success).length; } else if (key === 'keccak256') { @@ -381,6 +454,17 @@ export default function App() { disabled={isRunning} /> + +