Skip to content
Snippets Groups Projects
Commit 9f7afef8 authored by Éloïs's avatar Éloïs
Browse files

[fix] block local check: auto use new verify fn when dubp jump to v12

parent 075bd0d2
No related branches found
No related tags found
1 merge request!1283Resolve "Duniter uses a buggy version of TweetNaCl"
......@@ -16,7 +16,7 @@ import {ConfDTO} from "../dto/ConfDTO"
import {CindexEntry, IndexEntry, Indexer, MindexEntry, SindexEntry} from "../indexer"
import {BaseDTO, TransactionDTO} from "../dto/TransactionDTO"
import {DBBlock} from "../db/DBBlock"
import {verifyBuggy} from "../common-libs/crypto/keyring"
import {verify, verifyBuggy} from "../common-libs/crypto/keyring"
import {hashf} from "../common"
import {CommonConstants} from "../common-libs/constants"
import {IdentityDTO} from "../dto/IdentityDTO"
......@@ -87,8 +87,13 @@ export const LOCAL_RULES_FUNCTIONS = {
},
checkBlockSignature: async (block:BlockDTO) => {
if (!verifyBuggy(block.getSignedPart(), block.signature, block.issuer))
// Historically, Duniter used a buggy version of TweetNaCl (see #1390)
// Starting with the v12 blocks, Duniter uses a fixed version of TweetNaCl.
if (block.version >= 12 && !verify(block.getSignedPart(), block.signature, block.issuer)) {
throw Error('Block\'s signature must match');
} else if (!verifyBuggy(block.getSignedPart(), block.signature, block.issuer)) {
throw Error('Block\'s signature must match');
}
return true;
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment