# Encrypted User Information

POST: /server/encrypteduser?yourAppAddress

This endpoint returns a user's name, date of birth and three letter country code.

For this endpoint, information is encrypted in transit. This works as follows:

  1. Your server-side code generates an RSA key pair
  2. You provide the user address to be queried (which can be obtained from the 'addr' claim in a user's JWT), and the modulus and exponent of the public key that was generated by your code
  3. You sign the request as specified in Authorization
  4. The response will contain an AES key, encrypted using the RSA components supplied in your request, an AES IV, and user data, encrypted using the AES key
  5. Use the private key from the RSA key pair that was previously generated in order to decrpyt the AES key
  6. Use the decrypted AES key to decrypt the user data

# Sample Request

POST https://localhost:5010/api/server/encrypteduser?casinoAddress=0x2D447Da24D7174e142D6708ca350CF43f12a5570 HTTP/1.1
Host: localhost:5010
X-App-Signature: 0xd31c8806f916f2179e9f2c838dd02280c1bae42808b113cc3ce56c10aa978777799090d309ef93b567be104c0e1798c6300e6f752a39271d09c86b68e00750c21c.2020-06-03T09:38:29Z // signature goes here
Accept-Encoding: gzip, deflate
Content-Type: application/json; charset=utf-8
Content-Length: 377
{"userAddress":"0x19D491B3e5CdB5af04b4A9ADB1d521784CAB433f","rsaPublicKeyModulus":"0xbcb5bfa7a4a58689151ed9ea9a17655f32c0ed560d6f0231976b3adf08d36375d9aa7cbbd11f067ee500ba62a12544c97d49883c3579de697406918eae2d7c91e1a0599e305d2374a4ed9313ad75d483e70234ca52926d227aec7d6986a335992ca2ed596adb6e11738d73bf68e2c6148ff5028f2330964d25b3cdda0fccdb1d","rsaPublicKeyExponent":"0x010001"}

The userAddress field should be populated with the Ethereum account address for the user you wish to retrieve information for. This can be retrieved from the 'addr' claim in the JWT used by the user.

# Sample Response

{
  "aesKey": "0x3e7f20d5414c654466011743126c1e5b5ab10a6e70ca57b98c0083a7bba02f794e5835804987431376555e01f61b501f6bcba64e161d0c9c4c56c1a39278653b30718f777d571ffd054909c88ac7d30a0a83ce9076457740c3ccfca9826e3a2c046bea8abe252206759574f308cd83ada92689a1f6ce3aba60e2d48a5e5e7881",
  "aesIv": "0xd8df0c110843ea95f2a329b3faa1dc69",
  "data": "0x763f4f6dec5c348e6908f7788cc825271db607c2acfe59738e8b5ee525bf0a34a124c52cd71b3e925f75241cd0adbec43411051dde4a86a86963bb1bc2c5ad5da1346d8f570c0893c7602dbc667d2fb8"
}

# Decrypted User Data

Successful decryption of the 'data' value using the AES key (once it's been decrypted using your RSA private key) will result in JSON like this:

{
	"FullName": "Justin Bieber",
	"DateOfBirth": 6235156423, // unix time
	"CountryCode": "CAN"
}