Skip to content

Commit

Permalink
Use ed25519::Public (#2495)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kailai-Wang committed Feb 16, 2024
1 parent 2fd34d3 commit 1c5f281
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions bitacross-worker/enclave-runtime/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use itp_types::{AttestationType, OpaqueCall, WorkerType};
use itp_utils::write_slice_and_whitespace_pad;
use log::*;
use sgx_types::*;
use sp_core::Pair;
use sp_core::{ed25519::Public as Ed25519Public, Pair};
use sp_runtime::OpaqueExtrinsic;
use std::{prelude::v1::*, slice, vec::Vec};

Expand Down Expand Up @@ -569,13 +569,13 @@ fn get_shielding_pubkey() -> EnclaveResult<Option<Vec<u8>>> {
Ok(shielding_pubkey)
}

fn get_vc_pubkey() -> EnclaveResult<Option<Vec<u8>>> {
fn get_vc_pubkey() -> EnclaveResult<Option<Ed25519Public>> {
let vc_pubkey = GLOBAL_SHIELDING_KEY_REPOSITORY_COMPONENT
.get()?
.retrieve_key()
.and_then(|keypair| {
// vc signing pubkey
keypair.derive_ed25519().map(|keypair| keypair.public().to_vec())
keypair.derive_ed25519().map(|keypair| keypair.public())
})
.ok();

Expand Down
4 changes: 2 additions & 2 deletions pallets/teebag/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use frame_support::{
traits::Get,
};
use frame_system::pallet_prelude::*;
use sp_core::H256;
use sp_core::{ed25519::Public as Ed25519Public, H256};
use sp_runtime::traits::{CheckedSub, SaturatedConversion};
use sp_std::{prelude::*, str};

Expand Down Expand Up @@ -417,7 +417,7 @@ pub mod pallet {
attestation: Vec<u8>,
worker_url: Vec<u8>,
shielding_pubkey: Option<Vec<u8>>,
vc_pubkey: Option<Vec<u8>>,
vc_pubkey: Option<Ed25519Public>,
attestation_type: AttestationType,
) -> DispatchResultWithPostInfo {
let sender = ensure_signed(origin)?;
Expand Down
5 changes: 3 additions & 2 deletions pallets/teebag/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

use crate::Ed25519Public;
use codec::{Decode, Encode};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
Expand Down Expand Up @@ -105,7 +106,7 @@ pub struct Enclave {
pub last_seen_timestamp: u64, // unix epoch in milliseconds when it's last seen
pub url: Vec<u8>, // utf8 encoded url
pub shielding_pubkey: Option<Vec<u8>>, // JSON serialised enclave shielding pub key
pub vc_pubkey: Option<Vec<u8>>,
pub vc_pubkey: Option<Ed25519Public>,
pub sgx_build_mode: SgxBuildMode,
pub attestation_type: AttestationType,
}
Expand Down Expand Up @@ -135,7 +136,7 @@ impl Enclave {
self
}

pub fn with_vc_pubkey(mut self, vc_pubkey: Option<Vec<u8>>) -> Self {
pub fn with_vc_pubkey(mut self, vc_pubkey: Option<Ed25519Public>) -> Self {
self.vc_pubkey = vc_pubkey;
self
}
Expand Down
6 changes: 3 additions & 3 deletions tee-worker/enclave-runtime/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use itp_types::{AttestationType, OpaqueCall, WorkerType};
use itp_utils::write_slice_and_whitespace_pad;
use log::*;
use sgx_types::*;
use sp_core::Pair;
use sp_core::{ed25519::Public as Ed25519Public, Pair};
use sp_runtime::OpaqueExtrinsic;
use std::{prelude::v1::*, slice, vec::Vec};

Expand Down Expand Up @@ -572,13 +572,13 @@ fn get_shielding_pubkey() -> EnclaveResult<Option<Vec<u8>>> {
Ok(shielding_pubkey)
}

fn get_vc_pubkey() -> EnclaveResult<Option<Vec<u8>>> {
fn get_vc_pubkey() -> EnclaveResult<Option<Ed25519Public>> {
let vc_pubkey = GLOBAL_SHIELDING_KEY_REPOSITORY_COMPONENT
.get()?
.retrieve_key()
.and_then(|keypair| {
// vc signing pubkey
keypair.derive_ed25519().map(|keypair| keypair.public().to_vec())
keypair.derive_ed25519().map(|keypair| keypair.public())
})
.ok();

Expand Down

0 comments on commit 1c5f281

Please sign in to comment.