-
Notifications
You must be signed in to change notification settings - Fork 46
manage proxied vault account per shard #1467
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
Changes from 25 commits
ecdf920
347e187
81e94dd
6ddd043
156aac3
f1d3d77
9911098
ead3662
b20d978
4524b9f
6587f1b
d5ce0c7
cd3562d
36bdc5c
b5da3a2
ed26be7
da6bea0
b72c063
4d2c000
9bc2e60
757c07a
2b7ed16
bb69ebd
42fac49
f5acb2d
6e03fff
2109bd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # sidechain startup internal view | ||
| ```mermaid | ||
| sequenceDiagram | ||
| participant integritee_network | ||
| participant service | ||
| participant slotworker | ||
| participant parentsync | ||
| participant enclave | ||
| participant enclave_rpc | ||
| participant provisioningserver | ||
| participant isinitializedserver | ||
| participant metrics | ||
| service ->> enclave: EnclaveBase.get_mrenclave | ||
| service ->> provisioningserver: spawn (`--mu-ra-port` | 3443) | ||
| activate provisioningserver | ||
| service ->> enclave: get_ecc_signing_pubkey | ||
| service ->> isinitializedserver: spawn (`--untrusted-http-port | 4545) | ||
| activate isinitializedserver | ||
| service ->> metrics: spawn (`--metrics-port`| 8787) | ||
| activate metrics | ||
| service ->> enclave_rpc: spawn (`--trusted-worker-port`| 2000) | ||
| activate enclave_rpc | ||
|
|
||
| service ->> enclave: generate_dcap_ra_extrinsic | ||
| service ->> integritee_network: send register_sgx_enclave extrinsic | ||
| service ->> integritee_network: get ShardStatus | ||
| service ->> isinitializedserver: registered_on_parentchain | ||
| # schedule teeracle re-registration and updates | ||
| loop while blocks to sync | ||
| service ->> integritee_network: get_block | ||
| service ->> enclave: sync_parentchain(blocks, events, proofs) | ||
| end | ||
| service ->> enclave: init_enclave_sidechain_components | ||
| service ->> slotworker: spawn | ||
| loop forever | ||
| slotworker ->> enclave: execute_trusted_calls | ||
| activate enclave | ||
| enclave ->> enclave: propose_sidechain_block | ||
| enclave ->> integritee_network: send_extrinsics | ||
| deactivate enclave | ||
| end | ||
| service ->> parentsync: spawn | ||
| loop forever | ||
| parentsync ->> integritee_network: subscribe new headers | ||
| parentsync ->> enclave: sync_parentchain | ||
| end | ||
| service ->> service: poll worker_for_shard | ||
| service ->> isinitializedserver: worker_for_shard_registered | ||
|
|
||
| deactivate enclave_rpc | ||
| deactivate metrics | ||
| deactivate isinitializedserver | ||
| deactivate provisioningserver | ||
| ``` | ||
|
|
||
| # sidechain lifetime external view | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| participant integritee_network | ||
| participant validateer_1 | ||
| participant validateer_2 | ||
| actor alice | ||
|
|
||
| validateer_1 ->> integritee_network: register_sgx_enclave() | ||
|
|
||
| validateer_2 ->> integritee_network: register_sgx_enclave() | ||
|
|
||
| validateer_2 ->> validateer_1: sidechain_fetchBlocksFromPeer() | ||
|
|
||
| validateer_1 ->> validateer_2: sidechain_importBlock() | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,6 +234,31 @@ pub fn percent_decode(orig: String) -> EnclaveResult<String> { | |
| Ok(ret) | ||
| } | ||
|
|
||
| pub fn parse_cert_issuer(cert_der: &[u8]) -> SgxResult<Vec<u8>> { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is currently not used. I wrote it because I tried to derive the MU RA client from the TLS certificate. fell back to passing it as a payload instead. Still, I think this fn might be useful on its own. webpki and rustls hide the issuer all too well behind private fields |
||
| // Before we reach here, Webpki already verified the cert is properly signed | ||
|
|
||
| // Search for Public Key prime256v1 OID | ||
| let prime256v1_oid = &[0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07]; | ||
| let mut offset = cert_der | ||
| .windows(prime256v1_oid.len()) | ||
| .position(|window| window == prime256v1_oid) | ||
| .ok_or(sgx_status_t::SGX_ERROR_UNEXPECTED)?; | ||
| offset += 11; // 10 + TAG (0x03) | ||
|
|
||
| // Obtain Public Key length | ||
| let mut len = cert_der[offset] as usize; | ||
| if len > 0x80 { | ||
| len = (cert_der[offset + 1] as usize) * 0x100 + (cert_der[offset + 2] as usize); | ||
| offset += 2; | ||
| } | ||
|
|
||
| // Obtain Public Key | ||
| offset += 1; | ||
| let pub_k = cert_der[offset + 2..offset + len].to_vec(); // skip "00 04" | ||
|
|
||
| Ok(pub_k) | ||
| } | ||
|
|
||
| // FIXME: This code is redundant with the host call of the integritee-node | ||
| pub fn verify_mra_cert<A>( | ||
| cert_der: &[u8], | ||
|
|
@@ -346,6 +371,7 @@ where | |
| verify_attn_report(attn_report_raw, pub_k, attestation_ocall) | ||
| } else { | ||
| // TODO Refactor state provisioning to not use MURA #1385 | ||
| // TODO DCAP is currently just passed through! SECURITY!!! | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't aware that our MU RA is insecure for DCAP. Increases the urgency for #1385 |
||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,6 +88,15 @@ where | |
| ) -> Self { | ||
| ExtrinsicsFactory { genesis_hash, signer, nonce_cache, node_metadata_repository } | ||
| } | ||
|
|
||
| pub fn with_signer(&self, signer: Signer, nonce_cache: Arc<NonceCache>) -> Self { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this allows the enclave to send extrinsics using arbitrary signers (closes #1466) |
||
| ExtrinsicsFactory { | ||
| genesis_hash: self.genesis_hash, | ||
| signer, | ||
| nonce_cache, | ||
| node_metadata_repository: self.node_metadata_repository.clone(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<Signer, NonceCache, NodeMetadataRepository> CreateExtrinsics | ||
|
|
@@ -170,6 +179,33 @@ pub mod tests { | |
| assert_eq!(nonce_cache.get_nonce().unwrap(), Nonce(opaque_calls.len() as NonceValue)); | ||
| } | ||
|
|
||
| #[test] | ||
| pub fn with_signer_works() { | ||
| let nonce_cache1 = Arc::new(NonceCache::default()); | ||
| *nonce_cache1.load_for_mutation().unwrap() = Nonce(42); | ||
|
|
||
| let node_metadata_repo = Arc::new(NodeMetadataRepository::new(NodeMetadata::default())); | ||
| let extrinsics_factory = ExtrinsicsFactory::new( | ||
| test_genesis_hash(), | ||
| StaticExtrinsicSigner::<_, PairSignature>::new(test_account()), | ||
| nonce_cache1.clone(), | ||
| node_metadata_repo, | ||
| ); | ||
|
|
||
| let nonce_cache2 = Arc::new(NonceCache::default()); | ||
| let extrinsics_factory = extrinsics_factory.with_signer( | ||
| StaticExtrinsicSigner::<_, PairSignature>::new(test_account2()), | ||
| nonce_cache2.clone(), | ||
| ); | ||
|
|
||
| let opaque_calls = [OpaqueCall(vec![3u8; 42]), OpaqueCall(vec![12u8, 78])]; | ||
| let xts = extrinsics_factory.create_extrinsics(&opaque_calls, None).unwrap(); | ||
|
|
||
| assert_eq!(opaque_calls.len(), xts.len()); | ||
| assert_eq!(nonce_cache2.get_nonce().unwrap(), Nonce(opaque_calls.len() as NonceValue)); | ||
| assert_eq!(nonce_cache1.get_nonce().unwrap(), Nonce(42)); | ||
| } | ||
|
|
||
| // #[test] | ||
| // pub fn xts_have_increasing_nonce() { | ||
| // let nonce_cache = Arc::new(NonceCache::default()); | ||
|
|
@@ -194,6 +230,10 @@ pub mod tests { | |
| ed25519::Pair::from_seed(b"42315678901234567890123456789012") | ||
| } | ||
|
|
||
| fn test_account2() -> ed25519::Pair { | ||
| ed25519::Pair::from_seed(b"12315678901234567890123456789012") | ||
| } | ||
|
|
||
| fn test_genesis_hash() -> H256 { | ||
| H256::from_slice(&[56u8; 32]) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.