I'm building a mobile application that transfers points between users via QRCode. I'm concerned about security and am looking for effective simple yes secure algorithm to use. The scenario should be something similar to this.
- User A wants to transfer X points to User B.
- User A generates a QR code on his mobile application, embeds the points number(
X) anduserA.idin the QR code. - User B reads the QR code, sends {
points numver:X,from=userA.id,to=userB.id} to the server. - User
Acan generate the QRCode while offline, where userBmust be online to read the QRCode. - The server receives the request and transfers
Xpoints from userAto userB.
The technical scenario we have for making this:
- The server has a global value named
salt.saltis random and auto generated every day. - In the server, every user has the following fields:
- id: Auto Incriminate number.
- userKey:
md5( id + salt )=> changes every day. - generatedQRCodesNumberForToday: a number represents how many times the user generated a QRCode today, max value is 10, the value resets every day.
- N: Array of already uses numbers in the current day while transferring points, the array resets everyday.
- Every day, the user claims a new
userKey. - Every user have a counter in his mobile application represents
generatedQRCodesNumberForToday, this number is synced with the server whenever the user is online, and this number increases whenever the user creates an new QRCode. - If user
Awants to transferXpoints to userB:- User
Acreates a QRCode that has {from:userA.id,numberOfTrile:md5(userA.userKey + userA.generatedQRCodesNumberForToday),points:encode(userA.pointsToTransfer, userA.userKey)}. - User
Breads the qr data, addsto:userB.idto them, and sends them to the server.
- User
- On server side:
- The server receives the
fromfield and knows who is the sender. - The server receives the
tofield and knows who is the receiver. - The server receives the
pointsfield and decodes is using the senderuserKeyto know the amount of points. - The server receives
numberOfTrilefield. The use ofnumberOfTrilefield is to make sure that no user will generate the same QRCode more than once. The server tries to matchnumberOfTrilewith {md5(from.userKey + '1'),...,md5(from.userKey + N),...,md5(from.userKey + '10')} whereNwas not used before, if there's a match then the transform process is approved and the number that matched the concatenationNis marked as not valid for future use.
- The server receives the
I want to know if my process is secure or it has any possible security vulnerabilities.