Skip to content

Commit

Permalink
feat: add end point param in tee register interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ytqaljn committed Nov 8, 2023
1 parent a257bab commit 0ae78c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions c-pallets/tee-worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ pub mod pallet {
pub fn register(
origin: OriginFor<T>,
stash_account: AccountOf<T>,
node_key: NodePublicKey,
peer_id: PeerId,
podr2_pbk: Podr2Key,
sgx_attestation_report: SgxAttestationReport,
end_point: EndPoint,
) -> DispatchResult {
let sender = ensure_signed(origin)?;
//Even if the primary key is not present here, panic will not be caused
Expand All @@ -159,6 +159,7 @@ pub mod pallet {
let mut identity = Vec::new();
identity.append(&mut peer_id.to_vec());
identity.append(&mut podr2_pbk.to_vec());
identity.append(&mut end_point.to_vec());
let identity_hashing = sp_io::hashing::sha2_256(&identity);
let _ = verify_miner_cert(
&sgx_attestation_report.sign,
Expand All @@ -170,8 +171,8 @@ pub mod pallet {
let tee_worker_info = TeeWorkerInfo::<T> {
controller_account: sender.clone(),
peer_id: peer_id.clone(),
node_key,
stash_account: stash_account,
end_point,
};

if TeeWorkerMap::<T>::count() == 0 {
Expand Down Expand Up @@ -251,16 +252,16 @@ pub mod pallet {
origin: OriginFor<T>,
stash_account: AccountOf<T>,
controller_account: AccountOf<T>,
node_key: NodePublicKey,
peer_id: PeerId,
end_point: EndPoint,
) -> DispatchResult {
let _ = ensure_root(origin)?;

let tee_worker_info = TeeWorkerInfo::<T> {
controller_account: controller_account.clone(),
peer_id: peer_id.clone(),
node_key,
stash_account: stash_account,
end_point,
};

TeeWorkerMap::<T>::insert(&controller_account, tee_worker_info);
Expand Down
2 changes: 1 addition & 1 deletion c-pallets/tee-worker/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use super::*;
pub struct TeeWorkerInfo<T: pallet::Config> {
pub controller_account: AccountOf<T>,
pub peer_id: PeerId,
pub node_key: NodePublicKey,
pub stash_account: AccountOf<T>,
pub end_point: EndPoint,
}

#[derive(PartialEq, Eq, Encode, Decode, Clone, RuntimeDebug, Default, MaxEncodedLen, TypeInfo)]
Expand Down
1 change: 1 addition & 0 deletions primitives/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub type Mrenclave = [u8; 32];
pub type PeerId = [u8; 38];
pub type Podr2Key = [u8; 270];
pub type TeeRsaSignature = [u8; 256];
pub type EndPoint = BoundedVec<u8, ConstU32<100>>;

pub const M_BYTE: u128 = 1_048_576;
pub const G_BYTE: u128 = 1_048_576 * 1024;
Expand Down

0 comments on commit 0ae78c1

Please sign in to comment.