Skip to content
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

Direct invocation demo code #1676

Merged
merged 25 commits into from
May 11, 2023
Merged

Direct invocation demo code #1676

merged 25 commits into from
May 11, 2023

Conversation

Kailai-Wang
Copy link
Collaborator

@Kailai-Wang Kailai-Wang commented May 10, 2023

This PR has addressed most of #1658

It shows how to construct a direct trusted call and send it, currently supported trusted call:

  • set_user_shielding_key_direct
  • create_identity_direct

It also demonstrates the public query to e.g. retrieve TEE's shielding key.

It includes a basic RPC response handling as well.
The subscription to parachain header and the subsequent handling are not written as we have the code already I believe.

Please bear with my crude ts code.

See ts-tests/examples/direct-invocation/README.md for more information.

cc @jonalvarezz

@Kailai-Wang Kailai-Wang requested a review from a team May 10, 2023 23:31
@Kailai-Wang Kailai-Wang self-assigned this May 10, 2023
@Kailai-Wang Kailai-Wang linked an issue May 10, 2023 that may be closed by this pull request
4 tasks
Copy link
Contributor

@jonalvarezz jonalvarezz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the examples, If that's all what it takes, it doesn't look complex 🙌

const keyring = new Keyring({ type: 'sr25519' });

const PARACHAIN_WS_ENDPINT = 'ws://localhost:9944';
const WORKER_TRUSTED_WS_ENDPOINT = 'wss://localhost:2000';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood correctly from Nitesh some time ago, this endpoint is not publicly available for security reasons. Is it still the case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1010
We don't see security issues - only server load (similar to any other rpc service provider)

...call.toU8a(),
...nonce.toU8a(),
...hexToU8a(mrenclave),
...hexToU8a(mrenclave), // should be shard, but it's the same as MRENCLAVE in our case
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"in our case" here means our Parachain regardless of the network, right? How likely it is to change in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's network unrelated.

How likely it is to change in the future?

Highly improbable, even if it's going to change, that's not in near future

top: Uint8Array
) => {
let cyphertext = compactAddLength(bufferToU8a(encryptWithTeeShieldingKey(teeShieldingKey, top)));
return parachain_api.createType('Request', { shard: hexToU8a(mrenclave), cyphertext }).toU8a();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kailai-Wang, cyphertext -> ciphertext – Is it a typo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - In rust the struct field is cyphertext and it's from upstream - so we didn't change it.

And according to Bing, cipher and cypher should be alternative forms:
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDHub uses ciphertext 😭😭😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide direct invocation e2e sample code
4 participants