You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@teaclave.apache.org by GitBox <gi...@apache.org> on 2021/01/25 20:11:57 UTC

[GitHub] [incubator-teaclave] Mengyuan-L opened a new pull request #468: Rust sdk example

Mengyuan-L opened a new pull request #468:
URL: https://github.com/apache/incubator-teaclave/pull/468


   ## Description
   
   Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
   Rust SDK's example. 
   
   Fixes # (issue)
   
   ## Type of change (select or add applied and delete the others)
   
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
   - [ ] API change with a documentation update
   - [x] Additional test coverage
   - [ ] Code cleanup or just sync with upstream third-party crates
   
   ## How has this been tested?
   
   ## Checklist
   
   - [x] Fork the repo and create your branch from `master`.
   - [x] If you've added code that should be tested, add tests.
   - [x] If you've changed APIs, update the documentation.
   - [x] Ensure the tests pass (see CI results).
   - [x] Make sure your code lints/format.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org


[GitHub] [incubator-teaclave] mssun commented on a change in pull request #468: Rust sdk example

Posted by GitBox <gi...@apache.org>.
mssun commented on a change in pull request #468:
URL: https://github.com/apache/incubator-teaclave/pull/468#discussion_r573981433



##########
File path: examples/rust/builtin_echo/Cargo.toml
##########
@@ -0,0 +1,12 @@
+[package]
+name = "builtin_echo"
+version = "0.1.0"
+authors = ["Teaclave Contributors <de...@teaclave.apache.org>"]
+description = "Teaclave rust sdk builtin_echo example"

Review comment:
       => `builtin_echo function example using Teaclave Rust client SDK.`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org


[GitHub] [incubator-teaclave] mssun commented on a change in pull request #468: Rust sdk example

Posted by GitBox <gi...@apache.org>.
mssun commented on a change in pull request #468:
URL: https://github.com/apache/incubator-teaclave/pull/468#discussion_r565692897



##########
File path: examples/rust/builtin_echo/src/main.rs
##########
@@ -0,0 +1,102 @@
+use anyhow::Result;

