From 4c784b0b1562d7465908fcb671c4f48ce299d272 Mon Sep 17 00:00:00 2001 From: edef Date: Tue, 19 Apr 2022 15:08:23 +0000 Subject: ripple/fossil: use bao to one-shot verify hashes Change-Id: I77ace8ee9f69ccb92afaa0a41d69538d28f11583 --- ripple/fossil/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'ripple/fossil/src') diff --git a/ripple/fossil/src/lib.rs b/ripple/fossil/src/lib.rs index 3492789..9e380f2 100644 --- a/ripple/fossil/src/lib.rs +++ b/ripple/fossil/src/lib.rs @@ -7,7 +7,7 @@ use { std::{ collections::BTreeMap, fs, - io::{self, BufRead, Read}, + io::{self, BufRead, Read, Write}, os::unix::fs::PermissionsExt, path::Path, }, @@ -107,10 +107,11 @@ impl Store { let mut buffer = Vec::new(); self.raw_blob(ident).read_to_end(&mut buffer).unwrap(); - let computed_ident = { - let mut h = blake3::Hasher::new(); - h.update_rayon(&buffer); - h.finalize() + let mut outboard = Vec::new(); + let computed_ident: blake3::Hash = { + let mut encoder = bao::encode::Encoder::new_outboard(io::Cursor::new(&mut outboard)); + encoder.write_all(&buffer).unwrap(); + encoder.finalize().unwrap() }; if computed_ident != ident { -- cgit 1.4.1