Skip to content

Commit

Permalink
pub key as prefix hex (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
chudkowsky authored Sep 9, 2024
1 parent 62752e6 commit b2c64c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion prover-sdk/src/sdk_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ProverSDKBuilder {
}
pub async fn get_nonce(&self, public_key: &VerifyingKey) -> Result<String, SdkErrors> {
let nonce_req = GenerateNonceRequest {
public_key: serde_json::to_string(&public_key)?,
public_key: prefix_hex::encode(public_key.to_bytes()),
};
let response = self
.client
Expand Down
5 changes: 4 additions & 1 deletion prover/src/auth/nonce.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::authorizer::AuthorizationProvider;
use crate::auth::auth_errors::AuthorizerError;
use crate::server::AppState;
use crate::{auth::auth_errors::AuthError, errors::ProverError};
use axum::{
Expand Down Expand Up @@ -60,7 +61,9 @@ pub async fn generate_nonce(
State(state): State<AppState>,
Query(params): Query<GenerateNonceRequest>,
) -> Result<Json<GenerateNonceResponse>, ProverError> {
let key: VerifyingKey = serde_json::from_str(&params.public_key)?;
let verifying_key_bytes = prefix_hex::decode::<Vec<u8>>(params.public_key)
.map_err(|e| AuthorizerError::PrefixHexConversionError(e.to_string()))?;
let key = VerifyingKey::from_bytes(&verifying_key_bytes.try_into()?)?;
if !state.authorizer.is_authorized(key).await? {
return Err(ProverError::Auth(AuthError::Unauthorized));
}
Expand Down

0 comments on commit b2c64c8

Please sign in to comment.