@@ -17,6 +17,9 @@ const MINA_PUBLIC_KEY_LENGTH: usize = 44;
17
17
// List of valid error report categories
18
18
const VALID_CATEGORIES : [ & str ; 1 ] = [ "blockProofFailure" ] ;
19
19
20
+ // Context string for signature verification
21
+ // const SIGNATURE_CONTEXT: &[u8] = b"OpenminaErrorReport";
22
+
20
23
#[ derive( Clone ) ]
21
24
struct ServerConfig {
22
25
port : u16 ,
@@ -34,6 +37,24 @@ struct ErrorReport {
34
37
signature : String , // Base64 encoded cryptographic signature
35
38
}
36
39
40
+ fn verify_signature (
41
+ public_key_bs58 : & str ,
42
+ _message : & [ u8 ] ,
43
+ signature_b64 : & str ,
44
+ ) -> Result < bool , String > {
45
+ if let Err ( e) = bs58:: decode ( public_key_bs58) . into_vec ( ) {
46
+ return Err ( format ! ( "Invalid public key encoding: {}" , e) ) ;
47
+ }
48
+
49
+ if let Err ( e) = BASE64 . decode ( signature_b64) {
50
+ return Err ( format ! ( "Invalid signature encoding: {}" , e) ) ;
51
+ }
52
+
53
+ // Stub implementation - always return true
54
+ // TODO: Replace with actual signature verification
55
+ Ok ( true )
56
+ }
57
+
37
58
/// Handles POST requests to the /error-report endpoint
38
59
async fn handle_error_report (
39
60
payload : web:: Json < ErrorReport > ,
@@ -80,18 +101,30 @@ async fn handle_error_report(
80
101
} ) ?;
81
102
82
103
if data. verify_signatures {
83
- let _sig_bytes = match BASE64 . decode ( & payload. signature ) {
84
- Ok ( bytes) => bytes,
104
+ // Verify the signature using the submitter's public key and the data
105
+ match verify_signature ( & payload. submitter , & data_bytes, & payload. signature ) {
106
+ Ok ( true ) => {
107
+ info ! (
108
+ "Signature verification successful for submitter: {}" ,
109
+ payload. submitter
110
+ ) ;
111
+ }
112
+ Ok ( false ) => {
113
+ error ! (
114
+ "Signature verification failed for submitter: {}" ,
115
+ payload. submitter
116
+ ) ;
117
+ return Err ( actix_web:: error:: ErrorBadRequest (
118
+ "Invalid signature: verification failed" ,
119
+ ) ) ;
120
+ }
85
121
Err ( e) => {
86
- warn ! ( "Invalid signature format : {}" , e) ;
122
+ error ! ( "Signature verification error : {}" , e) ;
87
123
return Err ( actix_web:: error:: ErrorBadRequest (
88
- "Invalid signature format " ,
124
+ "Signature verification error " ,
89
125
) ) ;
90
126
}
91
- } ;
92
-
93
- // TODO: verify signature here
94
- info ! ( "Signature verification would occur here (not implemented yet)" ) ;
127
+ }
95
128
}
96
129
97
130
let mut file = File :: create ( & file_name) . map_err ( |e| {
0 commit comments