---
# System prepended metadata

title: Secure Transaction Signing with Mobile App and Secure Element
tags: [mtls]

---

## Secure Transaction Signing with Mobile App and Secure Element

> 
> 
> This document outlines the technical specifications for a secure transaction signing process within a mobile banking application. The process utilizes a Secure Element (SE) to store the user's private key and leverages digital signatures for transaction authorization.

## 1. Actors and Participants

- **User:** Initiates financial transactions.
- **Mobile App:** Provides the user interface for transaction initiation and review.
- **Flutter SDK:** Software development kit used by the mobile app for secure communication, data signing, and interaction with the Secure Element.
- **Backend:** Banking system responsible for processing transactions and interacting with the Certificate Service (CS).
- **Certificate Service (CS):** Manages user keys stored securely, encrypts/decrypts transaction data, and validates digital signatures.

## 2. Functionality

### Transaction Initiation:

1. The user initiates a financial transaction within the mobile app.
2. The mobile app gathers transaction details and sends them to the backend system.

### Public Key Retrieval:

1. Upon receiving transaction data, the backend forwards it to the CS.
2. The CS retrieves the user's public key associated with the private key stored securely within the SE on the user's mobile device.

### Data Encryption and Nonce Addition:

1. The CS adds a unique nonce value to the transaction data for replay protection.
2. The CS encrypts the transaction data (including the nonce) using the user's public key.

### Encrypted Data to App:

1. The CS sends the encrypted transaction data back to the mobile app through the Flutter SDK.

### Data Decryption and User Review:

1. The mobile app (via SDK) securely accesses the Secure Element.
2. The SDK decrypts the transaction data using the user's private key stored within the SE.
3. The decrypted transaction details are presented to the user for review.

### User Confirmation:

1. The user reviews the transaction details and confirms it if everything is correct.

### Data Signing:

1. Upon user confirmation, the SDK signs the decrypted transaction data using the user's private key within the SE.

### Signed Data to Backend:

1. The signed transaction data is sent back to the backend system through the Flutter SDK.

### Signature Validation:

1. The backend forwards the signed data to the CS.
2. The CS validates the signature using the user's public key extracted from the signature certificate (obtained during login) stored in the database.
3. The CS also verifies the signature against the original transaction data and the nonce value to prevent replay attacks.

### Transaction Processing:

1. If the signature is valid, the CS informs the backend of a successful transaction.
2. The backend processes the financial transaction and logs it with a timestamp.

## 3. Security Considerations

- The Secure Element (SE) provides a secure environment for storing the user's private key, isolated from the main app environment.
- Transaction data is encrypted using the user's public key for secure transmission between the backend and mobile app.
- Digital signatures are generated using the user's private key to ensure data integrity and prevent tampering during transaction authorization.
- Signature verification using the user's public key ensures the user's authorization for the transaction.
- Nonce usage helps prevent replay attacks by introducing a unique value for each transaction.

## 4. Technical Requirements

- The mobile app development should utilize the Flutter SDK for secure communication, data handling, and interaction with the Secure Element.
- The backend system should implement secure protocols for communication with the mobile app and the CS.
- The mobile app environment should leverage a Secure Element to store the user's private key securely.
- The CS should securely store user keys and implement cryptographic functionalities for data encryption, decryption, and signature validation.

## 5. Open Issues/Next Steps

- Specify the format and content of the transaction data sent between the mobile app and backend.
- Define the error handling procedures for various stages of the transaction signing process.
- Determine the certificate lifecycle management process (renewal, revocation).

## 6. Sequence Diagram

![transacrion](https://hackmd.io/_uploads/SyAug8Vaa.png)
