@@ -232,7 +232,7 @@ struct ProofPreparer(RefCell<Vec<TlogTile>>);
232232
233233impl TileReader for ProofPreparer {
234234 fn height ( & self ) -> u8 {
235- 8
235+ TlogTile :: HEIGHT
236236 }
237237
238238 fn read_tiles ( & self , tiles : & [ Tile ] ) -> Result < Vec < Vec < u8 > > , TlogError > {
@@ -241,7 +241,7 @@ impl TileReader for ProofPreparer {
241241 * self . 0 . borrow_mut ( ) = tiles
242242 . iter ( )
243243 . map ( |t| {
244- if t. height ( ) != 8 {
244+ if t. height ( ) != TlogTile :: HEIGHT {
245245 Err ( TlogError :: InvalidInput (
246246 "SimpleTlogTileReader cannot read tiles of height not equal to 8"
247247 . to_string ( ) ,
@@ -267,7 +267,7 @@ struct SimpleTlogTileReader(HashMap<TlogTile, Vec<u8>>);
267267
268268impl TileReader for SimpleTlogTileReader {
269269 fn height ( & self ) -> u8 {
270- 8
270+ TlogTile :: HEIGHT
271271 }
272272
273273 /// Converts the given tiles into tlog tiles, then reads them from the
@@ -277,11 +277,11 @@ impl TileReader for SimpleTlogTileReader {
277277 /// Errors if any of given tiles hash height != 8, or is a data tile. Also
278278 /// errors if the hash map is missing tiles from the input here.
279279 fn read_tiles ( & self , tiles : & [ Tile ] ) -> Result < Vec < Vec < u8 > > , TlogError > {
280- let mut buf = Vec :: with_capacity ( 32 * ( 1 << self . height ( ) ) ) ;
280+ let mut buf = Vec :: with_capacity ( HASH_SIZE * TlogTile :: FULL_WIDTH as usize ) ;
281281
282282 for tile in tiles {
283283 // Convert the tile to a tlog-tile, ie one where height=8 and data=false
284- if tile. height ( ) != 8 {
284+ if tile. height ( ) != TlogTile :: HEIGHT {
285285 return Err ( TlogError :: InvalidInput (
286286 "SimpleTlogTileReader cannot read tiles of height not equal to 8" . to_string ( ) ,
287287 ) ) ;
@@ -1454,7 +1454,7 @@ mod tests {
14541454 let last_hash: Hash = {
14551455 // Get the rightmost leaf tile, then extract the last hash from it
14561456 let leaf_edge = & sequence_state. edge_tiles . get ( & 0u8 ) . unwrap ( ) . b ;
1457- Hash ( leaf_edge[ leaf_edge. len ( ) - 32 ..] . try_into ( ) . unwrap ( ) )
1457+ Hash ( leaf_edge[ leaf_edge. len ( ) - HASH_SIZE ..] . try_into ( ) . unwrap ( ) )
14581458 } ;
14591459 check_record ( & inc_proof, tree_size, new_tree_hash, leaf_index, last_hash) . unwrap ( ) ;
14601460
@@ -1482,17 +1482,17 @@ mod tests {
14821482 for i in 0 ..n {
14831483 // Compute the inclusion proof for leaf i
14841484 let proof = block_on ( sequence_state. prove_inclusion ( & log. object , i) ) . unwrap ( ) ;
1485- // Verify the inclusino proof. We need the leaf hash
1485+ // Verify the inclusion proof. We need the leaf hash
14861486 let leaf_hash = {
14871487 // Get the tile the leaf belongs to, and correct the width by getting the 0th parent
14881488 let leaf_tile = TlogTile :: from_leaf_index ( i) . parent ( 0 , n) . unwrap ( ) ;
14891489 let leaf_tile_data = block_on ( log. object . fetch ( & leaf_tile. path ( ) ) )
14901490 . unwrap ( )
14911491 . unwrap ( ) ;
14921492 // Extract the correct hash from the tile
1493- let leaf_tile_idx = i as usize % 256 ;
1493+ let leaf_tile_idx = ( i % TlogTile :: FULL_WIDTH as u64 ) as usize ;
14941494 Hash (
1495- leaf_tile_data[ 32 * leaf_tile_idx..32 * ( leaf_tile_idx + 1 ) ]
1495+ leaf_tile_data[ HASH_SIZE * leaf_tile_idx..HASH_SIZE * ( leaf_tile_idx + 1 ) ]
14961496 . try_into ( )
14971497 . unwrap ( ) ,
14981498 )
0 commit comments