Skip to content
Snippets Groups Projects
Commit 004da827 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Fixing #471 Blockchain generation is no more stuck by wrongly signed identities

parent 765dd2c6
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ var constants = require('./constants'); ...@@ -11,6 +11,7 @@ var constants = require('./constants');
var base58 = require('./base58'); var base58 = require('./base58');
var rules = require('./rules'); var rules = require('./rules');
var signature = require('./signature'); var signature = require('./signature');
var crypto = require('./crypto');
var Identity = require('./entity/identity'); var Identity = require('./entity/identity');
var Certification = require('./entity/certification'); var Certification = require('./entity/certification');
var Membership = require('./entity/membership'); var Membership = require('./entity/membership');
...@@ -461,6 +462,13 @@ function BlockGenerator(mainContext, prover) { ...@@ -461,6 +462,13 @@ function BlockGenerator(mainContext, prover) {
throw 'Too old identity'; throw 'Too old identity';
} }
} }
let idty = new Identity(identity);
idty.currency = conf.currency;
let selfCert = idty.rawWithoutSig();
let verified = crypto.verify(selfCert, idty.sig, idty.pubkey);
if (!verified) {
throw constants.ERRORS.IDENTITY_WRONGLY_SIGNED;
}
if (!identity.leaving) { if (!identity.leaving) {
if (!current) { if (!current) {
// Look for certifications from initial joiners // Look for certifications from initial joiners
......
...@@ -84,7 +84,8 @@ module.exports = { ...@@ -84,7 +84,8 @@ module.exports = {
SOURCE_ALREADY_CONSUMED: { httpCode: 400, uerr: { ucode: 2015, message: "Source already consumed" }}, SOURCE_ALREADY_CONSUMED: { httpCode: 400, uerr: { ucode: 2015, message: "Source already consumed" }},
WRONG_AMOUNTS: { httpCode: 400, uerr: { ucode: 2016, message: "Sum of inputs must equal sum of outputs" }}, WRONG_AMOUNTS: { httpCode: 400, uerr: { ucode: 2016, message: "Sum of inputs must equal sum of outputs" }},
WRONG_OUTPUT_BASE: { httpCode: 400, uerr: { ucode: 2017, message: "Wrong unit base for outputs" }}, WRONG_OUTPUT_BASE: { httpCode: 400, uerr: { ucode: 2017, message: "Wrong unit base for outputs" }},
CANNOT_ROOT_BLOCK_NO_MEMBERS: { httpCode: 400, uerr: { ucode: 2018, message: "Wrong new block: cannot make a root block without members" }} CANNOT_ROOT_BLOCK_NO_MEMBERS: { httpCode: 400, uerr: { ucode: 2018, message: "Wrong new block: cannot make a root block without members" }},
IDENTITY_WRONGLY_SIGNED: { httpCode: 400, uerr: { ucode: 2019, message: "Weird, the signature is wrong and in the database." }}
}, },
DEBUG: { DEBUG: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment