-
Notifications
You must be signed in to change notification settings - Fork 152
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
pruntime: Implement dcap key handover #1524
Conversation
crates/phactory/src/nts.rs
Outdated
} | ||
|
||
fn validate_results(results: Vec<u64>) -> Result<u64> { | ||
if results.len() < 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make these thresholds as constants so we can easily notice and update them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
crates/phactory/src/nts.rs
Outdated
.map(|r| (*r as i64 - average as i64).unsigned_abs()) | ||
.max() | ||
.unwrap_or_default(); | ||
if max_diff > 60 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
crates/phactory/src/prpc_service.rs
Outdated
// 4. verify challenge block height and report timestamp | ||
// only challenge within 150 blocks (30 minutes) is accepted | ||
let challenge_height = challenge.block_number; | ||
if !(challenge_height <= block_number && block_number - challenge_height <= 150) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems superceded by the challenge.ntp_time_secs
check above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this one.
.map_err(|_| from_display("Invalid client sgx target info"))? | ||
}; | ||
// the report data does not matter since we only care about the origin | ||
let report = sgx_api_lite::report(its_target_info, &report_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean an IAS pRuntime can also get key from DCAP pRuntime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, IAS pruntime validates RA to each other during handover, while dcap pruntime server won't generate RA report. So, an IAS pruntime won't accept an handover from DCAP pruntime.
Double check @kvinwang : is NTP Authentication enabled in phala-nts? |
I would also like to highlight some constants for future reference:
|
Regarding to the NTP servers, there are 5 servers are in north Europe, and 2 are in Brazil. Are they too close? |
Yes, it's enabled. |
@shelvenzhou do you think this is a problem? |
d78e80f
to
dc1c040
Compare
Can we make this configurable with on-chain governance? |
Good idea. |
Added on-chain governance. |
55a5ea2
to
44d64c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR implements the key handover feature according to the design from @shelvenzhou.
the RTP time is got from at least two of the white listed servers as show below:
A few points to note:
dev_mode
is not fully supported in this version (Won't success in dev_mode). (Maybe added in the future).