Review comment:
       Put license header on the top for all `.rs` files:
   ```
   // Licensed to the Apache Software Foundation (ASF) under one
   // or more contributor license agreements.  See the NOTICE file
   // distributed with this work for additional information
   // regarding copyright ownership.  The ASF licenses this file
   // to you under the Apache License, Version 2.0 (the
   // "License"); you may not use this file except in compliance
   // with the License.  You may obtain a copy of the License at
   //
   //   http://www.apache.org/licenses/LICENSE-2.0
   //
   // Unless required by applicable law or agreed to in writing,
   // software distributed under the License is distributed on an
   // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   // KIND, either express or implied.  See the License for the
   // specific language governing permissions and limitations
   // under the License.
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org


[GitHub] [incubator-teaclave] mssun commented on a change in pull request #468: Rust sdk example

Posted by GitBox <gi...@apache.org>.
mssun commented on a change in pull request #468:
URL: https://github.com/apache/incubator-teaclave/pull/468#discussion_r566323509



##########
File path: examples/rust/builtin_ordered_set_intersect/src/main.rs
##########
@@ -0,0 +1,230 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use anyhow::Result;
+use std::fs;
+use teaclave_client_sdk;
+
+#[macro_export]
+macro_rules! hashmap {
+    ($( $key: expr => $value: expr, )+) => { hashmap!($($key => $value),+) };
+    ($( $key: expr => $value: expr ),*) => {{
+        let mut map = ::std::collections::HashMap::new();
+        $( map.insert($key.into(), $value.into()); )*
+        map
+    }}
+}
+
+const ENCLAVE_INFO_PATH: &str = "../../../release/services/enclave_info.toml";
+#[cfg(dcap)]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/dcap_root_ca_cert.pem";
+#[cfg(not(dcap))]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/ias_root_ca_cert.pem";
+
+struct UserData {
+    user_id: String,
+    user_password: String,
+    input_url: String,
+    input_label: &'static str,

Review comment:
       Why not use an owned `String`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org


[GitHub] [incubator-teaclave] mssun commented on pull request #468: Rust sdk example

Posted by GitBox <gi...@apache.org>.
mssun commented on pull request #468:
URL: https://github.com/apache/incubator-teaclave/pull/468#issuecomment-777058011


   Can you rebase to the latest master and resolve the conflicts? Thanks.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org


[GitHub] [incubator-teaclave] mssun commented on a change in pull request #468: Rust sdk example

Posted by GitBox <gi...@apache.org>.
mssun commented on a change in pull request #468:
URL: https://github.com/apache/incubator-teaclave/pull/468#discussion_r573981679



##########
File path: examples/rust/builtin_ordered_set_intersect/Cargo.toml
##########
@@ -0,0 +1,12 @@
+[package]
+name = "builtin_ordered_set_intersect"
+version = "0.1.0"
+authors = ["Teaclave Contributors <de...@teaclave.apache.org>"]
+description = "Teaclave rust sdk builtin_ordered_set_intersect example"

Review comment:
       builtin_ordered_set_intersect function example using Teaclave Rust client SDK.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org


[GitHub] [incubator-teaclave] mssun merged pull request #468: Rust sdk example

Posted by GitBox <gi...@apache.org>.
mssun merged pull request #468:
URL: https://github.com/apache/incubator-teaclave/pull/468


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org


[GitHub] [incubator-teaclave] mssun commented on a change in pull request #468: Rust sdk example

Posted by GitBox <gi...@apache.org>.
mssun commented on a change in pull request #468:
URL: https://github.com/apache/incubator-teaclave/pull/468#discussion_r573981679



##########
File path: examples/rust/builtin_ordered_set_intersect/Cargo.toml
##########
@@ -0,0 +1,12 @@
+[package]
+name = "builtin_ordered_set_intersect"
+version = "0.1.0"
+authors = ["Teaclave Contributors <de...@teaclave.apache.org>"]
+description = "Teaclave rust sdk builtin_ordered_set_intersect example"

Review comment:
       builtin_ordered_set_intersect function example using Teaclave client SDK.

##########
File path: examples/rust/builtin_echo/Cargo.toml
##########
@@ -0,0 +1,12 @@
+[package]
+name = "builtin_echo"
+version = "0.1.0"
+authors = ["Teaclave Contributors <de...@teaclave.apache.org>"]
+description = "Teaclave rust sdk builtin_echo example"

Review comment:
       => `builtin_echo function example using Teaclave client SDK.`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org


[GitHub] [incubator-teaclave] mssun commented on a change in pull request #468: Rust sdk example

Posted by GitBox <gi...@apache.org>.
mssun commented on a change in pull request #468:
URL: https://github.com/apache/incubator-teaclave/pull/468#discussion_r565789851



##########
File path: examples/rust/builtin_ordered_set_intersect/src/main.rs
##########
@@ -0,0 +1,230 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use anyhow::Result;
+use std::fs;
+use teaclave_client_sdk;
+
+#[macro_export]
+macro_rules! hashmap {
+    ($( $key: expr => $value: expr, )+) => { hashmap!($($key => $value),+) };
+    ($( $key: expr => $value: expr ),*) => {{
+        let mut map = ::std::collections::HashMap::new();
+        $( map.insert($key.into(), $value.into()); )*
+        map
+    }}
+}
+
+const ENCLAVE_INFO_PATH: &str = "../../../release/services/enclave_info.toml";
+#[cfg(dcap)]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/dcap_root_ca_cert.pem";
+#[cfg(not(dcap))]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/ias_root_ca_cert.pem";
+
+struct UserData {
+    user_id: String,
+    user_password: String,
+    input_url: String,
+    input_label: &'static str,
+    output_url: String,
+    output_label: &'static str,
+    input_cmac: Vec<u8>,
+    key: Vec<u8>,
+    peer_id: String,
+    peer_input_label: &'static str,
+    peer_output_label: &'static str,
+}
+
+struct Client {
+    client: teaclave_client_sdk::FrontendClient,
+    user_data: UserData,
+}
+
+impl Client {
+    fn new(user_data: UserData) -> Result<Client> {
+        let enclave_info = teaclave_client_sdk::EnclaveInfo::from_file(ENCLAVE_INFO_PATH)?;
+        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
+        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
+        let mut client = teaclave_client_sdk::AuthenticationService::connect(
+            "localhost:7776",
+            &enclave_info,
+            &as_root_ca_cert,
+        )?;
+
+        println!("[+] {} registering user", user_data.user_id);
+        client.user_register(&user_data.user_id, &user_data.user_password)?;
+
+        println!("[+] {} login", user_data.user_id);
+        client.user_login(&user_data.user_id, &user_data.user_password)?;
+
+        let token = client.user_login(&user_data.user_id, &user_data.user_password)?;
+
+        let mut client = teaclave_client_sdk::FrontendService::connect(
+            "localhost:7777",
+            &enclave_info,
+            &as_root_ca_cert,
+        )?;
+        client.set_credential(&user_data.user_id, &token);
+
+        Ok(Client { client, user_data })
+    }
+
+    fn set_task(&mut self) -> Result<String> {
+        println!("[+] {} registering function", self.user_data.user_id);
+        let function_id = self.client.register_function(
+            "builtin-ordered-set-intersect",
+            "Native Private Set Intersection.",
+            "builtin",
+            None,
+            Some(&["order"]),
+            Some(vec![
+                teaclave_client_sdk::FunctionInput::new("input_data1", "Client 0 data."),
+                teaclave_client_sdk::FunctionInput::new("input_data2", "Client 1 data."),
+            ]),
+            Some(vec![
+                teaclave_client_sdk::FunctionOutput::new("output_result1", "Output data."),
+                teaclave_client_sdk::FunctionOutput::new("output_result2", "Output data."),
+            ]),
+        )?;
+        self.client.get_function(&function_id)?;
+        let function_arguments = hashmap!("order" => "ascending"); // Order can be ascending or desending
+        let inputs_ownership = hashmap!(self.user_data.input_label => vec![self.user_data.user_id.to_string()], self.user_data.peer_input_label => vec![self.user_data.peer_id.to_string()]);
+        let outputs_ownership = hashmap!(self.user_data.output_label => vec![self.user_data.user_id.to_string()], self.user_data.peer_output_label => vec![self.user_data.peer_id.to_string()]);
+
+        println!("[+] {} creating task", self.user_data.user_id);
+        let task_id = self.client.create_task(
+            &function_id,
+            Some(function_arguments),
+            "builtin",
+            Some(inputs_ownership),
+            Some(outputs_ownership),
+        )?;
+        Ok(task_id.to_string())
+    }
+
+    fn register_data(&mut self, task_id: &str) -> Result<()> {
+        println!(
+            "[+] {} registering input file {}",
+            self.user_data.user_id, self.user_data.input_url
+        );
+        let data_id = self.client.register_input_file(
+            &self.user_data.input_url,
+            &self.user_data.input_cmac,
+            teaclave_client_sdk::FileCrypto::new(
+                "teaclave-file-128",
+                &self.user_data.key,
+                &Vec::new(),
+            )
+            .unwrap(),
+        )?;
+        let inputs = hashmap!(self.user_data.input_label => data_id);
+
+        println!(
+            "[+] {} registering output file {}",
+            self.user_data.user_id, self.user_data.output_url
+        );
+        let data_id = self.client.register_output_file(
+            &self.user_data.output_url,
+            teaclave_client_sdk::FileCrypto::new(
+                "teaclave-file-128",
+                &self.user_data.key,
+                &Vec::new(),
+            )
+            .unwrap(),
+        )?;
+
+        let outputs = hashmap!(self.user_data.output_label => data_id);
+
+        println!("[+] {} assigning data to task", self.user_data.user_id);
+        self.client
+            .assign_data(&task_id, Some(inputs), Some(outputs))
+            .unwrap();
+        Ok(())
+    }
+
+    fn run_task(&mut self, task_id: &str) -> Result<()> {
+        println!("[+] {} invoking task", self.user_data.user_id);
+        self.client.invoke_task(&task_id)?;
+        Ok(())
+    }
+
+    fn approve_task(&mut self, task_id: &str) -> Result<()> {
+        println!("[+] {} approving task", self.user_data.user_id);
+        self.client.approve_task(&task_id)?;
+        Ok(())
+    }
+
+    fn get_task_result(&mut self, task_id: &str) -> Result<Vec<u8>> {
+        println!("[+] {} getting result", self.user_data.user_id);
+        let response = self.client.get_task_result(&task_id)?;
+        Ok(response)
+    }
+}
+
+fn main() -> Result<()> {
+    let user0_data = UserData {
+        user_id: "user0".to_string(),   //to_string.

Review comment:
       Remove the comment.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org


[GitHub] [incubator-teaclave] mssun commented on a change in pull request #468: Rust sdk example

Posted by GitBox <gi...@apache.org>.
mssun commented on a change in pull request #468:
URL: https://github.com/apache/incubator-teaclave/pull/468#discussion_r565693894



##########
File path: examples/rust/builtin_ordered_set_intersect/src/main.rs
##########
@@ -0,0 +1,219 @@
+use anyhow::Result;
+use std::fs;
+use teaclave_client_sdk;
+
+#[macro_export]
+macro_rules! hashmap {
+    ($( $key: expr => $value: expr, )+) => { hashmap!($($key => $value),+) };
+    ($( $key: expr => $value: expr ),*) => {{
+        let mut map = ::std::collections::HashMap::new();
+        $( map.insert($key.into(), $value.into()); )*
+        map
+    }}
+}
+
+const ENCLAVE_INFO_PATH: &str = "../../../release/services/enclave_info.toml";
+#[cfg(dcap)]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/dcap_root_ca_cert.pem";
+#[cfg(not(dcap))]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/ias_root_ca_cert.pem";
+
+struct UserData {
+    user_id: String,
+    user_password: String,
+    input_url: String,
+    input_label: &'static str,
+    output_url: String,
+    output_label: &'static str,
+    input_cmac: Vec<u8>,
+    key: Vec<u8>,
+    peer_id: String,
+    peer_input_label: &'static str,
+    peer_output_label: &'static str,
+}
+
+struct Client {
+    client: teaclave_client_sdk::FrontendClient,
+    user_data: UserData,
+}
+
+impl Client {
+    fn new(user_data: UserData) -> Client {
+        let enclave_info = teaclave_client_sdk::EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
+        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
+        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
+        let mut client = teaclave_client_sdk::AuthenticationService::connect(
+            "localhost:7776",
+            &enclave_info,
+            &as_root_ca_cert,
+        )
+        .unwrap();
+
+        println!("[+] {} registering user", user_data.user_id);
+        let _ = client.user_register(&user_data.user_id, &user_data.user_password);
+
+        println!("[+] {} login", user_data.user_id);
+        client
+            .user_login(&user_data.user_id, &user_data.user_password)
+            .unwrap();

Review comment:
       Don't `unwrap` the result. Handle it properly.

##########
File path: examples/rust/builtin_ordered_set_intersect/src/main.rs
##########
@@ -0,0 +1,219 @@
+use anyhow::Result;
+use std::fs;
+use teaclave_client_sdk;
+
+#[macro_export]
+macro_rules! hashmap {
+    ($( $key: expr => $value: expr, )+) => { hashmap!($($key => $value),+) };
+    ($( $key: expr => $value: expr ),*) => {{
+        let mut map = ::std::collections::HashMap::new();
+        $( map.insert($key.into(), $value.into()); )*
+        map
+    }}
+}
+
+const ENCLAVE_INFO_PATH: &str = "../../../release/services/enclave_info.toml";
+#[cfg(dcap)]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/dcap_root_ca_cert.pem";
+#[cfg(not(dcap))]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/ias_root_ca_cert.pem";
+
+struct UserData {
+    user_id: String,
+    user_password: String,
+    input_url: String,
+    input_label: &'static str,
+    output_url: String,
+    output_label: &'static str,
+    input_cmac: Vec<u8>,
+    key: Vec<u8>,
+    peer_id: String,
+    peer_input_label: &'static str,
+    peer_output_label: &'static str,
+}
+
+struct Client {
+    client: teaclave_client_sdk::FrontendClient,
+    user_data: UserData,
+}
+
+impl Client {
+    fn new(user_data: UserData) -> Client {
+        let enclave_info = teaclave_client_sdk::EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
+        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
+        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
+        let mut client = teaclave_client_sdk::AuthenticationService::connect(
+            "localhost:7776",
+            &enclave_info,
+            &as_root_ca_cert,
+        )
+        .unwrap();

Review comment:
       Don't `unwrap` the result. Handle it properly.

##########
File path: examples/rust/builtin_ordered_set_intersect/src/main.rs
##########
@@ -0,0 +1,219 @@
+use anyhow::Result;
+use std::fs;
+use teaclave_client_sdk;
+
+#[macro_export]
+macro_rules! hashmap {
+    ($( $key: expr => $value: expr, )+) => { hashmap!($($key => $value),+) };
+    ($( $key: expr => $value: expr ),*) => {{
+        let mut map = ::std::collections::HashMap::new();
+        $( map.insert($key.into(), $value.into()); )*
+        map
+    }}
+}
+
+const ENCLAVE_INFO_PATH: &str = "../../../release/services/enclave_info.toml";
+#[cfg(dcap)]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/dcap_root_ca_cert.pem";
+#[cfg(not(dcap))]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/ias_root_ca_cert.pem";
+
+struct UserData {
+    user_id: String,
+    user_password: String,
+    input_url: String,
+    input_label: &'static str,
+    output_url: String,
+    output_label: &'static str,
+    input_cmac: Vec<u8>,
+    key: Vec<u8>,
+    peer_id: String,
+    peer_input_label: &'static str,
+    peer_output_label: &'static str,
+}
+
+struct Client {
+    client: teaclave_client_sdk::FrontendClient,
+    user_data: UserData,
+}
+
+impl Client {
+    fn new(user_data: UserData) -> Client {
+        let enclave_info = teaclave_client_sdk::EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
+        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
+        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
+        let mut client = teaclave_client_sdk::AuthenticationService::connect(
+            "localhost:7776",
+            &enclave_info,
+            &as_root_ca_cert,
+        )
+        .unwrap();
+
+        println!("[+] {} registering user", user_data.user_id);
+        let _ = client.user_register(&user_data.user_id, &user_data.user_password);
+
+        println!("[+] {} login", user_data.user_id);
+        client
+            .user_login(&user_data.user_id, &user_data.user_password)
+            .unwrap();
+
+        let token = client
+            .user_login(&user_data.user_id, &user_data.user_password)
+            .unwrap();

Review comment:
       Don't `unwrap` the result. Handle it properly.

##########
File path: examples/rust/builtin_ordered_set_intersect/src/main.rs
##########
@@ -0,0 +1,219 @@
+use anyhow::Result;
+use std::fs;
+use teaclave_client_sdk;
+
+#[macro_export]
+macro_rules! hashmap {
+    ($( $key: expr => $value: expr, )+) => { hashmap!($($key => $value),+) };
+    ($( $key: expr => $value: expr ),*) => {{
+        let mut map = ::std::collections::HashMap::new();
+        $( map.insert($key.into(), $value.into()); )*
+        map
+    }}
+}
+
+const ENCLAVE_INFO_PATH: &str = "../../../release/services/enclave_info.toml";
+#[cfg(dcap)]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/dcap_root_ca_cert.pem";
+#[cfg(not(dcap))]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/ias_root_ca_cert.pem";
+
+struct UserData {
+    user_id: String,
+    user_password: String,
+    input_url: String,
+    input_label: &'static str,
+    output_url: String,
+    output_label: &'static str,
+    input_cmac: Vec<u8>,
+    key: Vec<u8>,
+    peer_id: String,
+    peer_input_label: &'static str,
+    peer_output_label: &'static str,
+}
+
+struct Client {
+    client: teaclave_client_sdk::FrontendClient,
+    user_data: UserData,
+}
+
+impl Client {
+    fn new(user_data: UserData) -> Client {
+        let enclave_info = teaclave_client_sdk::EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
+        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
+        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
+        let mut client = teaclave_client_sdk::AuthenticationService::connect(
+            "localhost:7776",
+            &enclave_info,
+            &as_root_ca_cert,
+        )
+        .unwrap();
+
+        println!("[+] {} registering user", user_data.user_id);
+        let _ = client.user_register(&user_data.user_id, &user_data.user_password);
+
+        println!("[+] {} login", user_data.user_id);
+        client
+            .user_login(&user_data.user_id, &user_data.user_password)
+            .unwrap();
+
+        let token = client
+            .user_login(&user_data.user_id, &user_data.user_password)
+            .unwrap();
+
+        let mut client = teaclave_client_sdk::FrontendService::connect(
+            "localhost:7777",
+            &enclave_info,
+            &as_root_ca_cert,
+        )
+        .unwrap();

Review comment:
       Don't `unwrap` the result. Handle it properly.

##########
File path: examples/rust/builtin_ordered_set_intersect/src/main.rs
##########
@@ -0,0 +1,219 @@
+use anyhow::Result;
+use std::fs;
+use teaclave_client_sdk;
+
+#[macro_export]
+macro_rules! hashmap {
+    ($( $key: expr => $value: expr, )+) => { hashmap!($($key => $value),+) };
+    ($( $key: expr => $value: expr ),*) => {{
+        let mut map = ::std::collections::HashMap::new();
+        $( map.insert($key.into(), $value.into()); )*
+        map
+    }}
+}
+
+const ENCLAVE_INFO_PATH: &str = "../../../release/services/enclave_info.toml";
+#[cfg(dcap)]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/dcap_root_ca_cert.pem";
+#[cfg(not(dcap))]
+const AS_ROOT_CA_CERT_PATH: &str = "../../../keys/ias_root_ca_cert.pem";
+
+struct UserData {
+    user_id: String,
+    user_password: String,
+    input_url: String,
+    input_label: &'static str,
+    output_url: String,
+    output_label: &'static str,
+    input_cmac: Vec<u8>,
+    key: Vec<u8>,
+    peer_id: String,
+    peer_input_label: &'static str,
+    peer_output_label: &'static str,
+}
+
+struct Client {
+    client: teaclave_client_sdk::FrontendClient,
+    user_data: UserData,
+}
+
+impl Client {
+    fn new(user_data: UserData) -> Client {
+        let enclave_info = teaclave_client_sdk::EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
+        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
+        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
+        let mut client = teaclave_client_sdk::AuthenticationService::connect(
+            "localhost:7776",
+            &enclave_info,
+            &as_root_ca_cert,
+        )
+        .unwrap();
+
+        println!("[+] {} registering user", user_data.user_id);
+        let _ = client.user_register(&user_data.user_id, &user_data.user_password);
+
+        println!("[+] {} login", user_data.user_id);
+        client
+            .user_login(&user_data.user_id, &user_data.user_password)
+            .unwrap();
+
+        let token = client
+            .user_login(&user_data.user_id, &user_data.user_password)
+            .unwrap();
+
+        let mut client = teaclave_client_sdk::FrontendService::connect(
+            "localhost:7777",
+            &enclave_info,
+            &as_root_ca_cert,
+        )
+        .unwrap();

Review comment:
       Same for others.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org