Skip to content
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
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ aws-config = { version = "1.8.14" }
aws-sdk-kms = { version = "1.100" }
diesel = { workspace = true }
diesel_migrations = { workspace = true }
k256 = "0.13.4"
miden-node-db = { workspace = true }
miden-node-proto = { workspace = true }
miden-node-proto-build = { features = ["internal"], workspace = true }
Expand Down
17 changes: 2 additions & 15 deletions crates/validator/src/signers/kms.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
use anyhow::Context;
use aws_sdk_kms::error::SdkError;
use aws_sdk_kms::operation::sign::SignError;
use aws_sdk_kms::types::SigningAlgorithmSpec;
use k256::PublicKey as K256PublicKey;
use k256::elliptic_curve::sec1::ToEncodedPoint;
use k256::pkcs8::DecodePublicKey as _;
use miden_node_utils::signer::BlockSigner;
use miden_protocol::block::BlockHeader;
use miden_protocol::crypto::dsa::ecdsa_k256_keccak::{PublicKey, Signature};
use miden_protocol::crypto::hash::keccak::Keccak256;
use miden_tx::utils::{Deserializable, DeserializationError, Serializable};
use miden_tx::utils::{DeserializationError, Serializable};

// KMS SIGNER ERROR
// ================================================================================================
Expand All @@ -23,9 +19,6 @@ pub enum KmsSignerError {
#[error("KMS request returned an empty result")]
EmptyBlob,
/// The KMS backend returned a signature with an invalid format.
#[error("k256 signature error")]
K256Error(#[source] k256::ecdsa::Error),
/// The KMS backend returned a signature with an invalid format.
#[error("invalid signature format")]
SignatureFormatError(#[source] DeserializationError),
}
Expand Down Expand Up @@ -74,14 +67,8 @@ impl KmsSigner {
let pub_key_output = client.get_public_key().key_id(key_id.clone()).send().await?;
let spki_der = pub_key_output.public_key().ok_or(KmsSignerError::EmptyBlob)?.as_ref();

// Decode the DER-encoded SPKI and compress it.
let kpub = K256PublicKey::from_public_key_der(spki_der)
.context("failed to parse SPKI as secp256k1")?;
let compressed = kpub.to_encoded_point(true); // 33 bytes, 0x02/0x03 || X.
let sec1_compressed = compressed.as_bytes();

// Decode the compressed SPKI as a Miden public key.
let pub_key = PublicKey::read_from_bytes(sec1_compressed)?;
let pub_key = PublicKey::from_der(spki_der)?;
Ok(Self { key_id, pub_key, client })
}
}
Expand Down
Loading