Please note that, due to changes on the Sandbox integration process for Setu Account Aggregator, this document is now outdated. Please refer to the updated quickstart to proceed.
#End-to-end encryption
According to ReBIT spec, the FI data flow between the FIU and the FIP should be end-to-end encrypted. The FIU and the FIP should generate key pairs that are not permanent and are generated for every data fetch request that happens between them.
Account Aggregators are data-blind, which means that only encrypted data passes through them. The AA will not be able to decrypt the data at any point.
#Key generation and exchange
The FIU and the FIP should generate Curve25519 ephemeral key pairs comprising of public and private keys. Curve25519 is taken as default curve as per the ReBit spec.
The Elliptic Curve Diffie-Hellman (ECDH) key-exchange protocol is an anonymous key-agreement scheme. It is used by the FIU and the FIP to generate a shared secret key, using the ephemeral key pairs for encryption and decrytpion. Learn more about ECDH.
#KeyMaterial object
KeyMaterial is an object which contains information about the public key, encryption algorithm and nonce, as in the sample provided below.
{"cryptoAlg" : "ECDH","curve" : "Curve25519","params" : "AES/GCM/NoPadding","DHPublicKey" : {"expiry" : "<PUBLIC_KEY_EXPIRY_DATE>","Parameters" : "","KeyValue" : "<PUBLIC_KEY_VALUE>"},"Nonce" : "<256_BIT_NONCE>"}
#Encryption and decryption
Below steps are derived from the official security library of Sahamati, called Rahasya. We have deployed the official library with minor updates on Setu servers for making testing easier. You can find it here
Below is a list of steps that happen in a data flow session—
Encryption at FIP
- The FIU generates a ephemeral key pair,
fiu_public_key&fiu_private_keyand a 256-bit base64 encoded nonce,fiu_nonce. The FIU sends this information asKeyMaterialto the FIP in the data request for that session. - The FIP generates a ephemeral key pair,
fip_public_key&fip_private_keyand a 256-bit base64 encoded nonce,fip_nonce. - Using ECDH, the FIP generates a shared secret key,
fip_shared_secretby usingfip_private_keyandfiu_public_key. - The FIP generates a
shared_nonceby XOR offiu_nonceandfip_nonce - The FIP generates a
session_keyby HKDF (HMAC based Key Derivation function) using thefip_shared_secretandshared_nonce. Learn more about HKDF. - The FIP uses AES-GCM encryption algorithm with
session_keyused as the encryption key to encrypt the FI data requested by the FIU. According to spec and the library, AES-GCM is the default encryption algorithm. Learn more about AES.
Decryption at FIU
- Once the data is encrypted, the FIP sends the encrypted data along with
fip_public_keyandfip_nonceasKeyMaterial. - Using ECDH, the FIU generates a shared secret key,
fiu_shared_secretby usingfiu_private_keyandfip_public_key. - Note that both the shared secret keys,
fiu_shared_secretandfip_shared_secretwill be the same. - The FIU generates a
shared_nonceby XOR offiu_nonceandfip_nonce - The FIU generates a
session_keyby HKDF (HMAC based Key Derivation function) using thefiu_shared_secretandshared_nonce. - The FIU uses the same AES-GCM encryption algorithm with
session_keyused as the decryption key to decrypt the FI data sent by FIP.
#Rahasya helper library
To facilitate easier testing of our sandbox, Setu has deployed the official Sahamati library, Rahasya on our infra. This will help FIU to easily generate ephemeral keys and decrypting the FI data in sandbox.
You can deploy the Setu's fork of Rahasya library on your own servers for custom usage of the library and its implementation.
Get the the Postman collection for key generation and decrypting data—the Rahasya helper library here.
