Added hash verifier with reconstruction
This commit is contained in:
parent
54b4225e5d
commit
ef5548b0d3
@ -60,7 +60,6 @@ async function findMessages(){
|
||||
apiGET("getdata", "/" + block).then(function(d){
|
||||
console.debug(d)
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
<script src="sha3.js" defer></script>
|
||||
<script src="onionr-jspow/index.js" defer></script>
|
||||
<script src="hush-hush.js" defer></script>
|
||||
<script src="worker-handler.js"></script>
|
||||
<script src="onionr-blocks.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
14
onionr-blocks.js
Normal file
14
onionr-blocks.js
Normal file
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user