@@ -141,9 +141,14 @@ impl SchemaPinClient for NativeSchemaPinClient {
141141
142142 // Attempt to extract an embedded signature from the schema JSON.
143143 // Schemas signed by SchemaPin contain a top-level `signature` field.
144- let embedded_signature: Option < String > = serde_json:: from_slice :: < serde_json:: Value > ( & schema_data)
145- . ok ( )
146- . and_then ( |v| v. get ( "signature" ) . and_then ( |s| s. as_str ( ) ) . map ( String :: from) ) ;
144+ let embedded_signature: Option < String > =
145+ serde_json:: from_slice :: < serde_json:: Value > ( & schema_data)
146+ . ok ( )
147+ . and_then ( |v| {
148+ v. get ( "signature" )
149+ . and_then ( |s| s. as_str ( ) )
150+ . map ( String :: from)
151+ } ) ;
147152
148153 if let Some ( ref sig) = embedded_signature {
149154 // Verify the embedded signature against the schema content and fetched public key
@@ -155,14 +160,17 @@ impl SchemaPinClient for NativeSchemaPinClient {
155160 if let Some ( obj) = schema_value. as_object_mut ( ) {
156161 obj. remove ( "signature" ) ;
157162 }
158- let canonical_payload = serde_json :: to_vec ( & schema_value )
159- . map_err ( |e| SchemaPinError :: IoError {
163+ let canonical_payload =
164+ serde_json :: to_vec ( & schema_value ) . map_err ( |e| SchemaPinError :: IoError {
160165 reason : format ! ( "Failed to serialize canonical schema: {}" , e) ,
161166 } ) ?;
162167
163168 match verify_signature ( & public_key_pem, & canonical_payload, sig) {
164169 Ok ( true ) => {
165- tracing:: info!( "Schema signature verified successfully for {}" , args. schema_path) ;
170+ tracing:: info!(
171+ "Schema signature verified successfully for {}" ,
172+ args. schema_path
173+ ) ;
166174 Ok ( VerificationResult {
167175 success : true ,
168176 message : "Schema signature verified successfully using native Rust implementation" . to_string ( ) ,
@@ -179,10 +187,14 @@ impl SchemaPinClient for NativeSchemaPinClient {
179187 } )
180188 }
181189 Ok ( false ) => {
182- tracing:: warn!( "Schema signature verification failed: signature invalid for {}" , args. schema_path) ;
190+ tracing:: warn!(
191+ "Schema signature verification failed: signature invalid for {}" ,
192+ args. schema_path
193+ ) ;
183194 Ok ( VerificationResult {
184195 success : false ,
185- message : "Schema signature verification failed: signature is invalid" . to_string ( ) ,
196+ message : "Schema signature verification failed: signature is invalid"
197+ . to_string ( ) ,
186198 schema_hash : Some ( schema_hash) ,
187199 public_key_url : Some ( args. public_key_url . clone ( ) ) ,
188200 signature : Some ( SignatureInfo {
@@ -196,7 +208,11 @@ impl SchemaPinClient for NativeSchemaPinClient {
196208 } )
197209 }
198210 Err ( e) => {
199- tracing:: warn!( "Schema signature verification error for {}: {}" , args. schema_path, e) ;
211+ tracing:: warn!(
212+ "Schema signature verification error for {}: {}" ,
213+ args. schema_path,
214+ e
215+ ) ;
200216 Ok ( VerificationResult {
201217 success : false ,
202218 message : format ! ( "Schema signature verification error: {}" , e) ,
0 commit comments