check authenticated rpc signatures in separate threads
This commit is contained in:
@@ -129,44 +129,6 @@ Core.isValidCookie = function (Sessions, publicKey, cookie) {
|
||||
return true;
|
||||
};
|
||||
|
||||
Core.checkSignature = function (Env, signedMsg, signature, publicKey) {
|
||||
if (!(signedMsg && publicKey)) { return false; }
|
||||
|
||||
var signedBuffer;
|
||||
var pubBuffer;
|
||||
var signatureBuffer;
|
||||
|
||||
try {
|
||||
signedBuffer = Nacl.util.decodeUTF8(signedMsg);
|
||||
} catch (e) {
|
||||
Env.Log.error('INVALID_SIGNED_BUFFER', signedMsg);
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
pubBuffer = Nacl.util.decodeBase64(publicKey);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
signatureBuffer = Nacl.util.decodeBase64(signature);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pubBuffer.length !== 32) {
|
||||
Env.Log.error('PUBLIC_KEY_LENGTH', publicKey);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (signatureBuffer.length !== 64) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Nacl.sign.detached.verify(signedBuffer, signatureBuffer, pubBuffer);
|
||||
};
|
||||
|
||||
// E_NO_OWNERS
|
||||
Core.hasOwners = function (metadata) {
|
||||
return Boolean(metadata && Array.isArray(metadata.owners));
|
||||
|
||||
Reference in New Issue
Block a user