summary refs log tree commit diff
path: root/ripple/fossil
diff options
context:
space:
mode:
authoredef <edef@unfathomable.blue>2022-04-19 15:08:23 +0000
committeredef <edef@unfathomable.blue>2022-04-19 15:08:23 +0000
commit4c784b0b1562d7465908fcb671c4f48ce299d272 (patch)
tree32cd784281c1ff1fda1fd31dae44c13dcc49d34d /ripple/fossil
parent6a51ad1041f0a5639fc7b0b6e39a04642d5a3c2e (diff)
downloadunf-legacy-4c784b0b1562d7465908fcb671c4f48ce299d272.tar.zst
ripple/fossil: use bao to one-shot verify hashes
Change-Id: I77ace8ee9f69ccb92afaa0a41d69538d28f11583
Diffstat (limited to 'ripple/fossil')
-rw-r--r--ripple/fossil/Cargo.toml1
-rw-r--r--ripple/fossil/src/lib.rs11
2 files changed, 7 insertions, 5 deletions
diff --git a/ripple/fossil/Cargo.toml b/ripple/fossil/Cargo.toml
index 70554ea..ecfa5b4 100644
--- a/ripple/fossil/Cargo.toml
+++ b/ripple/fossil/Cargo.toml
@@ -17,6 +17,7 @@ log = "0.4.14"
 libc = "0.2.112"
 env_logger = "0.9.0"
 lazy_static = "1.4.0"
+bao = "0.12.0"
 
 [build-dependencies]
 prost-build = "0.8.0"
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 {