respond with 3 values
- floid_pubkey_match - message_sign_match - success
This commit is contained in:
parent
1bf4b70e62
commit
a88965cab1
@ -12,20 +12,19 @@ module.exports = function startServer(port) {
|
|||||||
req.on('data', chunk => data += chunk);
|
req.on('data', chunk => data += chunk);
|
||||||
req.on('end', () => {
|
req.on('end', () => {
|
||||||
//process verification
|
//process verification
|
||||||
let result = {};
|
let result = {
|
||||||
|
success: 0,
|
||||||
|
floid_pubkey_match: 0,
|
||||||
|
message_sign_match: 0
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
var d = JSON.parse(data);
|
var d = JSON.parse(data);
|
||||||
if (!floCrypto.validateAddr(d.floID))
|
if (floCrypto.validateAddr(d.floID) && floCrypto.getFloID(d.pubKey) == d.floID)
|
||||||
result.success = 0;
|
result.floid_pubkey_match = 1;
|
||||||
else if (floCrypto.getFloID(d.pubKey) !== d.floID)
|
if (floCrypto.verifySign(d.message, d.sign, d.pubKey))
|
||||||
result.success = 0;
|
result.message_sign_match = 1;
|
||||||
else if (!floCrypto.verifySign(d.message, d.sign, d.pubKey))
|
result.success = result.floid_pubkey_match && result.message_sign_match
|
||||||
result.success = 0;
|
} catch (error) {} finally {
|
||||||
else
|
|
||||||
result.success = 1;
|
|
||||||
} catch (error) {
|
|
||||||
result.success = 0;
|
|
||||||
} finally {
|
|
||||||
res.end(JSON.stringify(result));
|
res.end(JSON.stringify(result));
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user