Each block must be signed using the private key assigned to each user or entity, adding the signature attribute to the block.
block = {
prevHash: block.prevHash,
height: block.height,
version: block.version,
data: block.data,
timestamp: block.timestamp,
scope: block.scope,
by: block.by,
signature: ...,
hash: ...,
};
const pathToKey = "./KEY.priv.key";
const blockContent = "TEST";
const signedBlock = await clientSign(
"ENTITY",
"SCOPE",
blockContent, // BLOCK CONTENT
pathToKey // PATH TO LOCAL KEY
);
const submitResult = await submitBlock(signedBlock);
console.log("submitResult", submitResult);
console.log(await confirmBlock(signedBlock.hash));
{
prevHash: '12512a748535f9b28b727570d9cb6b',
height: 15,
version: 2,
data: 'TEST',
timestamp: 16847615,
scope: 'SCOPE',
signature: 'fR7loT8CLTOuf/KxvEeCaRGurqRATMtiPJSZ8q2IQ==',
by: 'ENTITY',
signature: 'bcags98cays90opib3ug97...kopmlnjbhvyft6r7t9'
hash: '875457b166809e2a64e1abc74568fa820ef3'
}