Skip to content

Commit d5077ca

Browse files
committed
Change HpkeError::Secp256k1 into the opaque InvalidPublicKey error
Making this into an opaque error will prevent leaking implementation details
1 parent 27f7813 commit d5077ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

payjoin/src/hpke.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ fn pad_plaintext(msg: &mut Vec<u8>, padded_length: usize) -> Result<&[u8], HpkeE
271271
/// Error from de/encrypting a v2 Hybrid Public Key Encryption payload.
272272
#[derive(Debug, PartialEq)]
273273
pub enum HpkeError {
274-
Secp256k1(secp256k1::Error),
274+
InvalidPublicKey,
275275
Hpke(hpke::HpkeError),
276276
InvalidKeyLength,
277277
PayloadTooLarge { actual: usize, max: usize },
@@ -283,7 +283,7 @@ impl From<hpke::HpkeError> for HpkeError {
283283
}
284284

285285
impl From<secp256k1::Error> for HpkeError {
286-
fn from(value: secp256k1::Error) -> Self { Self::Secp256k1(value) }
286+
fn from(_: secp256k1::Error) -> Self { Self::InvalidPublicKey }
287287
}
288288

289289
impl fmt::Display for HpkeError {
@@ -301,7 +301,7 @@ impl fmt::Display for HpkeError {
301301
)
302302
}
303303
PayloadTooShort => write!(f, "Payload too small"),
304-
Secp256k1(e) => e.fmt(f),
304+
InvalidPublicKey => write!(f, "Invalid public key"),
305305
}
306306
}
307307
}
@@ -314,7 +314,7 @@ impl error::Error for HpkeError {
314314
Hpke(e) => Some(e),
315315
PayloadTooLarge { .. } => None,
316316
InvalidKeyLength | PayloadTooShort => None,
317-
Secp256k1(e) => Some(e),
317+
InvalidPublicKey => None,
318318
}
319319
}
320320
}

0 commit comments

Comments
 (0)