44
55import { describe , it } from 'node:test' ;
66import assert from 'node:assert' ;
7- import {
8- generateKeypair ,
9- getPublicKey ,
10- signEvent ,
7+ import {
8+ generateKeypair ,
9+ getPublicKey ,
10+ signEvent ,
1111 verifySignature ,
1212 getEventHash ,
1313 isValidPublicKey
@@ -17,7 +17,7 @@ describe('Crypto Functions', () => {
1717 describe ( 'generateKeypair' , ( ) => {
1818 it ( 'should generate a valid keypair' , async ( ) => {
1919 const keypair = await generateKeypair ( ) ;
20-
20+
2121 assert ( keypair , 'Keypair should be returned' ) ;
2222 assert ( keypair . privateKey , 'Private key should exist' ) ;
2323 assert ( keypair . publicKey , 'Public key should exist' ) ;
@@ -30,7 +30,7 @@ describe('Crypto Functions', () => {
3030 it ( 'should generate different keypairs each time' , async ( ) => {
3131 const keypair1 = await generateKeypair ( ) ;
3232 const keypair2 = await generateKeypair ( ) ;
33-
33+
3434 assert . notStrictEqual ( keypair1 . privateKey , keypair2 . privateKey , 'Private keys should differ' ) ;
3535 assert . notStrictEqual ( keypair1 . publicKey , keypair2 . publicKey , 'Public keys should differ' ) ;
3636 } ) ;
@@ -40,7 +40,7 @@ describe('Crypto Functions', () => {
4040 it ( 'should derive public key from private key' , async ( ) => {
4141 const keypair = await generateKeypair ( ) ;
4242 const derivedPublicKey = getPublicKey ( keypair . privateKey ) ;
43-
43+
4444 assert . strictEqual ( derivedPublicKey , keypair . publicKey , 'Derived public key should match' ) ;
4545 assert . strictEqual ( derivedPublicKey . length , 64 , 'Public key should be 64 chars' ) ;
4646 } ) ;
@@ -63,7 +63,7 @@ describe('Crypto Functions', () => {
6363 } ;
6464
6565 const signed = await signEvent ( event , keypair . privateKey ) ;
66-
66+
6767 assert ( signed . id , 'Event should have id' ) ;
6868 assert ( signed . pubkey , 'Event should have pubkey' ) ;
6969 assert ( signed . sig , 'Event should have signature' ) ;
@@ -84,7 +84,7 @@ describe('Crypto Functions', () => {
8484
8585 const signed = await signEvent ( event , keypair . privateKey ) ;
8686 const hashWithPubkey = getEventHash ( { ...event , pubkey : keypair . publicKey } ) ;
87-
87+
8888 assert . strictEqual ( signed . id , hashWithPubkey , 'Event ID should match hash with pubkey' ) ;
8989 } ) ;
9090 } ) ;
@@ -101,7 +101,7 @@ describe('Crypto Functions', () => {
101101
102102 const signed = await signEvent ( event , keypair . privateKey ) ;
103103 const isValid = await verifySignature ( signed ) ;
104-
104+
105105 assert . strictEqual ( isValid , true , 'Signature should be valid' ) ;
106106 } ) ;
107107
@@ -134,7 +134,7 @@ describe('Crypto Functions', () => {
134134
135135 const hash1 = getEventHash ( event ) ;
136136 const hash2 = getEventHash ( event ) ;
137-
137+
138138 assert . strictEqual ( hash1 , hash2 , 'Hashes should be consistent' ) ;
139139 assert . strictEqual ( hash1 . length , 64 , 'Hash should be 64 chars' ) ;
140140 } ) ;
@@ -147,15 +147,15 @@ describe('Crypto Functions', () => {
147147 content : 'Test' ,
148148 pubkey : 'a' . repeat ( 64 )
149149 } ;
150-
150+
151151 const event2 = {
152152 ...event1 ,
153153 pubkey : 'b' . repeat ( 64 )
154154 } ;
155155
156156 const hash1 = getEventHash ( event1 ) ;
157157 const hash2 = getEventHash ( event2 ) ;
158-
158+
159159 assert . notStrictEqual ( hash1 , hash2 , 'Different pubkeys should produce different hashes' ) ;
160160 } ) ;
161161 } ) ;
0 commit comments