Commit 956fb1df authored by's avatar
Browse files

added blockhash to signing example

parent 17a60288
This diff is collapsed.
......@@ -7,8 +7,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<script type="text/javascript" src="irma.js"></script>
<script type="text/javascript" src="blockhash.js"></script>
<script type="text/javascript" src="pop.js"></script>
html, body {
margin: 10px 0;
......@@ -30,9 +30,16 @@
<h3>sign text</h3>
<textarea id="message" rows="5" cols="80">Replace this with your <b>own</b> text!</textarea>
<button id="start-popup">Sign message</button>
<textarea id="result" rows="5" cols="80"></textarea>
<h3>sign image</h3>
<textarea id="imageurl" rows="5" cols="80"></textarea>
<button id="start-popup-image">Sign image hash</button>
<textarea id="result-image" rows="5" cols="80"></textarea>
<script type="text/javascript">
......@@ -57,6 +64,37 @@
console.error("Couldn't do what you asked 😢", error);
//sign the hash of an image
document.getElementById('start-popup-image').onclick = () => {
//1. calculate hash using pop library function
let url = document.getElementById("imageurl").value;
//NB a CORS error can be thrown,
//make sure the url that points to the image is on a server that serves correct CORS headers
document.getElementById("imageurl").value = hash;
//2. sign the hash
.then( result =>{
//3. show the result
document.getElementById("result-image").value = result;
}).catch(error => {
if (error === 'Aborted') {
console.log('We closed it ourselves, so no problem 😅');
console.error("Couldn't do what you asked 😢", error);
} else {
document.getElementById("imageurl").value = err;
......@@ -7,6 +7,12 @@ function pop_normalize(raw){
return text;
//perform perceptual image hash on url specified in image, specify callback with signature (err,hash)
function pop_imagehash(url,callback){
var blockhash = blockhashjs.blockhash;
return blockhash(url,16,2,callback);
//calls irma server specified in url
//to sign the message, using the (disclosed) attribute name
function pop_sign(url, attribute, message){
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment