bud02 completed

This commit is contained in:
Your Name
2025-09-02 12:54:22 -04:00
parent e98ec5489a
commit db3f078583
29 changed files with 5024 additions and 7 deletions

28
Trash/auth_debug.log Normal file
View File

@@ -0,0 +1,28 @@
DEBUG: authenticate_request ENTRY - method: upload, hash: 59fbf16bd87c759e1a723b6b638d925bb0b589e6ef5169ff6ad187957345aa58
DEBUG: authenticate_request - calling parse_authorization_header
DEBUG: authenticate_request - parse_authorization_header succeeded
DEBUG: authenticate_request - calling cJSON_Parse on: {"kind":24242,"id":"9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1755685428,"tags":[["t","upload"],["x","84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"],["expiration","1755689028"]],"content":"","sig":"95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead"}
DEBUG: authenticate_request - cJSON_Parse succeeded, event parsed
DEBUG: authenticate_request - Parsed JSON: {
"kind": 24242,
"id": "9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6",
"pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"created_at": 1755685428,
"tags": [["t", "upload"], ["x", "84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"], ["expiration", "1755689028"]],
"content": "",
"sig": "95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead"
}
DEBUG: authenticate_request ENTRY - method: upload, hash: b22d8bb93c030bdff71a4bf00dc38c1e3d920e2535df3b9e2e513dfcb6249820
DEBUG: authenticate_request - calling parse_authorization_header
DEBUG: authenticate_request - parse_authorization_header succeeded
DEBUG: authenticate_request - calling cJSON_Parse on: {"kind":24242,"id":"ee2631b20eaa4644827686119e3bf4d51caa70dfa0b48bd771e7d11a22620cfb","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1755687299,"tags":[["t","upload"],["x","b22d8bb93c030bdff71a4bf00dc38c1e3d920e2535df3b9e2e513dfcb6249820"],["expiration","1755690899"]],"content":"","sig":"edb88c03d25ac22423c0d2f7cfdd5b9bba4b9780ab0d68471799150bb3548348b85886451c0fd260c1bacd38c75e96ad6ae0c9de61acb7e04a20f4338abf7419"}
DEBUG: authenticate_request - cJSON_Parse succeeded, event parsed
DEBUG: authenticate_request - Parsed JSON: {
"kind": 24242,
"id": "ee2631b20eaa4644827686119e3bf4d51caa70dfa0b48bd771e7d11a22620cfb",
"pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"created_at": 1755687299,
"tags": [["t", "upload"], ["x", "b22d8bb93c030bdff71a4bf00dc38c1e3d920e2535df3b9e2e513dfcb6249820"], ["expiration", "1755690899"]],
"content": "",
"sig": "edb88c03d25ac22423c0d2f7cfdd5b9bba4b9780ab0d68471799150bb3548348b85886451c0fd260c1bacd38c75e96ad6ae0c9de61acb7e04a20f4338abf7419"
}

View File

@@ -0,0 +1,202 @@
═══════════════════════════════════════════════════════════════════
🔧 COMPREHENSIVE NOSTR EVENT VALIDATION DEBUG TEST 🔧
═══════════════════════════════════════════════════════════════════
🔍 STEP INIT-1: Initializing nostr library
✅ SUCCESS: Nostr library initialized
INFO: Testing Authorization header:
Nostr eyJraW5kIjoyNDI0MiwiaWQiOiI5NTYxNjA1YjEwNjJjZTM3ZTk1YWI5YjgxZDMwMGQ5YWQ1YmZiOWM1NDRhZTM5NWUxZWI0MWYwMDBjN2Q4OWY2IiwicHVia2V5IjoiNzliZTY2N2VmOWRjYmJhYzU1YTA2Mjk1Y2U4NzBiMDcwMjliZmNkYjJkY2UyOGQ5NTlmMjgxNWIxNmY4MTc5OCIsImNyZWF0ZWRfYXQiOjE3NTU2ODU0MjgsInRhZ3MiOltbInQiLCJ1cGxvYWQiXSxbIngiLCI4NDcxNjE3MWJhYjE2YWQwMjFiZDg5NTMwNTAxODlmZTYwNzU5MTc0MzZjZDExY2M5MzNmMDIxYmJjNWQ1YjBiIl0sWyJleHBpcmF0aW9uIiwiMTc1NTY4OTAyOCJdXSwiY29udGVudCI6IiIsInNpZyI6Ijk1MzE2YWI3NWY4ZDAyYmI5OTVhMTI0OGMyNzRiOTlmOWJjNWRjMGFmNTY0OWU2OTQ5MDE1ZDA2OTkwNGQ0YmRmM2EzYzc5NDI3YWM4MjQ1Njk4NmEyZTkzN2IxZDI1YjZkMmVlOGVlMWU0NDZhODQ5Y2IxOTc3NGRmOTQ4ZWFkIn0=
═══════════════════════════════════════════════════════════════════
🔍 STEP PARSE-1: Parsing Authorization header
DEBUG: parse_authorization_header called with header: Nostr eyJraW5kIjoyNDI0MiwiaWQiOiI5NTYxNjA1YjEwNjJj...
DEBUG: Extracted base64 event (length=616): eyJraW5kIjoyNDI0MiwiaWQiOiI5NTYxNjA1YjEwNjJjZTM3ZTk1YWI5YjgxZDMwMGQ5YWQ1YmZiOWM1NDRhZTM5NWUxZWI0MWYw...
DEBUG: Base64 decode result - decoded_len=461
DEBUG: Successfully decoded JSON (length=461): {"kind":24242,"id":"9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1755685428,"tags":[["t","upload"],["x","84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"],["expiration","1755689028"]],"content":"","sig":"95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead"}
✅ SUCCESS: Authorization header parsed successfully
INFO: Decoded JSON: {"kind":24242,"id":"9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1755685428,"tags":[["t","upload"],["x","84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"],["expiration","1755689028"]],"content":"","sig":"95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead"}
🔍 STEP PARSE-2: Parsing JSON string
✅ SUCCESS: JSON parsing successful
═══════════════════════════════════════════════════════════════════
🔍 STEP ANALYZE-1: Analyzing event field details
INFO: Field 'kind':
INFO: Type: Number
INFO: Value: 24242
INFO: Field 'id':
INFO: Type: String
INFO: Value: '9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6'
INFO: Length: 64
INFO: Field 'pubkey':
INFO: Type: String
INFO: Value: '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'
INFO: Length: 64
INFO: Field 'created_at':
INFO: Type: Number
INFO: Value: 1755685428
INFO: Field 'tags':
INFO: Type: Array
INFO: Size: 3
INFO: Field 'content':
INFO: Type: String
INFO: Value: ''
INFO: Length: 0
INFO: Field 'sig':
INFO: Type: String
INFO: Value: '95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead'
INFO: Length: 128
🔍 STEP MAIN-1: Running detailed structure validation
═══════════════════════════════════════════════════════════════════
🔍 STEP STRUCT-1: Starting detailed structure validation
✅ SUCCESS: Event is valid JSON object
🔍 STEP STRUCT-2: Checking required field existence
✅ SUCCESS: Field 'id' exists
✅ SUCCESS: Field 'pubkey' exists
✅ SUCCESS: Field 'created_at' exists
✅ SUCCESS: Field 'kind' exists
✅ SUCCESS: Field 'tags' exists
✅ SUCCESS: Field 'content' exists
✅ SUCCESS: Field 'sig' exists
🔍 STEP STRUCT-3: Validating field types
✅ SUCCESS: Field 'id' is string
✅ SUCCESS: Field 'pubkey' is string
✅ SUCCESS: Field 'created_at' is number
✅ SUCCESS: Field 'kind' is number
✅ SUCCESS: Field 'tags' is array
✅ SUCCESS: Field 'content' is string
✅ SUCCESS: Field 'sig' is string
🔍 STEP STRUCT-4: Validating hex string lengths
INFO: ID string: '9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6' (length: 64)
✅ SUCCESS: ID string length is correct (64 chars)
INFO: Pubkey string: '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798' (length: 64)
✅ SUCCESS: Pubkey string length is correct (64 chars)
INFO: Signature string: '95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead' (length: 128)
✅ SUCCESS: Signature string length is correct (128 chars)
🔍 STEP STRUCT-5: Validating hex characters
INFO: Checking ID hex characters...
✅ SUCCESS: ID hex characters are valid (lowercase)
INFO: Checking pubkey hex characters...
✅ SUCCESS: Pubkey hex characters are valid (lowercase)
INFO: Checking signature hex characters...
✅ SUCCESS: Signature hex characters are valid (lowercase)
🔍 STEP STRUCT-6: Validating timestamp
INFO: Created_at timestamp: 1755685428
✅ SUCCESS: Timestamp is valid: 2025-08-20 10:23:48 UTC
🔍 STEP STRUCT-7: Validating kind
INFO: Event kind: 24242
✅ SUCCESS: Kind is valid: 24242
🔍 STEP STRUCT-8: Validating tags array structure
INFO: Tags array has 3 elements
INFO: Tag[0] has 2 elements
INFO: Tag[0][0]: 't'
INFO: Tag[0][1]: 'upload'
INFO: Tag[1] has 2 elements
INFO: Tag[1][0]: 'x'
INFO: Tag[1][1]: '84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b'
INFO: Tag[2] has 2 elements
INFO: Tag[2][0]: 'expiration'
INFO: Tag[2][1]: '1755689028'
✅ SUCCESS: Tags array structure is valid
🔍 STEP STRUCT-9: Validating content
INFO: Content: '' (length: 0)
✅ SUCCESS: Content is valid string
✅ SUCCESS: Structure validation completed successfully
✅ SUCCESS: Detailed structure validation PASSED
🔍 STEP MAIN-2: Running detailed signature validation
═══════════════════════════════════════════════════════════════════
🔍 STEP CRYPTO-1: Starting detailed signature validation
🔍 STEP CRYPTO-2: Creating serialization array
✅ SUCCESS: Serialization array created
🔍 STEP CRYPTO-3: Converting to JSON string
✅ SUCCESS: JSON serialization string created
INFO: Serialization string (length 208): [0,"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",1755685428,24242,[["t","upload"],["x","84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"],["expiration","1755689028"]],""]
🔍 STEP CRYPTO-4: Computing SHA256 hash
✅ SUCCESS: SHA256 hash computed
INFO: Event hash (32 bytes):
0000: 95 61 60 5b 10 62 ce 37 e9 5a b9 b8 1d 30 0d 9a |.a`[.b.7.Z...0..|
0010: d5 bf b9 c5 44 ae 39 5e 1e b4 1f 00 0c 7d 89 f6 |....D.9^.....}..|
🔍 STEP CRYPTO-5: Verifying event ID
INFO: Calculated ID: 9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6
INFO: Provided ID: 9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6
✅ SUCCESS: Event ID verification passed
🔍 STEP CRYPTO-6: Preparing signature verification
🔍 STEP CRYPTO-7: Converting hex strings to bytes
✅ SUCCESS: Pubkey hex converted to bytes
INFO: Pubkey bytes (32 bytes):
0000: 79 be 66 7e f9 dc bb ac 55 a0 62 95 ce 87 0b 07 |y.f~....U.b.....|
0010: 02 9b fc db 2d ce 28 d9 59 f2 81 5b 16 f8 17 98 |....-.(.Y..[....|
✅ SUCCESS: Signature hex converted to bytes
INFO: Signature bytes (64 bytes):
0000: 95 31 6a b7 5f 8d 02 bb 99 5a 12 48 c2 74 b9 9f |.1j._....Z.H.t..|
0010: 9b c5 dc 0a f5 64 9e 69 49 01 5d 06 99 04 d4 bd |.....d.iI.].....|
0020: f3 a3 c7 94 27 ac 82 45 69 86 a2 e9 37 b1 d2 5b |....'..Ei...7..[|
0030: 6d 2e e8 ee 1e 44 6a 84 9c b1 97 74 df 94 8e ad |m....Dj....t....|
🔍 STEP CRYPTO-8: Parsing public key into secp256k1 format
✅ SUCCESS: Public key parsed into secp256k1 format
🔍 STEP CRYPTO-9: Verifying Schnorr signature
✅ SUCCESS: Schnorr signature verification PASSED!
✅ SUCCESS: Detailed signature validation PASSED
═══════════════════════════════════════════════════════════════════
🔍 STEP COMPARE-1: Running standard nostr_validate_event for comparison
INFO: nostr_validate_event result: 0 (Success)
✅ SUCCESS: Standard validation PASSED - matches detailed validation
🔍 STEP COMPARE-2: Running server-style authentication (exact mirror of server code)
═══════════════════════════════════════════════════════════════════
🔍 STEP SERVER-1: Starting server-style authentication (mirroring main.c)
INFO: Server-style auth called with method: upload, hash: 84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b
🔍 STEP SERVER-2: Calling parse_authorization_header
DEBUG: parse_authorization_header called with header: Nostr eyJraW5kIjoyNDI0MiwiaWQiOiI5NTYxNjA1YjEwNjJj...
DEBUG: Extracted base64 event (length=616): eyJraW5kIjoyNDI0MiwiaWQiOiI5NTYxNjA1YjEwNjJjZTM3ZTk1YWI5YjgxZDMwMGQ5YWQ1YmZiOWM1NDRhZTM5NWUxZWI0MWYw...
DEBUG: Base64 decode result - decoded_len=461
DEBUG: Successfully decoded JSON (length=461): {"kind":24242,"id":"9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1755685428,"tags":[["t","upload"],["x","84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"],["expiration","1755689028"]],"content":"","sig":"95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead"}
✅ SUCCESS: parse_authorization_header succeeded
🔍 STEP SERVER-3: Calling cJSON_Parse on JSON string
INFO: JSON to parse: {"kind":24242,"id":"9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1755685428,"tags":[["t","upload"],["x","84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"],["expiration","1755689028"]],"content":"","sig":"95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead"}
✅ SUCCESS: cJSON_Parse succeeded, event parsed
INFO: Parsed JSON: {
"kind": 24242,
"id": "9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6",
"pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"created_at": 1755685428,
"tags": [["t", "upload"], ["x", "84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"], ["expiration", "1755689028"]],
"content": "",
"sig": "95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead"
}
🔍 STEP SERVER-4: Event fields before validation
INFO: id: 9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6
INFO: pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
INFO: sig: 95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead
INFO: kind: 24242
INFO: created_at: 1755685428
🔍 STEP SERVER-5: Detailed pubkey analysis
INFO: Pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
INFO: Length: 64
INFO: Character analysis (first 10):
7(0x37) 9(0x39) b(0x62) e(0x65) 6(0x36) 6(0x36) 7(0x37) e(0x65) f(0x66) 9(0x39)
🔍 STEP SERVER-6: Pre-validation pubkey analysis
INFO: Pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
INFO: Length: 64
INFO: Character analysis (first 10):
7(55) 9(57) b(98) e(101) 6(54) 6(54) 7(55) e(101) f(102) 9(57)
INFO: Character validation test:
ALL VALID (lowercase hex)
🔍 STEP SERVER-7: Starting detailed validation analysis
INFO: Testing structure validation...
INFO: nostr_validate_event_structure returned: 0 (Success)
✅ SUCCESS: Structure validation PASSED
INFO: Testing cryptographic verification...
INFO: nostr_verify_event_signature returned: 0 (Success)
✅ SUCCESS: Crypto verification PASSED
INFO: Testing complete validation...
INFO: nostr_validate_event returned: 0 (Success)
✅ SUCCESS: Complete validation PASSED
✅ SUCCESS: Server-style authentication successful, returning NOSTR_SUCCESS
INFO: server_style_authentication result: 0 (Success)
✅ SUCCESS: Server-style validation PASSED
═══════════════════════════════════════════════════════════════════
✅ SUCCESS: 🎉 ALL DETAILED VALIDATIONS PASSED! Event is completely valid.
✅ Structure validation: PASSED
✅ Signature validation: PASSED
✅ Standard validation: PASSED
✅ Server-style validation: PASSED
═══════════════════════════════════════════════════════════════════
✅ SUCCESS: 🔍 DETAILED COMPARISON COMPLETE
✅ SUCCESS: 🎯 ALL VALIDATION METHODS AGREE: Event is valid
═══════════════════════════════════════════════════════════════════

View File

@@ -0,0 +1,145 @@
═══════════════════════════════════════════════════════════════════
🔧 COMPREHENSIVE NOSTR EVENT VALIDATION DEBUG TEST 🔧
═══════════════════════════════════════════════════════════════════
🔍 STEP INIT-1: Initializing nostr library
✅ SUCCESS: Nostr library initialized
INFO: Testing Authorization header:
Nostr eyJraW5kIjoyNDI0MiwiaWQiOiI5NTYxNjA1YjEwNjJjZTM3ZTk1YWI5YjgxZDMwMGQ5YWQ1YmZiOWM1NDRhZTM5NWUxZWI0MWYwMDBjN2Q4OWY2IiwicHVia2V5IjoiNzliZTY2N2VmOWRjYmJhYzU1YTA2Mjk1Y2U4NzBiMDcwMjliZmNkYjJkY2UyOGQ5NTlmMjgxNWIxNmY4MTc5OCIsImNyZWF0ZWRfYXQiOjE3NTU2ODU0MjgsInRhZ3MiOltbInQiLCJ1cGxvYWQiXSxbIngiLCI4NDcxNjE3MWJhYjE2YWQwMjFiZDg5NTMwNTAxODlmZTYwNzU5MTc0MzZjZDExY2M5MzNmMDIxYmJjNWQ1YjBiIl0sWyJleHBpcmF0aW9uIiwiMTc1NTY4OTAyOCJdXSwiY29udGVudCI6IiIsInNpZyI6Ijk1MzE2YWI3NWY4ZDAyYmI5OTVhMTI0OGMyNzRiOTlmOWJjNWRjMGFmNTY0OWU2OTQ5MDE1ZDA2OTkwNGQ0YmRmM2EzYzc5NDI3YWM4MjQ1Njk4NmEyZTkzN2IxZDI1YjZkMmVlOGVlMWU0NDZhODQ5Y2IxOTc3NGRmOTQ4ZWFkIn0=
═══════════════════════════════════════════════════════════════════
🔍 STEP PARSE-1: Parsing Authorization header
DEBUG: parse_authorization_header called with header: Nostr eyJraW5kIjoyNDI0MiwiaWQiOiI5NTYxNjA1YjEwNjJj...
DEBUG: Extracted base64 event (length=616): eyJraW5kIjoyNDI0MiwiaWQiOiI5NTYxNjA1YjEwNjJjZTM3ZTk1YWI5YjgxZDMwMGQ5YWQ1YmZiOWM1NDRhZTM5NWUxZWI0MWYw...
DEBUG: Base64 decode result - decoded_len=461
DEBUG: Successfully decoded JSON (length=461): {"kind":24242,"id":"9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1755685428,"tags":[["t","upload"],["x","84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"],["expiration","1755689028"]],"content":"","sig":"95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead"}
✅ SUCCESS: Authorization header parsed successfully
INFO: Decoded JSON: {"kind":24242,"id":"9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1755685428,"tags":[["t","upload"],["x","84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"],["expiration","1755689028"]],"content":"","sig":"95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead"}
🔍 STEP PARSE-2: Parsing JSON string
✅ SUCCESS: JSON parsing successful
═══════════════════════════════════════════════════════════════════
🔍 STEP ANALYZE-1: Analyzing event field details
INFO: Field 'kind':
INFO: Type: Number
INFO: Value: 24242
INFO: Field 'id':
INFO: Type: String
INFO: Value: '9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6'
INFO: Length: 64
INFO: Field 'pubkey':
INFO: Type: String
INFO: Value: '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'
INFO: Length: 64
INFO: Field 'created_at':
INFO: Type: Number
INFO: Value: 1755685428
INFO: Field 'tags':
INFO: Type: Array
INFO: Size: 3
INFO: Field 'content':
INFO: Type: String
INFO: Value: ''
INFO: Length: 0
INFO: Field 'sig':
INFO: Type: String
INFO: Value: '95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead'
INFO: Length: 128
🔍 STEP MAIN-1: Running detailed structure validation
═══════════════════════════════════════════════════════════════════
🔍 STEP STRUCT-1: Starting detailed structure validation
✅ SUCCESS: Event is valid JSON object
🔍 STEP STRUCT-2: Checking required field existence
✅ SUCCESS: Field 'id' exists
✅ SUCCESS: Field 'pubkey' exists
✅ SUCCESS: Field 'created_at' exists
✅ SUCCESS: Field 'kind' exists
✅ SUCCESS: Field 'tags' exists
✅ SUCCESS: Field 'content' exists
✅ SUCCESS: Field 'sig' exists
🔍 STEP STRUCT-3: Validating field types
✅ SUCCESS: Field 'id' is string
✅ SUCCESS: Field 'pubkey' is string
✅ SUCCESS: Field 'created_at' is number
✅ SUCCESS: Field 'kind' is number
✅ SUCCESS: Field 'tags' is array
✅ SUCCESS: Field 'content' is string
✅ SUCCESS: Field 'sig' is string
🔍 STEP STRUCT-4: Validating hex string lengths
INFO: ID string: '9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6' (length: 64)
✅ SUCCESS: ID string length is correct (64 chars)
INFO: Pubkey string: '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798' (length: 64)
✅ SUCCESS: Pubkey string length is correct (64 chars)
INFO: Signature string: '95316ab75f8d02bb995a1248c274b99f9bc5dc0af5649e6949015d069904d4bdf3a3c79427ac82456986a2e937b1d25b6d2ee8ee1e446a849cb19774df948ead' (length: 128)
✅ SUCCESS: Signature string length is correct (128 chars)
🔍 STEP STRUCT-5: Validating hex characters
INFO: Checking ID hex characters...
✅ SUCCESS: ID hex characters are valid (lowercase)
INFO: Checking pubkey hex characters...
✅ SUCCESS: Pubkey hex characters are valid (lowercase)
INFO: Checking signature hex characters...
✅ SUCCESS: Signature hex characters are valid (lowercase)
🔍 STEP STRUCT-6: Validating timestamp
INFO: Created_at timestamp: 1755685428
✅ SUCCESS: Timestamp is valid: 2025-08-20 10:23:48 UTC
🔍 STEP STRUCT-7: Validating kind
INFO: Event kind: 24242
✅ SUCCESS: Kind is valid: 24242
🔍 STEP STRUCT-8: Validating tags array structure
INFO: Tags array has 3 elements
INFO: Tag[0] has 2 elements
INFO: Tag[0][0]: 't'
INFO: Tag[0][1]: 'upload'
INFO: Tag[1] has 2 elements
INFO: Tag[1][0]: 'x'
INFO: Tag[1][1]: '84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b'
INFO: Tag[2] has 2 elements
INFO: Tag[2][0]: 'expiration'
INFO: Tag[2][1]: '1755689028'
✅ SUCCESS: Tags array structure is valid
🔍 STEP STRUCT-9: Validating content
INFO: Content: '' (length: 0)
✅ SUCCESS: Content is valid string
✅ SUCCESS: Structure validation completed successfully
✅ SUCCESS: Detailed structure validation PASSED
🔍 STEP MAIN-2: Running detailed signature validation
═══════════════════════════════════════════════════════════════════
🔍 STEP CRYPTO-1: Starting detailed signature validation
🔍 STEP CRYPTO-2: Creating serialization array
✅ SUCCESS: Serialization array created
🔍 STEP CRYPTO-3: Converting to JSON string
✅ SUCCESS: JSON serialization string created
INFO: Serialization string (length 208): [0,"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",1755685428,24242,[["t","upload"],["x","84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b"],["expiration","1755689028"]],""]
🔍 STEP CRYPTO-4: Computing SHA256 hash
✅ SUCCESS: SHA256 hash computed
INFO: Event hash (32 bytes):
0000: 95 61 60 5b 10 62 ce 37 e9 5a b9 b8 1d 30 0d 9a |.a`[.b.7.Z...0..|
0010: d5 bf b9 c5 44 ae 39 5e 1e b4 1f 00 0c 7d 89 f6 |....D.9^.....}..|
🔍 STEP CRYPTO-5: Verifying event ID
INFO: Calculated ID: 9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6
INFO: Provided ID: 9561605b1062ce37e95ab9b81d300d9ad5bfb9c544ae395e1eb41f000c7d89f6
✅ SUCCESS: Event ID verification passed
🔍 STEP CRYPTO-6: Preparing signature verification
🔍 STEP CRYPTO-7: Converting hex strings to bytes
✅ SUCCESS: Pubkey hex converted to bytes
INFO: Pubkey bytes (32 bytes):
0000: 79 be 66 7e f9 dc bb ac 55 a0 62 95 ce 87 0b 07 |y.f~....U.b.....|
0010: 02 9b fc db 2d ce 28 d9 59 f2 81 5b 16 f8 17 98 |....-.(.Y..[....|
✅ SUCCESS: Signature hex converted to bytes
INFO: Signature bytes (64 bytes):
0000: 95 31 6a b7 5f 8d 02 bb 99 5a 12 48 c2 74 b9 9f |.1j._....Z.H.t..|
0010: 9b c5 dc 0a f5 64 9e 69 49 01 5d 06 99 04 d4 bd |.....d.iI.].....|
0020: f3 a3 c7 94 27 ac 82 45 69 86 a2 e9 37 b1 d2 5b |....'..Ei...7..[|
0030: 6d 2e e8 ee 1e 44 6a 84 9c b1 97 74 df 94 8e ad |m....Dj....t....|
🔍 STEP CRYPTO-8: Parsing public key into secp256k1 format
✅ SUCCESS: Public key parsed into secp256k1 format
🔍 STEP CRYPTO-9: Verifying Schnorr signature
✅ SUCCESS: Schnorr signature verification PASSED!
✅ SUCCESS: Detailed signature validation PASSED
═══════════════════════════════════════════════════════════════════
🔍 STEP COMPARE-1: Running standard nostr_validate_event for comparison
INFO: nostr_validate_event result: 0 (Success)
✅ SUCCESS: Standard validation PASSED - matches detailed validation
═══════════════════════════════════════════════════════════════════
✅ SUCCESS: 🎉 ALL VALIDATIONS PASSED! Event is completely valid.
✅ Structure validation: PASSED
✅ Signature validation: PASSED
✅ Standard validation: PASSED
═══════════════════════════════════════════════════════════════════

0
Trash/debug.log Normal file
View File

231
Trash/debug_hash_data.log Normal file
View File

@@ -0,0 +1,231 @@
=== HASH DEBUG SESSION ===
Content length: 296
File data to hash: 5465737420626c6f6220636f6e74656e7420666f722047696e78736f6d20426c6f73736f6d207365727665720a54696d657374616d703a20323032352d30382d32305430393a33333a32362d30343a30300a52616e646f6d20646174613a20323465336130393961313333323063653530396562323334663735663334663733656239393966616133373764346361636231343165616536313933396665370a54657374206d6573736167653a2048656c6c6f2066726f6d207075745f746573742e7368210a0a546869732066696c65206973207573656420746f2074657374207468652075706c6f61642066756e6374696f6e616c6974790a6f66207468652047696e78736f6d20426c6f73736f6d2073657276657220696d706c656d656e746174696f6e2e0a
File data as string: Test blob content for Ginxsom Blossom server
Timestamp: 2025-08-20T09:33:26-04:00
Random data: 24e3a099a13320ce509eb234f75f34f73eb999faa377d4cacb141eae61939fe7
Test message: Hello from put_test.sh!
This file is used to test the upload functionality
of the Ginxsom Blossom server implementation.
Calculated SHA-256: 97ed52416da9b486cc21ff71911ebb10b7298b1b12cdb5735fb8cfd76bb3d18e
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 296
File data to hash: 5465737420626c6f6220636f6e74656e7420666f722047696e78736f6d20426c6f73736f6d207365727665720a54696d657374616d703a20323032352d30382d32305430393a33393a32372d30343a30300a52616e646f6d20646174613a20383039303533333161616530366665333533313961366630666266383566636165313966663139346561643962643664363062393237636432303035616130330a54657374206d6573736167653a2048656c6c6f2066726f6d207075745f746573742e7368210a0a546869732066696c65206973207573656420746f2074657374207468652075706c6f61642066756e6374696f6e616c6974790a6f66207468652047696e78736f6d20426c6f73736f6d2073657276657220696d706c656d656e746174696f6e2e0a
File data as string: Test blob content for Ginxsom Blossom server
Timestamp: 2025-08-20T09:39:27-04:00
Random data: 80905331aae06fe35319a6f0fbf85fcae19ff194ead9bd6d60b927cd2005aa03
Test message: Hello from put_test.sh!
This file is used to test the upload functionality
of the Ginxsom Blossom server implementation.
Calculated SHA-256: 87714d44b5d3a3954de88a1ce6b46eaa0b0d11887879a23e649fce83f0adee62
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 296
File data to hash: 5465737420626c6f6220636f6e74656e7420666f722047696e78736f6d20426c6f73736f6d207365727665720a54696d657374616d703a20323032352d30392d30325430393a34343a33312d30343a30300a52616e646f6d20646174613a20376263336438313834326431363263643233393234356664393863316338363563343264383338646465653634343536653962633836366463313462353432610a54657374206d6573736167653a2048656c6c6f2066726f6d207075745f746573742e7368210a0a546869732066696c65206973207573656420746f2074657374207468652075706c6f61642066756e6374696f6e616c6974790a6f66207468652047696e78736f6d20426c6f73736f6d2073657276657220696d706c656d656e746174696f6e2e0a
File data as string: Test blob content for Ginxsom Blossom server
Timestamp: 2025-09-02T09:44:31-04:00
Random data: 7bc3d81842d162cd239245fd98c1c865c42d838ddee64456e9bc866dc14b542a
Test message: Hello from put_test.sh!
This file is used to test the upload functionality
of the Ginxsom Blossom server implementation.
Calculated SHA-256: 2f4958f2e57b6d74120583abbfa7571171e1f5ca21b9b32643184b8af0027cfc
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 83
File data to hash: 74657374206461746120666f7220686173682038343731363137316261623136616430323162643839353330353031383966653630373539313734333663643131636339333366303231626263356435623062
File data as string: test data for hash 84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b
Calculated SHA-256: d831a2b32ba89becc86fdb775c6fc09ad874bf126207fd275598f62d630044f4
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 9
File data to hash: 746573742064617461
File data as string: test data
Calculated SHA-256: 916f0027a575074ce72a331777c3478d6513f786a591bd892da1a577bf2335f9
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 39
File data to hash: 546869732069732061207365742066696c6520746f20746573742e20446f6e277420656469742e
File data as string: This is a set file to test. Don't edit.
Calculated SHA-256: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 296
File data to hash: 5465737420626c6f6220636f6e74656e7420666f722047696e78736f6d20426c6f73736f6d207365727665720a54696d657374616d703a20323032352d30392d30325431323a34353a32382d30343a30300a52616e646f6d20646174613a20386435393962643333353636323466636237383266383332623866303364396135333937326238343732613162646361633833656165333533653732323632310a54657374206d6573736167653a2048656c6c6f2066726f6d207075745f746573742e7368210a0a546869732066696c65206973207573656420746f2074657374207468652075706c6f61642066756e6374696f6e616c6974790a6f66207468652047696e78736f6d20426c6f73736f6d2073657276657220696d706c656d656e746174696f6e2e0a
File data as string: Test blob content for Ginxsom Blossom server
Timestamp: 2025-09-02T12:45:28-04:00
Random data: 8d599bd3356624fcb782f832b8f03d9a53972b8472a1bdcac83eae353e722621
Test message: Hello from put_test.sh!
This file is used to test the upload functionality
of the Ginxsom Blossom server implementation.
Calculated SHA-256: 7b3b92e2ffefed8c7444e9c78c432d279d859672e465bfc90fe44a7a2566a156
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 296
File data to hash: 5465737420626c6f6220636f6e74656e7420666f722047696e78736f6d20426c6f73736f6d207365727665720a54696d657374616d703a20323032352d30392d30325431323a34353a33332d30343a30300a52616e646f6d20646174613a20306434646365343535663861376264666238626431636338653930633235343666636237316630363839633337373435333061646661373138303134633930350a54657374206d6573736167653a2048656c6c6f2066726f6d207075745f746573742e7368210a0a546869732066696c65206973207573656420746f2074657374207468652075706c6f61642066756e6374696f6e616c6974790a6f66207468652047696e78736f6d20426c6f73736f6d2073657276657220696d706c656d656e746174696f6e2e0a
File data as string: Test blob content for Ginxsom Blossom server
Timestamp: 2025-09-02T12:45:33-04:00
Random data: 0d4dce455f8a7bdfb8bd1cc8e90c2546fcb71f0689c3774530adfa718014c905
Test message: Hello from put_test.sh!
This file is used to test the upload functionality
of the Ginxsom Blossom server implementation.
Calculated SHA-256: a27df9a425b43ca292eaf4e3779229d1955ea2e25aeddef196232008d4a25c5a
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 296
File data to hash: 5465737420626c6f6220636f6e74656e7420666f722047696e78736f6d20426c6f73736f6d207365727665720a54696d657374616d703a20323032352d30392d30325431323a34353a34322d30343a30300a52616e646f6d20646174613a20643239383630663962333735633266393634646433626362343436366661303138666537306163363333356234656537396365633030306334663764653165390a54657374206d6573736167653a2048656c6c6f2066726f6d207075745f746573742e7368210a0a546869732066696c65206973207573656420746f2074657374207468652075706c6f61642066756e6374696f6e616c6974790a6f66207468652047696e78736f6d20426c6f73736f6d2073657276657220696d706c656d656e746174696f6e2e0a
File data as string: Test blob content for Ginxsom Blossom server
Timestamp: 2025-09-02T12:45:42-04:00
Random data: d29860f9b375c2f964dd3bcb4466fa018fe70ac6335b4ee79cec000c4f7de1e9
Test message: Hello from put_test.sh!
This file is used to test the upload functionality
of the Ginxsom Blossom server implementation.
Calculated SHA-256: 61993aa6a0969bca4316461550095adbd2b5e82f691f514454a8f4082179c7c1
=== END DEBUG SESSION ===
=== HASH DEBUG SESSION ===
Content length: 296
File data to hash: 5465737420626c6f6220636f6e74656e7420666f722047696e78736f6d20426c6f73736f6d207365727665720a54696d657374616d703a20323032352d30392d30325431323a34363a35302d30343a30300a52616e646f6d20646174613a20346630333037316538646536373133353963633966326434633836383832356335393736303161333232346339323463313661633633643331323232353935650a54657374206d6573736167653a2048656c6c6f2066726f6d207075745f746573742e7368210a0a546869732066696c65206973207573656420746f2074657374207468652075706c6f61642066756e6374696f6e616c6974790a6f66207468652047696e78736f6d20426c6f73736f6d2073657276657220696d706c656d656e746174696f6e2e0a
File data as string: Test blob content for Ginxsom Blossom server
Timestamp: 2025-09-02T12:46:50-04:00
Random data: 4f03071e8de671359cc9f2d4c868825c597601a3224c924c16ac63d31222595e
Test message: Hello from put_test.sh!
This file is used to test the upload functionality
of the Ginxsom Blossom server implementation.
Calculated SHA-256: 8f68175a71f1a38e70e0dac1b45973510973fd713a37a10e9b4d04b1558a7999
=== END DEBUG SESSION ===

272
Trash/debug_validation.log Normal file
View File

@@ -0,0 +1,272 @@
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: -32 (Event has invalid public key)
CRYPTO VALIDATION FAILED!
Failed pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 (length: 64)
=== END CRYPTO DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===
=== STRUCTURE VALIDATION DEBUG ===
nostr_validate_event_structure result: 0 (Success)
=== END STRUCTURE DEBUG ===
=== CRYPTO VALIDATION DEBUG ===
nostr_verify_event_signature result: 0 (Success)
=== END CRYPTO DEBUG ===
=== COMPLETE VALIDATION DEBUG ===
nostr_validate_event result: 0 (Success)
=== END COMPLETE DEBUG ===

24
Trash/fastcgi_params Normal file
View File

@@ -0,0 +1,24 @@
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

5
Trash/fcgi-wrapper.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
# FastCGI wrapper script to redirect stderr to log file
exec 2>>logs/fcgi-stderr.log
echo "FastCGI wrapper starting at $(date)" >&2
exec ./build/ginxsom-fcgi "$@"

125
Trash/file_put_standard.sh Executable file
View File

@@ -0,0 +1,125 @@
#!/bin/bash
# file_put_standard.sh - Simple test with known good event for debugging
# This uses a fixed event and the existing standard_test.txt file
set -e
# Configuration
SERVER_URL="http://localhost:9001"
UPLOAD_ENDPOINT="${SERVER_URL}/upload"
TEST_FILE="standard_test.txt"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Known good nostr event with 1-year expiration (created with nak for standard_test.txt)
EVENT_JSON='{
"kind": 24242,
"id": "6f1e2ff851bde47ab2445aab8c8cbfae5c54f3d62c1892f13149fc5941ffc601",
"pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"created_at": 1756828081,
"tags": [
["t", "upload"],
["x", "3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540"],
["expiration", "1788364069"]
],
"content": "Upload standard test file",
"sig": "99df5bc594cfb550b3f46625d248275492ce2ec4b8f93111a192443fc6396129d9d64d3f7b380ef29c292d9fb46ca8279aeea6f91dae349ea3ca22bfb41e677f"
}'
echo "=== Ginxsom Standard Upload Test ==="
echo "Using known good event and existing standard_test.txt file"
echo
# Check if test file exists
if [ ! -f "$TEST_FILE" ]; then
echo -e "${RED}❌ Error: $TEST_FILE not found!${NC}"
exit 1
fi
echo -e "${BLUE}Event Details:${NC}"
echo "Pubkey: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
echo "Expected Hash: 3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540"
echo "Event ID: 6f1e2ff851bde47ab2445aab8c8cbfae5c54f3d62c1892f13149fc5941ffc601"
echo "Expiration: 1788364069 ($(date -d @1788364069 '+%Y-%m-%d %H:%M:%S %Z'))"
echo
echo -e "${BLUE}Full Event JSON:${NC}"
echo "$EVENT_JSON" | jq '.' 2>/dev/null || echo "$EVENT_JSON"
echo
# Verify the hash matches
echo -e "${YELLOW}Hash Verification:${NC}"
CALCULATED_HASH=$(sha256sum "$TEST_FILE" | cut -d' ' -f1)
EXPECTED_HASH="3f49f934e838893bdc516e680ade3cee2a848bbf42c3e7aba0108cf7cedb8540"
echo "File: $TEST_FILE ($(wc -c < "$TEST_FILE") bytes)"
echo "Content: $(cat "$TEST_FILE")"
echo "Calculated: $CALCULATED_HASH"
echo "Expected: $EXPECTED_HASH"
if [ "$CALCULATED_HASH" = "$EXPECTED_HASH" ]; then
echo -e "${GREEN}✓ Hash matches!${NC}"
else
echo -e "${RED}✗ Hash mismatch!${NC}"
exit 1
fi
echo
# Create authorization header
echo -e "${YELLOW}Creating authorization header...${NC}"
AUTH_B64=$(echo -n "$EVENT_JSON" | base64 -w 0)
AUTH_HEADER="Nostr $AUTH_B64"
echo "Authorization header created (length: ${#AUTH_HEADER})"
echo
# Perform the upload
echo -e "${YELLOW}Uploading to ${UPLOAD_ENDPOINT}...${NC}"
echo
HTTP_STATUS=$(curl -s -w "%{http_code}" \
-X PUT \
-H "Authorization: $AUTH_HEADER" \
-H "Content-Type: text/plain" \
--data-binary @"$TEST_FILE" \
"$UPLOAD_ENDPOINT" \
-o response.json)
echo "HTTP Status: $HTTP_STATUS"
echo -e "${BLUE}Response:${NC}"
cat response.json | jq '.' 2>/dev/null || cat response.json
echo
# Check result
case "$HTTP_STATUS" in
200)
echo -e "${GREEN}✅ Upload successful!${NC}"
;;
201)
echo -e "${GREEN}✅ Upload successful (created)!${NC}"
;;
400)
echo -e "${RED}❌ Bad request${NC}"
;;
401)
echo -e "${RED}❌ Unauthorized - authentication failed${NC}"
;;
*)
echo -e "${RED}❌ Upload failed with status: $HTTP_STATUS${NC}"
;;
esac
# Cleanup response file only
rm -f response.json
echo
echo -e "${BLUE}Debug Info:${NC}"
echo "Check these files for detailed logs:"
echo " - logs/fcgi-stderr.log"
echo " - debug_validation.log"
echo " - logs/error.log"

