remove: Remove is_valid_signature util

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb 2024-07-23 22:21:56 +03:00
parent 470fd6c015
commit 672b84710e
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F
2 changed files with 4 additions and 16 deletions

View file

@ -71,11 +71,10 @@ pub async fn signature_check(
};
if !utils::is_valid_nonce(&signature, &depot.nonce_cache()).await
|| !utils::is_valid_signature(
&sender_public_key,
&depot.config().server.private_key,
&signature,
|| !depot.config().server.private_key.verify(
data.as_bytes(),
&signature,
&sender_public_key,
)
{
write_err("Invalid signature", UNAUTHORIZED);

View file

@ -22,8 +22,7 @@ use chrono::Utc;
use logcall::logcall;
use oxidetalis_config::Postgres;
use oxidetalis_core::{
cipher::K256Secret,
types::{PrivateKey, PublicKey, Signature},
types::{PublicKey, Signature},
PUBLIC_KEY_HEADER,
SIGNATURE_HEADER,
};
@ -50,16 +49,6 @@ pub(crate) async fn is_valid_nonce(signature: &Signature, nonce_cache: &NonceCac
new_timestamp && unused_nonce
}
/// Returns true if the given signature is valid.
pub(crate) fn is_valid_signature(
signer: &PublicKey,
private_key: &PrivateKey,
signature: &Signature,
data: &[u8],
) -> bool {
K256Secret::from_privkey(private_key).verify(data, signature, signer)
}
/// Extract the sender public key from the request
///
/// Returns the public key of the sender extracted from the request, or the