tweakroot
Version:
tweak a taproot pubkey using elliptic curve operations
62 lines (51 loc) • 1.92 kB
JavaScript
/**
* Basic verification test for the tweakroot implementation
*
* This script verifies that our implementation can process
* inputs correctly and produce a valid public key output.
*/
import { tweakPubkey } from '../lib/tweakroot.js';
// Test cases with valid inputs
const testCases = [
{
pubkey: '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
tweak: '00000000000000000000000000000000000000000000000000000000deadbeef',
},
{
pubkey: '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
tweak: '0000000000000000000000000000000000000000000000000000000000000001',
}
];
// Run a basic verification test
function runTests () {
console.log('=== TWEAKROOT BASIC VERIFICATION TEST ===');
console.log('NOTE: This is a proper EC tweaking implementation using tiny-secp256k1');
let allPassed = true;
for (let i = 0; i < testCases.length; i++) {
const { pubkey, tweak } = testCases[i];
console.log(`\nTest Case #${i + 1}:`);
console.log('Input Public Key:', pubkey);
console.log('Input Tweak Value:', tweak);
try {
const result = tweakPubkey(pubkey, tweak);
console.log('Result:', result);
// For basic testing, verify that we get a valid 64-char hex output
const isValidResult = /^[0-9a-fA-F]{64}$/.test(result);
console.log('Valid format?', isValidResult ? 'YES ✓' : 'NO ✗');
if (!isValidResult) {
allPassed = false;
}
} catch (error) {
console.error('ERROR:', error.message);
allPassed = false;
}
}
console.log('\n=== SUMMARY ===');
if (allPassed) {
console.log('✅ Basic tests passed - the function can process inputs and produce outputs');
console.log('NOTE: This is a proper EC tweaking implementation using tiny-secp256k1.');
} else {
console.log('❌ Some tests failed - implementation needs to be fixed');
}
}
runTests();