Style fixes and new style rules for eslint (#919)

This commit is contained in:
Ilya Chesnokov 2019-06-28 15:33:19 +02:00 committed by Daniel Huigens
parent 1bd5689d75
commit 6d626ea70c
12 changed files with 63 additions and 57 deletions

View File

@ -244,7 +244,7 @@ module.exports = {
"no-with": "error", "no-with": "error",
"nonblock-statement-body-position": "error", "nonblock-statement-body-position": "error",
"object-curly-newline": "off", "object-curly-newline": "off",
"object-curly-spacing": "off", "object-curly-spacing": "error",
"object-property-newline": [ "object-property-newline": [
"error", "error",
{ {
@ -314,6 +314,7 @@ module.exports = {
"error", "error",
"never" "never"
], ],
"indent": [ "error", 2, { "SwitchCase": 1 } ],
// Custom silencers: // Custom silencers:
"camelcase": 0, "camelcase": 0,
@ -335,7 +336,6 @@ module.exports = {
"no-unused-vars": 1, "no-unused-vars": 1,
// TODO Consider fixing these: // TODO Consider fixing these:
"indent": [ 0, 2, { "SwitchCase": 1 } ],
"valid-jsdoc": 0, "valid-jsdoc": 0,
"new-cap": [ 0, { "properties": false, "capIsNewExceptionPattern": "^type_.*" }], "new-cap": [ 0, { "properties": false, "capIsNewExceptionPattern": "^type_.*" }],
"no-lonely-if": 0, "no-lonely-if": 0,

View File

@ -84,8 +84,10 @@ export default {
} }
break; break;
} }
return { r: r.toArrayLike(Uint8Array), return {
s: s.toArrayLike(Uint8Array) }; r: r.toArrayLike(Uint8Array),
s: s.toArrayLike(Uint8Array)
};
}, },
/** /**

View File

@ -38,8 +38,10 @@ async function sign(oid, hash_algo, m, d, hashed) {
const curve = new Curve(oid); const curve = new Curve(oid);
const key = curve.keyFromPrivate(d); const key = curve.keyFromPrivate(d);
const signature = await key.sign(m, hash_algo, hashed); const signature = await key.sign(m, hash_algo, hashed);
return { r: signature.r.toArrayLike(Uint8Array), return {
s: signature.s.toArrayLike(Uint8Array) }; r: signature.r.toArrayLike(Uint8Array),
s: signature.s.toArrayLike(Uint8Array)
};
} }
/** /**

View File

@ -65,8 +65,10 @@ export default {
case enums.publicKey.eddsa: { case enums.publicKey.eddsa: {
const oid = pub_MPIs[0]; const oid = pub_MPIs[0];
// EdDSA signature params are expected in little-endian format // EdDSA signature params are expected in little-endian format
const signature = { R: msg_MPIs[0].toUint8Array('le', 32), const signature = {
S: msg_MPIs[1].toUint8Array('le', 32) }; R: msg_MPIs[0].toUint8Array('le', 32),
S: msg_MPIs[1].toUint8Array('le', 32)
};
const Q = pub_MPIs[1].toUint8Array('be', 33); const Q = pub_MPIs[1].toUint8Array('be', 33);
return publicKey.elliptic.eddsa.verify(oid, hash_algo, signature, data, Q, hashed); return publicKey.elliptic.eddsa.verify(oid, hash_algo, signature, data, Q, hashed);
} }