Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pub key as prefix hex #46

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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