refactor(crypto): replace byte-slice signing contexts with SigningContext enum

This commit is contained in:
CleverWild
2026-08-26 13:06:59 +02:00
committed by Skipper
parent f881102f0a
commit a501283b0c
12 changed files with 121 additions and 52 deletions

View File

@@ -336,7 +336,7 @@ impl ProposalManager {
approve: bool,
signature: Vec<u8>,
) -> Result<VoteOutcome, Error> {
use arbiter_crypto::authn::{self, GOVERNANCE_CONTEXT};
use arbiter_crypto::authn::{self, SigningContext};
let mut conn = self.db.get().await?;
@@ -391,7 +391,7 @@ impl ProposalManager {
let auth_sig = authn::Signature::try_from(signature.as_slice())
.map_err(|()| Error::InvalidSignature)?;
if !pubkey.verify_message(&vote_msg, GOVERNANCE_CONTEXT, &auth_sig) {
if !pubkey.verify_message(&vote_msg, SigningContext::GovernanceVote, &auth_sig) {
return Err(Error::InvalidSignature);
}
@@ -537,7 +537,7 @@ impl ProposalManager {
approve: bool,
signature: Vec<u8>,
) -> Result<VoteOutcome, Error> {
use arbiter_crypto::authn::{self, GOVERNANCE_CONTEXT};
use arbiter_crypto::authn::{self, SigningContext};
let mut conn = self.db.get().await?;
@@ -596,7 +596,7 @@ impl ProposalManager {
let auth_sig = authn::Signature::try_from(signature.as_slice())
.map_err(|()| Error::InvalidSignature)?;
if !pubkey.verify_message(&vote_msg, GOVERNANCE_CONTEXT, &auth_sig) {
if !pubkey.verify_message(&vote_msg, SigningContext::GovernanceVote, &auth_sig) {
return Err(Error::InvalidSignature);
}

View File

@@ -12,7 +12,7 @@ use crate::{
schema::program_client,
},
};
use arbiter_crypto::authn::{self, AuthChallenge, CLIENT_CONTEXT};
use arbiter_crypto::authn::{self, AuthChallenge, SigningContext};
use arbiter_proto::{
ClientMetadata,
transport::{Bi, expect_message},
@@ -306,7 +306,7 @@ where
Error::Transport
})?;
if !pubkey.verify(&challenge, CLIENT_CONTEXT, &signature) {
if !pubkey.verify(&challenge, SigningContext::Client, &signature) {
error!("Challenge solution verification failed");
return Err(Error::InvalidChallengeSolution);
}

View File

@@ -7,7 +7,7 @@ use crate::{
db::{DatabasePool, schema::operator_identity},
peers::operator::auth::Outbound,
};
use arbiter_crypto::authn::{self, AuthChallenge, OPERATOR_CONTEXT};
use arbiter_crypto::authn::{self, AuthChallenge, SigningContext};
use arbiter_proto::transport::Bi;
use diesel::{ExpressionMethods as _, OptionalExtension as _, QueryDsl};
@@ -141,7 +141,7 @@ where
Error::InvalidChallengeSolution
})?;
let valid = pubkey.verify(challenge, OPERATOR_CONTEXT, &signature);
let valid = pubkey.verify(challenge, SigningContext::Operator, &signature);
if !valid {
self.transport