Skip to content

Commit

Permalink
fix registerEnclaveKey's report type
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Jun 16, 2024
1 parent 2c441cc commit 96ca5ca
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules/attestation-report/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub struct EndorsedAttestationVerificationReport {

impl EndorsedAttestationVerificationReport {
pub fn get_avr(&self) -> Result<AttestationVerificationReport, Error> {
serde_json::from_slice(self.avr.as_bytes()).map_err(Error::serde_json)
serde_json::from_slice(self.avr.as_ref()).map_err(Error::serde_json)
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/attestation-report/src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn verify_report(
report_cert
.verify_signature(
&webpki::RSA_PKCS1_2048_8192_SHA256,
report.avr.as_bytes(),
report.avr.as_ref(),
&report.signature,
)
.map_err(|e| Error::web_pki(e.to_string()))?;
Expand Down
12 changes: 11 additions & 1 deletion modules/lcp-client/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ define_error! {

IbcProto
[TraceError<light_client::types::proto::protobuf::Error>]
|_| { "IBCProto error" }
|_| { "IBCProto error" },

StringFromUtf8Error
[TraceError<alloc::string::FromUtf8Error>]
|_| { "FromUtf8 error" },
}
}

Expand Down Expand Up @@ -91,3 +95,9 @@ impl From<light_client::commitments::Error> for Error {
Self::commitment_proof(value)
}
}

impl From<alloc::string::FromUtf8Error> for Error {
fn from(value: alloc::string::FromUtf8Error) -> Self {
Self::string_from_utf8_error(value)
}
}
4 changes: 2 additions & 2 deletions modules/lcp-client/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl TryFrom<RawRegisterEnclaveKeyMessage> for RegisterEnclaveKeyMessage {
fn try_from(value: RawRegisterEnclaveKeyMessage) -> Result<Self, Self::Error> {
Ok(RegisterEnclaveKeyMessage {
report: EndorsedAttestationVerificationReport {
avr: value.report,
avr: String::from_utf8(value.report)?,
signature: value.signature,
signing_cert: value.signing_cert,
},
Expand All @@ -80,7 +80,7 @@ impl TryFrom<RawRegisterEnclaveKeyMessage> for RegisterEnclaveKeyMessage {
impl From<RegisterEnclaveKeyMessage> for RawRegisterEnclaveKeyMessage {
fn from(value: RegisterEnclaveKeyMessage) -> Self {
RawRegisterEnclaveKeyMessage {
report: (&value.report.avr).try_into().unwrap(),
report: value.report.avr.into_bytes(),
signature: value.report.signature,
signing_cert: value.report.signing_cert,
operator_signature: value.operator_signature.unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion proto/definitions/ibc/lightclients/lcp/v1/lcp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ message UpdateClientMessage {
}

message RegisterEnclaveKeyMessage {
string report = 1;
bytes report = 1;
bytes signature = 2;
bytes signing_cert = 3;
bytes operator_signature = 4;
Expand Down
Binary file modified proto/src/descriptor.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions proto/src/prost/ibc.lightclients.lcp.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub struct UpdateClientMessage {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegisterEnclaveKeyMessage {
#[prost(string, tag = "1")]
pub report: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "1")]
pub report: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub signature: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
Expand Down

0 comments on commit 96ca5ca

Please sign in to comment.