Skip to content

Commit a25802f

Browse files
committed
Merge pull-request #593
2 parents 90dec56 + dd9a046 commit a25802f

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/qos_p256/src/lib.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,21 @@ impl P256Pair {
220220
path: P,
221221
) -> Result<(), P256Error> {
222222
let hex_string = qos_hex::encode(&self.master_seed);
223-
std::fs::write(path, hex_string.as_bytes()).map_err(|e| {
224-
P256Error::IOError(format!("failed to write master secret {e}"))
223+
std::fs::write(&path, hex_string.as_bytes()).map_err(|e| {
224+
P256Error::IOError(format!(
225+
"failed to write master secret to {}: {e}",
226+
path.as_ref().display()
227+
))
225228
})
226229
}
227230

228231
/// Read the raw, hex encoded master from a file.
229232
pub fn from_hex_file<P: AsRef<Path>>(path: P) -> Result<Self, P256Error> {
230-
let hex_bytes = std::fs::read(path).map_err(|e| {
231-
P256Error::IOError(format!("failed to read master seed: {e}"))
233+
let hex_bytes = std::fs::read(&path).map_err(|e| {
234+
P256Error::IOError(format!(
235+
"failed to read master seed from {}: {e}",
236+
path.as_ref().display()
237+
))
232238
})?;
233239

234240
let master_seed =
@@ -318,15 +324,21 @@ impl P256Public {
318324
path: P,
319325
) -> Result<(), P256Error> {
320326
let hex_string = qos_hex::encode(&self.to_bytes());
321-
std::fs::write(path, hex_string.as_bytes()).map_err(|e| {
322-
P256Error::IOError(format!("failed to write master secret: {e}"))
327+
std::fs::write(&path, hex_string.as_bytes()).map_err(|e| {
328+
P256Error::IOError(format!(
329+
"failed to write public key bytes to {}: {e}",
330+
path.as_ref().display()
331+
))
323332
})
324333
}
325334

326335
/// Read the hex encoded public keys from a file.
327336
pub fn from_hex_file<P: AsRef<Path>>(path: P) -> Result<Self, P256Error> {
328-
let hex_bytes = std::fs::read(path).map_err(|e| {
329-
P256Error::IOError(format!("failed to read master seed: {e}"))
337+
let hex_bytes = std::fs::read(&path).map_err(|e| {
338+
P256Error::IOError(format!(
339+
"failed to read public key bytes from {}: {e}",
340+
path.as_ref().display()
341+
))
330342
})?;
331343

332344
let public_keys_bytes =

0 commit comments

Comments
 (0)