@@ -2,7 +2,7 @@ use super::*;
22
33#[ derive( Parser ) ]
44pub ( crate ) struct Verify {
5- #[ arg( help = "Verify that BLAKE3 hash of manifest manifest is <HASH>" , long) ]
5+ #[ arg( help = "Verify manifest root hash is <HASH>" , long) ]
66 hash : Option < Hash > ,
77 #[ arg( help = "Ignore missing files" , long) ]
88 ignore_missing : bool ,
@@ -46,26 +46,27 @@ impl Verify {
4646 result => result. context ( error:: Io { path : & source } ) ?,
4747 } ;
4848
49+ let manifest = serde_json:: from_str :: < Manifest > ( & json) . context ( error:: DeserializeManifest {
50+ path : Manifest :: FILENAME ,
51+ } ) ?;
52+
53+ let root_hash = manifest. root_hash ( ) ;
54+
4955 if let Some ( expected) = self . hash {
50- let actual = Hash :: bytes ( json. as_bytes ( ) ) ;
51- if actual != expected {
56+ if root_hash != expected {
5257 let style = Style :: stderr ( ) ;
5358 eprintln ! (
5459 "\
55- manifest hash mismatch: `{source}`
56- expected: {}
57- actual: {}" ,
60+ root hash mismatch: `{source}`
61+ expected: {}
62+ actual: {}" ,
5863 expected. style( style. good( ) ) ,
59- actual . style( style. bad( ) ) ,
64+ root_hash . style( style. bad( ) ) ,
6065 ) ;
61- return Err ( error:: ManifestHashMismatch . build ( ) ) ;
66+ return Err ( error:: RootHashMismatch . build ( ) ) ;
6267 }
6368 }
6469
65- let manifest = serde_json:: from_str :: < Manifest > ( & json) . context ( error:: DeserializeManifest {
66- path : Manifest :: FILENAME ,
67- } ) ?;
68-
6970 let bar = progress_bar:: new ( manifest. files . values ( ) . map ( |entry| entry. size ) . sum ( ) ) ;
7071
7172 let mut mismatches = BTreeMap :: new ( ) ;
@@ -180,7 +181,7 @@ mismatched file: `{path}`
180181 . context ( error:: SignatureMalformed { path } ) ?;
181182
182183 pubkey
183- . verify ( json . as_bytes ( ) , & signature)
184+ . verify ( root_hash . as_bytes ( ) , & signature)
184185 . context ( error:: SignatureInvalid { path } ) ?;
185186
186187 signatures. insert ( pubkey) ;
0 commit comments