Skip to content

Commit cc88b71

Browse files
authored
Rename "root hash" to "fingerprint" (#74)
1 parent 232fad2 commit cc88b71

10 files changed

Lines changed: 34 additions & 34 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ Lofty Ambitions
216216

217217
`filepack` has lofty ambitions!
218218

219-
- Definition of a "root" hash, likely just the hash of the manifest itself, so
220-
that as long as the root hash is received from a trusted source the manifest
221-
itself does not need to be trusted.
219+
- Definition of a "fingerprint" hash, likely just the hash of the manifest
220+
itself, so that as long as the fingerprint is received from a trusted source
221+
the manifest itself does not need to be trusted.
222222

223-
- Creation and verification of signatures over the root hash, so that
223+
- Creation and verification of signatures over the fingerprint, so that
224224
developers and packagers can vouch for the correctness of the contents of a
225225
manifest, and users can verify that a manifest was signed by a trusted public
226226
key.

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ pub(crate) enum Error {
127127
backtrace: Option<Backtrace>,
128128
path: DisplayPath,
129129
},
130-
#[snafu(display("root hash mismatch"))]
131-
RootHashMismatch { backtrace: Option<Backtrace> },
130+
#[snafu(display("fingerprint mismatch"))]
131+
FingerprintMismatch { backtrace: Option<Backtrace> },
132132
#[snafu(display("manifest has already been signed by public key `{public_key}`"))]
133133
SignatureAlreadyExists {
134134
backtrace: Option<Backtrace>,

src/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(crate) struct Manifest {
1212
impl Manifest {
1313
pub(crate) const FILENAME: &'static str = "filepack.json";
1414

15-
pub(crate) fn root_hash(&self) -> Hash {
15+
pub(crate) fn fingerprint(&self) -> Hash {
1616
let canonical = Self {
1717
files: self.files.clone(),
1818
signatures: BTreeMap::new(),

src/page.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ mod tests {
6969
<dd>1</dd>
7070
<dt>total size</dt>
7171
<dd>1 KiB</dd>
72-
<dt>root hash</dt>
72+
<dt>fingerprint</dt>
7373
<dd class=monospace>2e2f6ca534371afe8783a9bcace2237a7611e2e5aa87eb272782b563f70d14ac</dd>
7474
<dt>signatures</dt>
7575
<dd class=monospace>3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29</dd>

src/subcommand/create.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl Create {
180180
let private_key_path = options.key_dir()?.join(MASTER_PRIVATE_KEY);
181181

182182
let (public_key, signature) =
183-
PrivateKey::load_and_sign(&private_key_path, manifest.root_hash().as_bytes())?;
183+
PrivateKey::load_and_sign(&private_key_path, manifest.fingerprint().as_bytes())?;
184184

185185
manifest.signatures.insert(public_key, signature);
186186
}

src/subcommand/sign.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ impl Sign {
2525

2626
let mut manifest = Manifest::load(&path)?;
2727

28-
let root_hash = manifest.root_hash();
28+
let fingerprint = manifest.fingerprint();
2929

3030
for (public_key, signature) in &manifest.signatures {
31-
public_key.verify(root_hash.as_bytes(), signature)?;
31+
public_key.verify(fingerprint.as_bytes(), signature)?;
3232
}
3333

3434
if !self.force {
@@ -43,7 +43,7 @@ impl Sign {
4343
let private_key_path = options.key_dir()?.join(MASTER_PRIVATE_KEY);
4444

4545
let (public_key, signature) =
46-
PrivateKey::load_and_sign(&private_key_path, root_hash.as_bytes())?;
46+
PrivateKey::load_and_sign(&private_key_path, fingerprint.as_bytes())?;
4747

4848
manifest.signatures.insert(public_key, signature);
4949

src/subcommand/verify.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use super::*;
22

33
#[derive(Parser)]
44
pub(crate) struct Verify {
5-
#[arg(help = "Verify manifest root hash is <HASH>", long)]
6-
hash: Option<Hash>,
5+
#[arg(help = "Verify manifest fingerprint is <FINGERPRINT>", long)]
6+
fingerprint: Option<Hash>,
77
#[arg(help = "Ignore missing files", long)]
88
ignore_missing: bool,
99
#[arg(help = "Verify that manifest has been signed by <KEY>", long)]
@@ -45,20 +45,20 @@ impl Verify {
4545
path: Manifest::FILENAME,
4646
})?;
4747

48-
let root_hash = manifest.root_hash();
48+
let fingerprint = manifest.fingerprint();
4949

50-
if let Some(expected) = self.hash {
51-
if root_hash != expected {
50+
if let Some(expected) = self.fingerprint {
51+
if fingerprint != expected {
5252
let style = Style::stderr();
5353
eprintln!(
5454
"\
55-
root hash mismatch: `{source}`
56-
expected: {}
57-
actual: {}",
55+
fingerprint mismatch: `{source}`
56+
expected: {}
57+
actual: {}",
5858
expected.style(style.good()),
59-
root_hash.style(style.bad()),
59+
fingerprint.style(style.bad()),
6060
);
61-
return Err(error::RootHashMismatch.build());
61+
return Err(error::FingerprintMismatch.build());
6262
}
6363
}
6464

@@ -169,7 +169,7 @@ mismatched file: `{path}`
169169
}
170170

171171
for (public_key, signature) in &manifest.signatures {
172-
public_key.verify(root_hash.as_bytes(), signature)?;
172+
public_key.verify(fingerprint.as_bytes(), signature)?;
173173
}
174174

175175
if let Some(key) = self.key {

templates/page.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ <h1>{{ metadata.title }}</h1>
2121
<dd>{{ self.manifest.files.len() }}</dd>
2222
<dt>total size</dt>
2323
<dd>{{ Bytes(self.manifest.total_size()) }}</dd>
24-
<dt>root hash</dt>
25-
<dd class=monospace>{{ self.manifest.root_hash() }}</dd>
24+
<dt>fingerprint</dt>
25+
<dd class=monospace>{{ self.manifest.fingerprint() }}</dd>
2626
<dt>signatures</dt>
2727
%% for key in self.manifest.signatures.keys() {
2828
<dd class=monospace>{{ key }}</dd>

tests/create.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,10 @@ fn sign_creates_valid_signature() {
588588
ed25519_dalek::VerifyingKey::from_bytes(&hex::decode(public_key).unwrap().try_into().unwrap())
589589
.unwrap();
590590

591-
let root_hash = blake3::hash(r#"{"files":{"bar":{"hash":"af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262","size":0}}}"#.as_bytes());
591+
let fingerprint = blake3::hash(r#"{"files":{"bar":{"hash":"af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262","size":0}}}"#.as_bytes());
592592

593593
public_key
594-
.verify_strict(root_hash.as_bytes(), &signature)
594+
.verify_strict(fingerprint.as_bytes(), &signature)
595595
.unwrap();
596596

597597
Command::cargo_bin("filepack")

tests/verify.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ fn signature_verification_success() {
624624
}
625625

626626
#[test]
627-
fn verify_hash() {
627+
fn verify_fingerprint() {
628628
let dir = TempDir::new().unwrap();
629629

630630
dir.child("foo").touch().unwrap();
@@ -640,7 +640,7 @@ fn verify_hash() {
640640
.unwrap()
641641
.args([
642642
"verify",
643-
"--hash",
643+
"--fingerprint",
644644
"74ddbe0dcf48c634aca1d90f37defd60b230fc52857ffa4b6c956583e8a4daaf",
645645
])
646646
.current_dir(&dir)
@@ -651,17 +651,17 @@ fn verify_hash() {
651651
.unwrap()
652652
.args([
653653
"verify",
654-
"--hash",
654+
"--fingerprint",
655655
"0000000000000000000000000000000000000000000000000000000000000000",
656656
])
657657
.current_dir(&dir)
658658
.assert()
659659
.stderr(is_match(
660660
"\
661-
root hash mismatch: `.*filepack\\.json`
662-
expected: 0000000000000000000000000000000000000000000000000000000000000000
663-
actual: 74ddbe0dcf48c634aca1d90f37defd60b230fc52857ffa4b6c956583e8a4daaf
664-
error: root hash mismatch\n",
661+
fingerprint mismatch: `.*filepack\\.json`
662+
expected: 0000000000000000000000000000000000000000000000000000000000000000
663+
actual: 74ddbe0dcf48c634aca1d90f37defd60b230fc52857ffa4b6c956583e8a4daaf
664+
error: fingerprint mismatch\n",
665665
))
666666
.failure();
667667
}

0 commit comments

Comments
 (0)