DemesneGH commented on code in PR #192:
URL: 
https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/192#discussion_r2104612286


##########
projects/web3/eth_wallet/ta/src/main.rs:
##########
@@ -18,37 +18,53 @@
 #![no_main]
 
 mod hash;
-mod secure_storage;
 mod wallet;
 
-use crate::secure_storage::{
-    delete_from_secure_storage, load_from_secure_storage, 
save_in_secure_storage,
-};
 use optee_utee::{
     ta_close_session, ta_create, ta_destroy, ta_invoke_command, 
ta_open_session, trace_println,
 };
 use optee_utee::{Error, ErrorKind, Parameters};
 use proto::Command;
+use secure_db::SecureStorageClient;
 
 use anyhow::{anyhow, bail, Result};
-use std::convert::TryInto;
 use std::io::Write;
 use wallet::Wallet;
 
+const DB_NAME: &str = "eth_wallet_db";
+
+// Define session context structure
+pub struct WalletSession {
+    db_client: SecureStorageClient,
+}
+
+impl Default for WalletSession {
+    fn default() -> Self {
+        Self {
+            db_client: SecureStorageClient::open(DB_NAME)
+                .expect("Failed to create SecureStorageClient"),
+        }
+    }
+}
+
 #[ta_create]
 fn create() -> optee_utee::Result<()> {
     trace_println!("[+] TA create");
     Ok(())
 }
 
 #[ta_open_session]
-fn open_session(_params: &mut Parameters) -> optee_utee::Result<()> {
+fn open_session(_params: &mut Parameters, _sess_ctx: &mut WalletSession) -> 
optee_utee::Result<()> {

Review Comment:
   Given that the pattern also exists in other examples: 
https://github.com/apache/incubator-teaclave-trustzone-sdk/blob/main/examples/acipher-rs/ta/src/main.rs#L32-L54,
 also in `hotp-rs` `aes-rs` `digest-rs` and so on, I think it's reasonable to 
use the same pattern here for now, we can open another PR to revise the session 
context handling then update all related examples.
   If it's not acceptable, I'm okay to rollback the `eth_wallet` example to the 
version doesn't use the secure_db crate.
   
   @m4sterchain Which approach would you prefer?



-- 
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.

To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org
For additional commands, e-mail: dev-h...@teaclave.apache.org

Reply via email to