diff --git a/hush-hush.js b/hush-hush.js index 9008657..1a45099 100644 --- a/hush-hush.js +++ b/hush-hush.js @@ -60,7 +60,6 @@ async function findMessages(){ apiGET("getdata", "/" + block).then(function(d){ console.debug(d) }) - }) } diff --git a/index.html b/index.html index b377c98..5dbf620 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,7 @@ - + diff --git a/onionr-blocks.js b/onionr-blocks.js new file mode 100644 index 0000000..a0569cd --- /dev/null +++ b/onionr-blocks.js @@ -0,0 +1,14 @@ +function reconstructHash(hash){ + return hash.padStart(64, 0) +} + + +function verifyBlock(raw, hash){ + var encoder = new TextEncoder("utf-8") + hash = reconstructHash(hash) + if (doHashHex(encoder.encode(raw)) != hash){ + throw new Error("Hash does not match") + } +} + +