0
Trash/server_debug.log Normal file
View File

10
Trash/server_response.log Normal file
View File

@@ -0,0 +1,10 @@
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 179 100 166 100 13 25917 2029 --:--:-- --:--:-- --:--:-- 29833
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.18.0 (Ubuntu)</center>

1
Trash/standard_test.txt Normal file
View File

@@ -0,0 +1 @@
This is a set file to test. Don't edit.

BIN
Trash/test_auth_debug Executable file

Binary file not shown.

765
Trash/test_auth_debug.c Normal file
View File

@@ -0,0 +1,765 @@
/*
* Debug test for Authorization header processing
* Tests the exact same flow as the ginxsom server with detailed step-by-step logging
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "nostr_core_lib/nostr_core/nip001.h"
#include "nostr_core_lib/nostr_core/nostr_common.h"
#include "nostr_core_lib/nostr_core/utils.h"
#include "nostr_core_lib/nostr_core/crypto/nostr_secp256k1.h"
#include "nostr_core_lib/cjson/cJSON.h"
// Logging utility
#define LOG_STEP(step, msg, ...) printf("🔍 STEP %s: " msg "\n", step, ##__VA_ARGS__)
#define LOG_SUCCESS(msg, ...) printf("✅ SUCCESS: " msg "\n", ##__VA_ARGS__)
#define LOG_ERROR(msg, ...) printf("❌ ERROR: " msg "\n", ##__VA_ARGS__)
#define LOG_INFO(msg, ...) printf(" INFO: " msg "\n", ##__VA_ARGS__)
#define LOG_DIVIDER() printf("═══════════════════════════════════════════════════════════════════\n")
// Forward declarations for detailed validation functions
int detailed_structure_validation(cJSON* event);
int detailed_signature_validation(cJSON* event);
void analyze_event_fields(cJSON* event);
void analyze_serialization(cJSON* event);
void hex_dump(const char* label, const unsigned char* data, size_t len);
// Copy the exact parse_authorization_header function from main.c
int parse_authorization_header(const char* auth_header, char* event_json, size_t json_size) {
if (!auth_header || !event_json) {
printf("DEBUG: parse_authorization_header - invalid parameters: auth_header=%p, event_json=%p\r\n",
(void*)auth_header, (void*)event_json);
return NOSTR_ERROR_INVALID_INPUT;
}
printf("DEBUG: parse_authorization_header called with header: %.50s...\r\n", auth_header);
// Check for "Nostr " prefix (case-insensitive)
const char* prefix = "nostr ";
size_t prefix_len = strlen(prefix);
if (strncasecmp(auth_header, prefix, prefix_len) != 0) {
printf("DEBUG: Authorization header missing 'Nostr ' prefix (found: %.10s)\r\n", auth_header);
return NOSTR_ERROR_INVALID_INPUT;
}
// Extract base64 encoded event after "Nostr "
const char* base64_event = auth_header + prefix_len;
printf("DEBUG: Extracted base64 event (length=%zu): %.100s...\r\n", strlen(base64_event), base64_event);
// Decode base64 to JSON using nostr_core_lib base64 decode
unsigned char decoded_buffer[4096];
size_t decoded_len = base64_decode(base64_event, decoded_buffer);
printf("DEBUG: Base64 decode result - decoded_len=%zu\r\n", decoded_len);
if (decoded_len == 0) {
printf("DEBUG: Failed to decode base64 event - base64_decode returned 0\r\n");
return NOSTR_ERROR_INVALID_INPUT;
}
if (decoded_len >= json_size) {
printf("DEBUG: Decoded JSON too large for buffer (decoded_len=%zu, json_size=%zu)\r\n", decoded_len, json_size);
return NOSTR_ERROR_INVALID_INPUT;
}
// Copy decoded JSON to output buffer
memcpy(event_json, decoded_buffer, decoded_len);
event_json[decoded_len] = '\0';
printf("DEBUG: Successfully decoded JSON (length=%zu): %s\r\n", decoded_len, event_json);
return NOSTR_SUCCESS;
}
/**
* Detailed structure validation with step-by-step logging
*/
int detailed_structure_validation(cJSON* event) {
LOG_DIVIDER();
LOG_STEP("STRUCT-1", "Starting detailed structure validation");
if (!event || !cJSON_IsObject(event)) {
LOG_ERROR("Event is null or not a JSON object");
return NOSTR_ERROR_EVENT_INVALID_STRUCTURE;
}
LOG_SUCCESS("Event is valid JSON object");
// Check each required field existence
LOG_STEP("STRUCT-2", "Checking required field existence");
const char* required_fields[] = {"id", "pubkey", "created_at", "kind", "tags", "content", "sig"};
for (int i = 0; i < 7; i++) {
cJSON* field = cJSON_GetObjectItem(event, required_fields[i]);
if (!field) {
LOG_ERROR("Missing required field: %s", required_fields[i]);
return NOSTR_ERROR_EVENT_INVALID_STRUCTURE;
}
LOG_SUCCESS("Field '%s' exists", required_fields[i]);
}
// Get all fields for detailed validation
cJSON* id_item = cJSON_GetObjectItem(event, "id");
cJSON* pubkey_item = cJSON_GetObjectItem(event, "pubkey");
cJSON* created_at_item = cJSON_GetObjectItem(event, "created_at");
cJSON* kind_item = cJSON_GetObjectItem(event, "kind");
cJSON* tags_item = cJSON_GetObjectItem(event, "tags");
cJSON* content_item = cJSON_GetObjectItem(event, "content");
cJSON* sig_item = cJSON_GetObjectItem(event, "sig");
// Validate field types
LOG_STEP("STRUCT-3", "Validating field types");
if (!cJSON_IsString(id_item)) {
LOG_ERROR("Field 'id' is not a string (type: %d)", id_item->type);
return NOSTR_ERROR_EVENT_INVALID_ID;
}
LOG_SUCCESS("Field 'id' is string");
if (!cJSON_IsString(pubkey_item)) {
LOG_ERROR("Field 'pubkey' is not a string (type: %d)", pubkey_item->type);
return NOSTR_ERROR_EVENT_INVALID_PUBKEY;
}
LOG_SUCCESS("Field 'pubkey' is string");
if (!cJSON_IsNumber(created_at_item)) {
LOG_ERROR("Field 'created_at' is not a number (type: %d)", created_at_item->type);
return NOSTR_ERROR_EVENT_INVALID_CREATED_AT;
}
LOG_SUCCESS("Field 'created_at' is number");
if (!cJSON_IsNumber(kind_item)) {
LOG_ERROR("Field 'kind' is not a number (type: %d)", kind_item->type);
return NOSTR_ERROR_EVENT_INVALID_KIND;
}
LOG_SUCCESS("Field 'kind' is number");
if (!cJSON_IsArray(tags_item)) {
LOG_ERROR("Field 'tags' is not an array (type: %d)", tags_item->type);
return NOSTR_ERROR_EVENT_INVALID_TAGS;
}
LOG_SUCCESS("Field 'tags' is array");
if (!cJSON_IsString(content_item)) {
LOG_ERROR("Field 'content' is not a string (type: %d)", content_item->type);
return NOSTR_ERROR_EVENT_INVALID_CONTENT;
}
LOG_SUCCESS("Field 'content' is string");
if (!cJSON_IsString(sig_item)) {
LOG_ERROR("Field 'sig' is not a string (type: %d)", sig_item->type);
return NOSTR_ERROR_EVENT_INVALID_SIGNATURE;
}
LOG_SUCCESS("Field 'sig' is string");
// Validate hex string lengths
LOG_STEP("STRUCT-4", "Validating hex string lengths");
const char* id_str = cJSON_GetStringValue(id_item);
const char* pubkey_str = cJSON_GetStringValue(pubkey_item);
const char* sig_str = cJSON_GetStringValue(sig_item);
LOG_INFO("ID string: '%s' (length: %zu)", id_str, id_str ? strlen(id_str) : 0);
if (!id_str || strlen(id_str) != 64) {
LOG_ERROR("ID string invalid length (expected 64, got %zu)", id_str ? strlen(id_str) : 0);
return NOSTR_ERROR_EVENT_INVALID_ID;
}
LOG_SUCCESS("ID string length is correct (64 chars)");
LOG_INFO("Pubkey string: '%s' (length: %zu)", pubkey_str, pubkey_str ? strlen(pubkey_str) : 0);
if (!pubkey_str || strlen(pubkey_str) != 64) {
LOG_ERROR("Pubkey string invalid length (expected 64, got %zu)", pubkey_str ? strlen(pubkey_str) : 0);
return NOSTR_ERROR_EVENT_INVALID_PUBKEY;
}
LOG_SUCCESS("Pubkey string length is correct (64 chars)");
LOG_INFO("Signature string: '%s' (length: %zu)", sig_str, sig_str ? strlen(sig_str) : 0);
if (!sig_str || strlen(sig_str) != 128) {
LOG_ERROR("Signature string invalid length (expected 128, got %zu)", sig_str ? strlen(sig_str) : 0);
return NOSTR_ERROR_EVENT_INVALID_SIGNATURE;
}
LOG_SUCCESS("Signature string length is correct (128 chars)");
// Validate hex characters
LOG_STEP("STRUCT-5", "Validating hex characters");
LOG_INFO("Checking ID hex characters...");
for (int i = 0; i < 64; i++) {
char c = id_str[i];
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'))) {
LOG_ERROR("Invalid hex character in ID at position %d: '%c' (0x%02x)", i, c, (unsigned char)c);
return NOSTR_ERROR_EVENT_INVALID_ID;
}
}
LOG_SUCCESS("ID hex characters are valid (lowercase)");
LOG_INFO("Checking pubkey hex characters...");
for (int i = 0; i < 64; i++) {
char c = pubkey_str[i];
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'))) {
LOG_ERROR("Invalid hex character in pubkey at position %d: '%c' (0x%02x)", i, c, (unsigned char)c);
return NOSTR_ERROR_EVENT_INVALID_PUBKEY;
}
}
LOG_SUCCESS("Pubkey hex characters are valid (lowercase)");
LOG_INFO("Checking signature hex characters...");
for (int i = 0; i < 128; i++) {
char c = sig_str[i];
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'))) {
LOG_ERROR("Invalid hex character in signature at position %d: '%c' (0x%02x)", i, c, (unsigned char)c);
return NOSTR_ERROR_EVENT_INVALID_SIGNATURE;
}
}
LOG_SUCCESS("Signature hex characters are valid (lowercase)");
// Validate timestamp
LOG_STEP("STRUCT-6", "Validating timestamp");
double created_at = cJSON_GetNumberValue(created_at_item);
LOG_INFO("Created_at timestamp: %.0f", created_at);
if (created_at < 0) {
LOG_ERROR("Invalid timestamp (negative): %.0f", created_at);
return NOSTR_ERROR_EVENT_INVALID_CREATED_AT;
}
// Convert to human readable time
time_t timestamp = (time_t)created_at;
char time_str[100];
struct tm* tm_info = gmtime(&timestamp);
strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S UTC", tm_info);
LOG_SUCCESS("Timestamp is valid: %s", time_str);
// Validate kind
LOG_STEP("STRUCT-7", "Validating kind");
double kind = cJSON_GetNumberValue(kind_item);
LOG_INFO("Event kind: %.0f", kind);
if (kind < 0 || kind > 65535 || kind != (int)kind) {
LOG_ERROR("Invalid kind value: %.0f (must be integer 0-65535)", kind);
return NOSTR_ERROR_EVENT_INVALID_KIND;
}
LOG_SUCCESS("Kind is valid: %d", (int)kind);
// Validate tags array structure
LOG_STEP("STRUCT-8", "Validating tags array structure");
int tag_count = cJSON_GetArraySize(tags_item);
LOG_INFO("Tags array has %d elements", tag_count);
cJSON* tag_item;
int tag_index = 0;
cJSON_ArrayForEach(tag_item, tags_item) {
if (!cJSON_IsArray(tag_item)) {
LOG_ERROR("Tag at index %d is not an array (type: %d)", tag_index, tag_item->type);
return NOSTR_ERROR_EVENT_INVALID_TAGS;
}
int tag_element_count = cJSON_GetArraySize(tag_item);
LOG_INFO("Tag[%d] has %d elements", tag_index, tag_element_count);
cJSON* tag_element;
int element_index = 0;
cJSON_ArrayForEach(tag_element, tag_item) {
if (!cJSON_IsString(tag_element)) {
LOG_ERROR("Tag[%d][%d] is not a string (type: %d)", tag_index, element_index, tag_element->type);
return NOSTR_ERROR_EVENT_INVALID_TAGS;
}
const char* tag_value = cJSON_GetStringValue(tag_element);
LOG_INFO("Tag[%d][%d]: '%s'", tag_index, element_index, tag_value);
element_index++;
}
tag_index++;
}
LOG_SUCCESS("Tags array structure is valid");
// Validate content
LOG_STEP("STRUCT-9", "Validating content");
const char* content_str = cJSON_GetStringValue(content_item);
LOG_INFO("Content: '%s' (length: %zu)", content_str, content_str ? strlen(content_str) : 0);
LOG_SUCCESS("Content is valid string");
LOG_SUCCESS("Structure validation completed successfully");
return NOSTR_SUCCESS;
}
/**
* Detailed signature validation with step-by-step logging
*/
int detailed_signature_validation(cJSON* event) {
LOG_DIVIDER();
LOG_STEP("CRYPTO-1", "Starting detailed signature validation");
if (!event) {
LOG_ERROR("Event is null");
return NOSTR_ERROR_INVALID_INPUT;
}
// Get event fields
cJSON* id_item = cJSON_GetObjectItem(event, "id");
cJSON* pubkey_item = cJSON_GetObjectItem(event, "pubkey");
cJSON* created_at_item = cJSON_GetObjectItem(event, "created_at");
cJSON* kind_item = cJSON_GetObjectItem(event, "kind");
cJSON* tags_item = cJSON_GetObjectItem(event, "tags");
cJSON* content_item = cJSON_GetObjectItem(event, "content");
cJSON* sig_item = cJSON_GetObjectItem(event, "sig");
if (!id_item || !pubkey_item || !created_at_item || !kind_item ||
!tags_item || !content_item || !sig_item) {
LOG_ERROR("Missing required fields for signature validation");
return NOSTR_ERROR_EVENT_INVALID_STRUCTURE;
}
// Create serialization array
LOG_STEP("CRYPTO-2", "Creating serialization array");
cJSON* serialize_array = cJSON_CreateArray();
if (!serialize_array) {
LOG_ERROR("Failed to create serialization array");
return NOSTR_ERROR_MEMORY_FAILED;
}
cJSON_AddItemToArray(serialize_array, cJSON_CreateNumber(0));
cJSON_AddItemToArray(serialize_array, cJSON_Duplicate(pubkey_item, 1));
cJSON_AddItemToArray(serialize_array, cJSON_Duplicate(created_at_item, 1));
cJSON_AddItemToArray(serialize_array, cJSON_Duplicate(kind_item, 1));
cJSON_AddItemToArray(serialize_array, cJSON_Duplicate(tags_item, 1));
cJSON_AddItemToArray(serialize_array, cJSON_Duplicate(content_item, 1));
LOG_SUCCESS("Serialization array created");
// Convert to JSON string
LOG_STEP("CRYPTO-3", "Converting to JSON string");
char* serialize_string = cJSON_PrintUnformatted(serialize_array);
cJSON_Delete(serialize_array);
if (!serialize_string) {
LOG_ERROR("Failed to serialize array to JSON string");
return NOSTR_ERROR_MEMORY_FAILED;
}
LOG_SUCCESS("JSON serialization string created");
LOG_INFO("Serialization string (length %zu): %s", strlen(serialize_string), serialize_string);
// Hash the serialized event
LOG_STEP("CRYPTO-4", "Computing SHA256 hash");
unsigned char event_hash[32];
if (nostr_sha256((const unsigned char*)serialize_string, strlen(serialize_string), event_hash) != 0) {
LOG_ERROR("SHA256 hashing failed");
free(serialize_string);
return NOSTR_ERROR_CRYPTO_FAILED;
}
LOG_SUCCESS("SHA256 hash computed");
hex_dump("Event hash", event_hash, 32);
// Convert hash to hex for event ID verification
LOG_STEP("CRYPTO-5", "Verifying event ID");
char calculated_id[65];
nostr_bytes_to_hex(event_hash, 32, calculated_id);
const char* provided_id = cJSON_GetStringValue(id_item);
LOG_INFO("Calculated ID: %s", calculated_id);
LOG_INFO("Provided ID: %s", provided_id);
if (!provided_id || strcmp(calculated_id, provided_id) != 0) {
LOG_ERROR("Event ID mismatch!");
LOG_ERROR(" Expected: %s", calculated_id);
LOG_ERROR(" Got: %s", provided_id ? provided_id : "NULL");
free(serialize_string);
return NOSTR_ERROR_EVENT_INVALID_ID;
}
LOG_SUCCESS("Event ID verification passed");
// Prepare signature verification
LOG_STEP("CRYPTO-6", "Preparing signature verification");
const char* pubkey_str = cJSON_GetStringValue(pubkey_item);
const char* sig_str = cJSON_GetStringValue(sig_item);
if (!pubkey_str || !sig_str) {
LOG_ERROR("Missing pubkey or signature strings");
free(serialize_string);
return NOSTR_ERROR_EVENT_INVALID_STRUCTURE;
}
// Convert hex strings to bytes
LOG_STEP("CRYPTO-7", "Converting hex strings to bytes");
unsigned char pubkey_bytes[32];
unsigned char sig_bytes[64];
if (nostr_hex_to_bytes(pubkey_str, pubkey_bytes, 32) != 0) {
LOG_ERROR("Failed to convert pubkey hex to bytes");
free(serialize_string);
return NOSTR_ERROR_CRYPTO_FAILED;
}
LOG_SUCCESS("Pubkey hex converted to bytes");
hex_dump("Pubkey bytes", pubkey_bytes, 32);
if (nostr_hex_to_bytes(sig_str, sig_bytes, 64) != 0) {
LOG_ERROR("Failed to convert signature hex to bytes");
free(serialize_string);
return NOSTR_ERROR_CRYPTO_FAILED;
}
LOG_SUCCESS("Signature hex converted to bytes");
hex_dump("Signature bytes", sig_bytes, 64);
// Parse the public key into secp256k1 format
LOG_STEP("CRYPTO-8", "Parsing public key into secp256k1 format");
nostr_secp256k1_xonly_pubkey xonly_pubkey;
if (!nostr_secp256k1_xonly_pubkey_parse(&xonly_pubkey, pubkey_bytes)) {
LOG_ERROR("Failed to parse public key into secp256k1 format");
free(serialize_string);
return NOSTR_ERROR_EVENT_INVALID_PUBKEY;
}
LOG_SUCCESS("Public key parsed into secp256k1 format");
// Verify Schnorr signature
LOG_STEP("CRYPTO-9", "Verifying Schnorr signature");
if (!nostr_secp256k1_schnorrsig_verify(sig_bytes, event_hash, &xonly_pubkey)) {
LOG_ERROR("Schnorr signature verification FAILED!");
LOG_ERROR("This means the signature does not match the event hash and public key");
free(serialize_string);
return NOSTR_ERROR_EVENT_INVALID_SIGNATURE;
}
LOG_SUCCESS("Schnorr signature verification PASSED!");
free(serialize_string);
return NOSTR_SUCCESS;
}
/**
* Analyze event fields in detail
*/
void analyze_event_fields(cJSON* event) {
LOG_DIVIDER();
LOG_STEP("ANALYZE-1", "Analyzing event field details");
cJSON* field;
cJSON_ArrayForEach(field, event) {
if (field->string) {
LOG_INFO("Field '%s':", field->string);
if (cJSON_IsString(field)) {
const char* value = cJSON_GetStringValue(field);
LOG_INFO(" Type: String");
LOG_INFO(" Value: '%s'", value);
LOG_INFO(" Length: %zu", value ? strlen(value) : 0);
} else if (cJSON_IsNumber(field)) {
double value = cJSON_GetNumberValue(field);
LOG_INFO(" Type: Number");
LOG_INFO(" Value: %.0f", value);
} else if (cJSON_IsArray(field)) {
int size = cJSON_GetArraySize(field);
LOG_INFO(" Type: Array");
LOG_INFO(" Size: %d", size);
} else {
LOG_INFO(" Type: Other (%d)", field->type);
}
}
}
}
/**
* Print hex dump of binary data
*/
void hex_dump(const char* label, const unsigned char* data, size_t len) {
LOG_INFO("%s (%zu bytes):", label, len);
for (size_t i = 0; i < len; i += 16) {
printf(" %04zx: ", i);
for (size_t j = 0; j < 16; j++) {
if (i + j < len) {
printf("%02x ", data[i + j]);
} else {
printf(" ");
}
}
printf(" |");
for (size_t j = 0; j < 16 && i + j < len; j++) {
unsigned char c = data[i + j];
printf("%c", (c >= 32 && c <= 126) ? c : '.');
}
printf("|\n");
}
}
/**
* Mirror the exact server-side validation flow for comparison
*/
int server_style_authentication(const char* auth_header, const char* method, const char* file_hash) {
LOG_DIVIDER();
LOG_STEP("SERVER-1", "Starting server-style authentication (mirroring main.c)");
if (!auth_header) {
LOG_ERROR("No authorization header provided");
return NOSTR_ERROR_INVALID_INPUT;
}
LOG_INFO("Server-style auth called with method: %s, hash: %s",
method ? method : "null", file_hash ? file_hash : "null");
// Parse authorization header (same as server)
char event_json[4096];
LOG_STEP("SERVER-2", "Calling parse_authorization_header");
int parse_result = parse_authorization_header(auth_header, event_json, sizeof(event_json));
if (parse_result != NOSTR_SUCCESS) {
LOG_ERROR("Authorization header parsing failed: %d (%s)", parse_result, nostr_strerror(parse_result));
return parse_result;
}
LOG_SUCCESS("parse_authorization_header succeeded");
// Parse JSON event (same as server)
LOG_STEP("SERVER-3", "Calling cJSON_Parse on JSON string");
LOG_INFO("JSON to parse: %s", event_json);
cJSON* event = cJSON_Parse(event_json);
if (!event) {
LOG_ERROR("Failed to parse JSON event with cJSON_Parse");
return NOSTR_ERROR_EVENT_INVALID_CONTENT;
}
LOG_SUCCESS("cJSON_Parse succeeded, event parsed");
// Print complete parsed JSON like server does
char* parsed_json_str = cJSON_Print(event);
LOG_INFO("Parsed JSON: %s", parsed_json_str ? parsed_json_str : "NULL");
if (parsed_json_str) free(parsed_json_str);
// Debug: Print event fields before validation (same as server)
cJSON* id_json = cJSON_GetObjectItem(event, "id");
cJSON* pubkey_json = cJSON_GetObjectItem(event, "pubkey");
cJSON* sig_json = cJSON_GetObjectItem(event, "sig");
cJSON* kind_json = cJSON_GetObjectItem(event, "kind");
cJSON* created_at_json = cJSON_GetObjectItem(event, "created_at");
LOG_STEP("SERVER-4", "Event fields before validation");
LOG_INFO(" id: %s", id_json && cJSON_IsString(id_json) ? cJSON_GetStringValue(id_json) : "MISSING/INVALID");
LOG_INFO(" pubkey: %s", pubkey_json && cJSON_IsString(pubkey_json) ? cJSON_GetStringValue(pubkey_json) : "MISSING/INVALID");
LOG_INFO(" sig: %s", sig_json && cJSON_IsString(sig_json) ? cJSON_GetStringValue(sig_json) : "MISSING/INVALID");
LOG_INFO(" kind: %d", kind_json && cJSON_IsNumber(kind_json) ? (int)cJSON_GetNumberValue(kind_json) : -999);
LOG_INFO(" created_at: %ld", created_at_json && cJSON_IsNumber(created_at_json) ? (long)cJSON_GetNumberValue(created_at_json) : -999);
// Detailed pubkey analysis (same as server)
if (pubkey_json && cJSON_IsString(pubkey_json)) {
const char* pubkey_str = cJSON_GetStringValue(pubkey_json);
LOG_STEP("SERVER-5", "Detailed pubkey analysis");
LOG_INFO(" Pubkey: %s", pubkey_str ? pubkey_str : "NULL");
LOG_INFO(" Length: %zu", pubkey_str ? strlen(pubkey_str) : 0);
if (pubkey_str && strlen(pubkey_str) == 64) {
LOG_INFO(" Character analysis (first 10): ");
for (int i = 0; i < 10; i++) {
char c = pubkey_str[i];
printf("%c(0x%02x) ", c, (unsigned char)c);
}
printf("\n");
}
}
// Pre-validation pubkey analysis (same as server)
LOG_STEP("SERVER-6", "Pre-validation pubkey analysis");
if (pubkey_json && cJSON_IsString(pubkey_json)) {
const char* pubkey_str = cJSON_GetStringValue(pubkey_json);
LOG_INFO(" Pubkey: %s", pubkey_str ? pubkey_str : "NULL");
LOG_INFO(" Length: %zu", pubkey_str ? strlen(pubkey_str) : 0);
if (pubkey_str && strlen(pubkey_str) == 64) {
LOG_INFO(" Character analysis (first 10): ");
for (int i = 0; i < 10; i++) {
char c = pubkey_str[i];
printf("%c(%d) ", c, (int)c);
}
printf("\n");
LOG_INFO(" Character validation test: ");
int valid_chars = 1;
for (int i = 0; i < 64; i++) {
char c = pubkey_str[i];
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'))) {
printf("INVALID at pos %d: %c(%d) ", i, c, (int)c);
valid_chars = 0;
}
}
if (valid_chars) {
printf("ALL VALID (lowercase hex)\n");
} else {
printf("\n");
}
}
}
// Detailed validation analysis (same as server)
LOG_STEP("SERVER-7", "Starting detailed validation analysis");
// Test structure validation first (same as server)
LOG_INFO("Testing structure validation...");
int structure_result = nostr_validate_event_structure(event);
LOG_INFO("nostr_validate_event_structure returned: %d (%s)",
structure_result, nostr_strerror(structure_result));
if (structure_result != NOSTR_SUCCESS) {
LOG_ERROR("STRUCTURE validation failed!");
cJSON_Delete(event);
return structure_result;
}
LOG_SUCCESS("Structure validation PASSED");
// Test crypto validation separately (same as server)
LOG_INFO("Testing cryptographic verification...");
int crypto_result = nostr_verify_event_signature(event);
LOG_INFO("nostr_verify_event_signature returned: %d (%s)",
crypto_result, nostr_strerror(crypto_result));
if (crypto_result != NOSTR_SUCCESS) {
LOG_ERROR("CRYPTO verification failed!");
if (pubkey_json && cJSON_IsString(pubkey_json)) {
const char* pubkey_str = cJSON_GetStringValue(pubkey_json);
LOG_ERROR("Failed pubkey: %s (length: %zu)",
pubkey_str ? pubkey_str : "NULL", pubkey_str ? strlen(pubkey_str) : 0);
}
cJSON_Delete(event);
return crypto_result;
}
LOG_SUCCESS("Crypto verification PASSED");
// Finally test complete validation (same as server)
LOG_INFO("Testing complete validation...");
int validation_result = nostr_validate_event(event);
LOG_INFO("nostr_validate_event returned: %d (%s)",
validation_result, nostr_strerror(validation_result));
if (validation_result != NOSTR_SUCCESS) {
LOG_ERROR("COMPLETE validation failed: %d (%s)",
validation_result, nostr_strerror(validation_result));
// Additional debug: Check specific validation issues (same as server)
if (pubkey_json && cJSON_IsString(pubkey_json)) {
const char* pubkey_str = cJSON_GetStringValue(pubkey_json);
LOG_ERROR("Pubkey length: %zu, value: %s",
pubkey_str ? strlen(pubkey_str) : 0, pubkey_str ? pubkey_str : "NULL");
}
cJSON_Delete(event);
return validation_result;
}
LOG_SUCCESS("Complete validation PASSED");
cJSON_Delete(event);
LOG_SUCCESS("Server-style authentication successful, returning NOSTR_SUCCESS");
return NOSTR_SUCCESS;
}
int main(void) {
LOG_DIVIDER();
printf("🔧 COMPREHENSIVE NOSTR EVENT VALIDATION DEBUG TEST 🔧\n");
LOG_DIVIDER();
// Initialize crypto library
LOG_STEP("INIT-1", "Initializing nostr library");
if (nostr_init() != NOSTR_SUCCESS) {
LOG_ERROR("Failed to initialize nostr library");
return 1;
}
LOG_SUCCESS("Nostr library initialized");
// The actual failing Authorization header from your upload attempt
const char* auth_header = "Nostr eyJraW5kIjoyNDI0MiwiaWQiOiI5NTYxNjA1YjEwNjJjZTM3ZTk1YWI5YjgxZDMwMGQ5YWQ1YmZiOWM1NDRhZTM5NWUxZWI0MWYwMDBjN2Q4OWY2IiwicHVia2V5IjoiNzliZTY2N2VmOWRjYmJhYzU1YTA2Mjk1Y2U4NzBiMDcwMjliZmNkYjJkY2UyOGQ5NTlmMjgxNWIxNmY4MTc5OCIsImNyZWF0ZWRfYXQiOjE3NTU2ODU0MjgsInRhZ3MiOltbInQiLCJ1cGxvYWQiXSxbIngiLCI4NDcxNjE3MWJhYjE2YWQwMjFiZDg5NTMwNTAxODlmZTYwNzU5MTc0MzZjZDExY2M5MzNmMDIxYmJjNWQ1YjBiIl0sWyJleHBpcmF0aW9uIiwiMTc1NTY4OTAyOCJdXSwiY29udGVudCI6IiIsInNpZyI6Ijk1MzE2YWI3NWY4ZDAyYmI5OTVhMTI0OGMyNzRiOTlmOWJjNWRjMGFmNTY0OWU2OTQ5MDE1ZDA2OTkwNGQ0YmRmM2EzYzc5NDI3YWM4MjQ1Njk4NmEyZTkzN2IxZDI1YjZkMmVlOGVlMWU0NDZhODQ5Y2IxOTc3NGRmOTQ4ZWFkIn0=";
LOG_INFO("Testing Authorization header:");
printf("%s\n", auth_header);
// Step 1: Parse the Authorization header
LOG_DIVIDER();
LOG_STEP("PARSE-1", "Parsing Authorization header");
char event_json[4096];
int parse_result = parse_authorization_header(auth_header, event_json, sizeof(event_json));
if (parse_result != NOSTR_SUCCESS) {
LOG_ERROR("Parse failed with error: %d (%s)", parse_result, nostr_strerror(parse_result));
nostr_cleanup();
return 1;
}
LOG_SUCCESS("Authorization header parsed successfully");
LOG_INFO("Decoded JSON: %s", event_json);
// Step 2: Parse the JSON
LOG_STEP("PARSE-2", "Parsing JSON string");
cJSON* event = cJSON_Parse(event_json);
if (!event) {
LOG_ERROR("JSON parsing failed - invalid JSON syntax");
nostr_cleanup();
return 1;
}
LOG_SUCCESS("JSON parsing successful");
// Step 3: Analyze event fields
analyze_event_fields(event);
// Step 4: Detailed structure validation
LOG_STEP("MAIN-1", "Running detailed structure validation");
int structure_result = detailed_structure_validation(event);
if (structure_result != NOSTR_SUCCESS) {
LOG_ERROR("Structure validation failed: %d (%s)", structure_result, nostr_strerror(structure_result));
LOG_ERROR("VALIDATION FAILED AT STRUCTURE LEVEL");
cJSON_Delete(event);
nostr_cleanup();
return 1;
}
LOG_SUCCESS("Detailed structure validation PASSED");
// Step 5: Detailed signature validation
LOG_STEP("MAIN-2", "Running detailed signature validation");
int crypto_result = detailed_signature_validation(event);
if (crypto_result != NOSTR_SUCCESS) {
LOG_ERROR("Signature validation failed: %d (%s)", crypto_result, nostr_strerror(crypto_result));
LOG_ERROR("VALIDATION FAILED AT CRYPTOGRAPHIC LEVEL");
cJSON_Delete(event);
nostr_cleanup();
return 1;
}
LOG_SUCCESS("Detailed signature validation PASSED");
// Step 6: Run standard nostr validation for comparison
LOG_DIVIDER();
LOG_STEP("COMPARE-1", "Running standard nostr_validate_event for comparison");
int validation_result = nostr_validate_event(event);
LOG_INFO("nostr_validate_event result: %d (%s)", validation_result, nostr_strerror(validation_result));
if (validation_result == NOSTR_SUCCESS) {
LOG_SUCCESS("Standard validation PASSED - matches detailed validation");
} else {
LOG_ERROR("Standard validation FAILED - inconsistent with detailed validation!");
LOG_ERROR("This indicates a potential issue in the standard validation logic");
}
// Step 7: Run server-style authentication for direct comparison
LOG_STEP("COMPARE-2", "Running server-style authentication (exact mirror of server code)");
int server_result = server_style_authentication(auth_header, "upload", "84716171bab16ad021bd8953050189fe6075917436cd11cc933f021bbc5d5b0b");
LOG_INFO("server_style_authentication result: %d (%s)", server_result, nostr_strerror(server_result));
if (server_result == NOSTR_SUCCESS) {
LOG_SUCCESS("Server-style validation PASSED");
} else {
LOG_ERROR("Server-style validation FAILED - this shows exactly where server diverges!");
}
// Final summary
LOG_DIVIDER();
if (structure_result == NOSTR_SUCCESS && crypto_result == NOSTR_SUCCESS) {
LOG_SUCCESS("🎉 ALL DETAILED VALIDATIONS PASSED! Event is completely valid.");
printf("✅ Structure validation: PASSED\n");
printf("✅ Signature validation: PASSED\n");
printf("✅ Standard validation: %s\n",
(validation_result == NOSTR_SUCCESS) ? "PASSED" : "FAILED (inconsistent!)");
printf("✅ Server-style validation: %s\n",
(server_result == NOSTR_SUCCESS) ? "PASSED" : "FAILED (shows server issue!)");
} else {
LOG_ERROR("❌ VALIDATION FAILED!");
printf("Structure validation: %s (%d)\n",
(structure_result == NOSTR_SUCCESS) ? "PASSED" : "FAILED", structure_result);
printf("Signature validation: %s (%d)\n",
(crypto_result == NOSTR_SUCCESS) ? "PASSED" : "FAILED", crypto_result);
printf("Server-style validation: %s (%d)\n",
(server_result == NOSTR_SUCCESS) ? "PASSED" : "FAILED", server_result);
}
LOG_DIVIDER();
LOG_SUCCESS("🔍 DETAILED COMPARISON COMPLETE");
if (structure_result == NOSTR_SUCCESS && crypto_result == NOSTR_SUCCESS &&
validation_result == NOSTR_SUCCESS && server_result == NOSTR_SUCCESS) {
LOG_SUCCESS("🎯 ALL VALIDATION METHODS AGREE: Event is valid");
} else {
LOG_ERROR("⚠️ VALIDATION METHODS DISAGREE: Check individual results above");
}
LOG_DIVIDER();
cJSON_Delete(event);
nostr_cleanup();
return (structure_result == NOSTR_SUCCESS && crypto_result == NOSTR_SUCCESS) ? 0 : 1;
}

View File

@@ -0,0 +1 @@
test data for hash match