Implement new Witness decoding function
diff --git a/js/tools/build/ndn-js.js b/js/tools/build/ndn-js.js
index cdeb725..36f2fd6 100644
--- a/js/tools/build/ndn-js.js
+++ b/js/tools/build/ndn-js.js
@@ -10,8 +10,8 @@
new UpcallInfo(a,null,0,this.contentObject));d=new KeyStoreEntry(l.keyName,d,(new Date).getTime());NDN.addKeyEntry(d)}};if(d.signedInfo&&d.signedInfo.locator&&d.signature){3<LOG&&console.log("Key verification...");var j=DataUtils.toHex(d.signature.signature).toLowerCase(),l=d.signedInfo.locator;if(l.type==KeyLocatorType.KEYNAME)if(3<LOG&&console.log("KeyLocator contains KEYNAME"),l.keyName.contentName.match(d.name))3<LOG&&console.log("Content is key itself"),k=decodeSubjectPublicKeyInfo(d.content),
k=k.verifyByteArray(d.rawSignatureData,f,j),f=!0==k?Closure.UPCALL_CONTENT:Closure.UPCALL_CONTENT_BAD,g.upcall(f,new UpcallInfo(a,null,0,d));else{var p=NDN.getKeyByName(l.keyName);p?(3<LOG&&console.log("Local key cache hit"),k=p.rsaKey,k=k.verifyByteArray(d.rawSignatureData,f,j),f=!0==k?Closure.UPCALL_CONTENT:Closure.UPCALL_CONTENT_BAD,g.upcall(f,new UpcallInfo(a,null,0,d))):(3<LOG&&console.log("Fetch key according to keylocator"),f=new k(d,g,l.keyName,j,f),d=new Interest(l.keyName.contentName.getPrefix(4)),
d.interestLifetime=4,b.expressInterest(a,d,f))}else l.type==KeyLocatorType.KEY?(3<LOG&&console.log("Keylocator contains KEY"),k=!1,null==f&&(k=decodeSubjectPublicKeyInfo(d.signedInfo.locator.publicKey),k=k.verifyByteArray(d.rawSignatureData,f,j)),f=!0==k?Closure.UPCALL_CONTENT:Closure.UPCALL_CONTENT_BAD,g.upcall(Closure.UPCALL_CONTENT,new UpcallInfo(a,null,0,d))):(d=l.certificate,console.log("KeyLocator contains CERT"),console.log(d))}}}else console.log("Incoming packet is not Interest or ContentObject. Discard now.");
-delete c;delete b.structureDecoder;delete b.buffer;b.structureDecoder=new BinaryXMLStructureDecoder;b.buffer=new Uint8Array(b.maxBufferSize);b.bufferOffset=0}};this.ws.onopen=function(a){3<LOG&&console.log(a);3<LOG&&console.log("ws.onopen: WebSocket connection opened.");3<LOG&&console.log("ws.onopen: ReadyState: "+this.readyState);a=new Interest(new Name(NDN.ccndIdFetcher));a.interestLifetime=4E3;var a=encodeToBinaryInterest(a),d=new Uint8Array(a.length);d.set(a);b.ws.send(d.buffer)};this.ws.onerror=
-function(a){console.log("ws.onerror: ReadyState: "+this.readyState);console.log(a);console.log("ws.onerror: WebSocket error: "+a.data)};this.ws.onclose=function(){console.log("ws.onclose: WebSocket connection closed.");b.ws=null;a.readyStatus=NDN.CLOSED;a.onclose()}};
+delete c;delete b.structureDecoder;delete b.buffer;b.structureDecoder=new BinaryXMLStructureDecoder;b.buffer=new Uint8Array(b.maxBufferSize);b.bufferOffset=0}};this.ws.onopen=function(a){3<LOG&&console.log(a);3<LOG&&console.log("ws.onopen: WebSocket connection opened.");3<LOG&&console.log("ws.onopen: ReadyState: "+this.readyState);a=new Interest(NDN.ccndIdFetcher);a.interestLifetime=4E3;var a=encodeToBinaryInterest(a),d=new Uint8Array(a.length);d.set(a);b.ws.send(d.buffer)};this.ws.onerror=function(a){console.log("ws.onerror: ReadyState: "+
+this.readyState);console.log(a);console.log("ws.onerror: WebSocket error: "+a.data)};this.ws.onclose=function(){console.log("ws.onclose: WebSocket connection closed.");b.ws=null;a.readyStatus=NDN.CLOSED;a.onclose()}};
WebSocketTransport.prototype.expressInterest=function(a,b,c){if(null!=this.ws){var d=encodeToBinaryInterest(b),e=new Uint8Array(d.length);e.set(d);var f=new PITEntry(b,c);NDN.PITTable.push(f);this.ws.send(e.buffer);3<LOG&&console.log("ws.send() returned.");c.timerID=setTimeout(function(){3<LOG&&console.log("Interest time out.");var d=NDN.PITTable.indexOf(f);0<=d&&NDN.PITTable.splice(d,1);c.upcall(Closure.UPCALL_INTEREST_TIMED_OUT,new UpcallInfo(a,b,0,null))},b.interestLifetime)}else console.log("WebSocket connection is not established.")};
var CSTable=[],CSEntry=function(a,b){this.name=a;this.closure=b};function getEntryForRegisteredPrefix(a){for(var b=0;b<CSTable.length;b++)if(null!=CSTable[b].name.match(a))return CSTable[b];return null}
WebSocketTransport.prototype.registerPrefix=function(a,b,c){if(null!=this.ws){if(null==this.ccndid)return console.log("ccnd node ID unkonwn. Cannot register prefix."),-1;var a=new ForwardingEntry("selfreg",b,null,null,3,2147483647),a=encodeForwardingEntry(a),d=new SignedInfo;d.setFields();a=new ContentObject(new Name,d,a,new Signature);a.sign();a=encodeToBinaryContentObject(a);a=new Name(["ccnx",this.ccndid,"selfreg",a]);a=new Interest(a);a.scope=1;d=encodeToBinaryInterest(a);a=new Uint8Array(d.length);
@@ -145,32 +145,11 @@
e.subjectPublicKeyRSA.e.toString(16)+"<br/>";b+="<br/>";c=e.subjectPublicKeyRSA.verifyByteArray(a.rawSignatureData,c);2<LOG&&console.log("result is "+c);d=e.subjectPublicKeyRSA.n;e=e.subjectPublicKeyRSA.e;2<LOG&&console.log("PUBLIC KEY n after is ");2<LOG&&console.log(d);2<LOG&&console.log("EXPONENT e after is ");2<LOG&&console.log(e);b=c?b+"SIGNATURE VALID":b+"SIGNATURE INVALID";b+="<br />";b+="<br />"}if(null!=a.signedInfo&&null!=a.signedInfo.locator&&null!=a.signedInfo.locator.publicKey){var d=
DataUtils.toHex(a.signedInfo.locator.publicKey).toLowerCase(),f=DataUtils.toString(a.signedInfo.locator.publicKey),c=DataUtils.toHex(a.signature.signature).toLowerCase(),e=DataUtils.toString(a.rawSignatureData),b=b+("Public key: "+d),b=b+"<br />",b=b+"<br />";2<LOG&&console.log(" ContentName + SignedInfo + Content = "+e);2<LOG&&console.log(" PublicKeyHex = "+d);2<LOG&&console.log(" PublicKeyString = "+f);2<LOG&&console.log(" Signature "+c);2<LOG&&console.log(" Signature NOW IS");2<LOG&&console.log(a.signature.signature);
e=decodeSubjectPublicKeyInfo(a.signedInfo.locator.publicKey);b+="Public key (hex) modulus: "+e.n.toString(16)+"<br/>";b+="exponent: "+e.e.toString(16)+"<br/>";b+="<br/>";c=e.verifyByteArray(a.rawSignatureData,c);2<LOG&&console.log("PUBLIC KEY n after is ");2<LOG&&console.log(e.n);2<LOG&&console.log("EXPONENT e after is ");2<LOG&&console.log(e.e);b=c?b+"SIGNATURE VALID":b+"SIGNATURE INVALID";b+="<br />";b+="<br />"}}return b}
-function Stream(a,b){a instanceof Stream?(this.enc=a.enc,this.pos=a.pos):(this.enc=a,this.pos=b)}Stream.prototype.get=function(a){void 0==a&&(a=this.pos++);if(a>=this.enc.length)throw"Requesting byte offset "+a+" on a stream of length "+this.enc.length;return this.enc[a]};Stream.prototype.hexDigits="0123456789ABCDEF";Stream.prototype.hexByte=function(a){return this.hexDigits.charAt(a>>4&15)+this.hexDigits.charAt(a&15)};
-Stream.prototype.hexDump=function(a,b){for(var c="",d=a;d<b;++d)switch(c+=this.hexByte(this.get(d)),d&15){case 7:c+=" ";break;case 15:c+="\n";break;default:c+=" "}return c};Stream.prototype.parseStringISO=function(a,b){for(var c="",d=a;d<b;++d)c+=String.fromCharCode(this.get(d));return c};
-Stream.prototype.parseStringUTF=function(a,b){for(var c="",d=0,e=a;e<b;)d=this.get(e++),c=128>d?c+String.fromCharCode(d):191<d&&224>d?c+String.fromCharCode((d&31)<<6|this.get(e++)&63):c+String.fromCharCode((d&15)<<12|(this.get(e++)&63)<<6|this.get(e++)&63);return c};Stream.prototype.reTime=/^((?:1[89]|2\d)?\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
-Stream.prototype.parseTime=function(a,b){var c=this.parseStringISO(a,b),d=this.reTime.exec(c);if(!d)return"Unrecognized time: "+c;c=d[1]+"-"+d[2]+"-"+d[3]+" "+d[4];d[5]&&(c+=":"+d[5],d[6]&&(c+=":"+d[6],d[7]&&(c+="."+d[7])));d[8]&&(c+=" UTC","Z"!=d[8]&&(c+=d[8],d[9]&&(c+=":"+d[9])));return c};Stream.prototype.parseInteger=function(a,b){var c=b-a;if(4<c){var c=c<<3,d=this.get(a);if(0==d)c-=8;else for(;128>d;)d<<=1,--c;return"("+c+" bit)"}c=0;for(d=a;d<b;++d)c=c<<8|this.get(d);return c};
-Stream.prototype.parseBitString=function(a,b){var c=this.get(a),d=(b-a-1<<3)-c,e="("+d+" bit)";if(20>=d)for(var f=c,e=e+" ",c=b-1;c>a;--c){for(d=this.get(c);8>f;++f)e+=d>>f&1?"1":"0";f=0}return e};Stream.prototype.parseOctetString=function(a,b){var c=b-a,d="("+c+" byte) ";20<c&&(b=a+20);for(var e=a;e<b;++e)d+=this.hexByte(this.get(e));20<c&&(d+=String.fromCharCode(8230));return d};
-Stream.prototype.parseOID=function(a,b){for(var c,d=0,e=0,f=a;f<b;++f){var g=this.get(f),d=d<<7|g&127,e=e+7;g&128||(c=void 0==c?parseInt(d/40)+"."+d%40:c+("."+(31<=e?"bigint":d)),d=e=0);c+=String.fromCharCode()}return c};function ASN1(a,b,c,d,e){this.stream=a;this.header=b;this.length=c;this.tag=d;this.sub=e}
-ASN1.prototype.typeName=function(){if(void 0==this.tag)return"unknown";var a=this.tag&31;switch(this.tag>>6){case 0:switch(a){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";
-case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString";default:return"Universal_"+a.toString(16)}case 1:return"Application_"+a.toString(16);case 2:return"["+a+"]";case 3:return"Private_"+a.toString(16)}};
-ASN1.prototype.content=function(){if(void 0==this.tag)return null;if(0!=this.tag>>6)return null==this.sub?null:"("+this.sub.length+")";var a=this.tag&31,b=this.posContent(),c=Math.abs(this.length);switch(a){case 1:return 0==this.stream.get(b)?"false":"true";case 2:return this.stream.parseInteger(b,b+c);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(b,b+c);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(b,b+c);case 6:return this.stream.parseOID(b,
-b+c);case 16:case 17:return"("+this.sub.length+" elem)";case 12:return this.stream.parseStringUTF(b,b+c);case 18:case 19:case 20:case 21:case 22:case 26:return this.stream.parseStringISO(b,b+c);case 23:case 24:return this.stream.parseTime(b,b+c)}return null};ASN1.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null==this.sub?"null":this.sub.length)+"]"};
-ASN1.prototype.print=function(a){void 0==a&&(a="");document.writeln(a+this);if(null!=this.sub)for(var a=a+" ",b=0,c=this.sub.length;b<c;++b)this.sub[b].print(a)};
-ASN1.prototype.toPrettyString=function(a){void 0==a&&(a="");var b=a+this.typeName()+" @"+this.stream.pos;0<=this.length&&(b+="+");b+=this.length;if(this.tag&32)b+=" (constructed)";else if((3==this.tag||4==this.tag)&&null!=this.sub)b+=" (encapsulates)";b+="\n";if(null!=this.sub)for(var a=a+" ",c=0,d=this.sub.length;c<d;++c)b+=this.sub[c].toPrettyString(a);return b};
-ASN1.prototype.toDOM=function(){var a=document.createElement("div");a.className="node";a.asn1=this;var b=document.createElement("div");b.className="head";var c=this.typeName().replace(/_/g," ");b.innerHTML=c;var d=this.content();null!=d&&(d=String(d).replace(/</g,"<"),c=document.createElement("span"),c.className="preview",c.innerHTML=d,b.appendChild(c));a.appendChild(b);this.node=a;this.head=b;var e=document.createElement("div");e.className="value";c="Offset: "+this.stream.pos+"<br/>";c+="Length: "+
-this.header+"+";c=0<=this.length?c+this.length:c+(-this.length+" (undefined)");if(this.tag&32)c+="<br/>(constructed)";else if((3==this.tag||4==this.tag)&&null!=this.sub)c+="<br/>(encapsulates)";if(null!=d&&(c+="<br/>Value:<br/><b>"+d+"</b>","object"==typeof oids&&6==this.tag&&(d=oids[d])))d.d&&(c+="<br/>"+d.d),d.c&&(c+="<br/>"+d.c),d.w&&(c+="<br/>(warning!)");e.innerHTML=c;a.appendChild(e);c=document.createElement("div");c.className="sub";if(null!=this.sub){d=0;for(e=this.sub.length;d<e;++d)c.appendChild(this.sub[d].toDOM())}a.appendChild(c);
-b.switchNode=a;b.onclick=function(){var a=this.switchNode;a.className="node collapsed"==a.className?"node":"node collapsed"};return a};ASN1.prototype.posStart=function(){return this.stream.pos};ASN1.prototype.posContent=function(){return this.stream.pos+this.header};ASN1.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)};ASN1.prototype.fakeHover=function(a){this.node.className+=" hover";a&&(this.head.className+=" hover")};
-ASN1.prototype.fakeOut=function(a){var b=/ ?hover/;this.node.className=this.node.className.replace(b,"");a&&(this.head.className=this.head.className.replace(b,""))};ASN1.prototype.toHexDOM_sub=function(a,b,c,d,e){if(!(d>=e)){var f=document.createElement("span");f.className=b;f.appendChild(document.createTextNode(c.hexDump(d,e)));a.appendChild(f)}};
-ASN1.prototype.toHexDOM=function(a){var b=document.createElement("span");b.className="hex";void 0==a&&(a=b);this.head.hexNode=b;this.head.onmouseover=function(){this.hexNode.className="hexCurrent"};this.head.onmouseout=function(){this.hexNode.className="hex"};b.asn1=this;b.onmouseover=function(){var b=!a.selected;b&&(a.selected=this.asn1,this.className="hexCurrent");this.asn1.fakeHover(b)};b.onmouseout=function(){var b=a.selected==this.asn1;this.asn1.fakeOut(b);b&&(a.selected=null,this.className=
-"hex")};this.toHexDOM_sub(b,"tag",this.stream,this.posStart(),this.posStart()+1);this.toHexDOM_sub(b,0<=this.length?"dlen":"ulen",this.stream,this.posStart()+1,this.posContent());if(null==this.sub)b.appendChild(document.createTextNode(this.stream.hexDump(this.posContent(),this.posEnd())));else if(0<this.sub.length){var c=this.sub[0],d=this.sub[this.sub.length-1];this.toHexDOM_sub(b,"intro",this.stream,this.posContent(),c.posStart());for(var c=0,e=this.sub.length;c<e;++c)b.appendChild(this.sub[c].toHexDOM(a));
-this.toHexDOM_sub(b,"outro",this.stream,d.posEnd(),this.posEnd())}return b};ASN1.decodeLength=function(a){var b=a.get(),c=b&127;if(c==b)return c;if(3<c)throw"Length over 24 bits not supported at position "+(a.pos-1);if(0==c)return-1;for(var d=b=0;d<c;++d)b=b<<8|a.get();return b};ASN1.hasContent=function(a,b,c){if(a&32)return!0;if(3>a||4<a)return!1;var d=new Stream(c);3==a&&d.get();if(d.get()>>6&1)return!1;try{var e=ASN1.decodeLength(d);return d.pos-c.pos+e==b}catch(f){return!1}};
-ASN1.decode=function(a){a instanceof Stream||(a=new Stream(a,0));var b=new Stream(a),c=a.get(),d=ASN1.decodeLength(a),e=a.pos-b.pos,f=null;if(ASN1.hasContent(c,d,a)){var g=a.pos;3==c&&a.get();f=[];if(0<=d){for(var j=g+d;a.pos<j;)f[f.length]=ASN1.decode(a);if(a.pos!=j)throw"Content size is not correct for container starting at offset "+g;}else try{for(;;){j=ASN1.decode(a);if(0==j.tag)break;f[f.length]=j}d=g-a.pos}catch(k){throw"Exception while decoding undefined length content: "+k;}}else a.pos+=d;
-return new ASN1(b,e,d,c,f)};
-Hex={decode:function(a){if(void 0==Hex.decoder){for(var b="0123456789ABCDEF",c=[],d=0;16>d;++d)c[b.charAt(d)]=d;b=b.toLowerCase();for(d=10;16>d;++d)c[b.charAt(d)]=d;for(d=0;8>d;++d)c[" \f\n\r\t\u00a0\u2028\u2029".charAt(d)]=-1;Hex.decoder=c}for(var b=[],e=c=0,d=0;d<a.length;++d){var f=a.charAt(d);if("="==f)break;f=Hex.decoder[f];if(-1!=f){if(void 0==f)throw"Illegal character at offset "+d;c|=f;2<=++e?(b[b.length]=c,e=c=0):c<<=4}}if(e)throw"Hex encoding incomplete: 4 bits missing";return b}};
-var KeyManager=function(){this.certificate="MIIBmzCCAQQCCQC32FyQa61S7jANBgkqhkiG9w0BAQUFADASMRAwDgYDVQQDEwdheGVsY2R2MB4XDTEyMDQyODIzNDQzN1oXDTEyMDUyODIzNDQzN1owEjEQMA4GA1UEAxMHYXhlbGNkdjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA4X0wp9goqxuECxdULcr2IHr9Ih4Iaypg0Wy39URIup8/CLzQmdsh3RYqd55hqonu5VTTpH3iMLx6xZDVJAZ8OJi7pvXcQ2C4Re2kjL2c8SanI0RfDhlS1zJadfr1VhRPmpivcYawJ4aFuOLAi+qHFxtN7lhcGCgpW1OV60oXd58CAwEAATANBgkqhkiG9w0BAQUFAAOBgQDLOrA1fXzSrpftUB5Ro6DigX1Bjkf7F5Bkd69hSVp+jYeJFBBlsILQAfSxUZPQtD+2Yc3iCmSYNyxqu9PcufDRJlnvB7PG29+L3y9lR37tetzUV9eTscJ7rdp8Wt6AzpW32IJ/54yKNfP7S6ZIoIG+LP6EIxq6s8K1MXRt8uBJKw==";
-this.publicKey="30819F300D06092A864886F70D010101050003818D0030818902818100E17D30A7D828AB1B840B17542DCAF6207AFD221E086B2A60D16CB7F54448BA9F3F08BCD099DB21DD162A779E61AA89EEE554D3A47DE230BC7AC590D524067C3898BBA6F5DC4360B845EDA48CBD9CF126A723445F0E1952D7325A75FAF556144F9A98AF7186B0278685B8E2C08BEA87171B4DEE585C1828295B5395EB4A17779F0203010001";this.privateKey="MIICXQIBAAKBgQDhfTCn2CirG4QLF1QtyvYgev0iHghrKmDRbLf1REi6nz8IvNCZ2yHdFip3nmGqie7lVNOkfeIwvHrFkNUkBnw4mLum9dxDYLhF7aSMvZzxJqcjRF8OGVLXMlp1+vVWFE+amK9xhrAnhoW44sCL6ocXG03uWFwYKClbU5XrShd3nwIDAQABAoGAGkv6T6jC3WmhFZYL6CdCWvlc6gysmKrhjarrLTxgavtFY6R5g2ft5BXAsCCVbUkWxkIFSKqxpVNl0gKZCNGEzPDN6mHJOQI/h0rlxNIHAuGfoAbCzALnqmyZivhJAPGijAyKuU9tczsst5+Kpn+bn7ehzHQuj7iwJonS5WbojqECQQD851K8TpW2GrRizNgG4dx6orZxAaon/Jnl8lS7soXhllQty7qG+oDfzznmdMsiznCqEABzHUUKOVGE9RWPN3aRAkEA5D/w9N55d0ibnChFJlc8cUAoaqH+w+U3oQP2Lb6AZHJpLptN4y4b/uf5d4wYU5/i/gC7SSBH3wFhh9bjRLUDLwJAVOx8vN0Kqt7myfKNbCo19jxjVSlA8TKCn1Oznl/BU1I+rC4oUaEW25DjmX6IpAR8kq7S59ThVSCQPjxqY/A08QJBAIRaF2zGPITQk3r/VumemCvLWiRK/yG0noc9dtibqHOWbCtcXtOm/xDWjq+lis2i3ssOvYrvrv0/HcDY+Dv1An0CQQCLJtMsfSg4kvG/FRY5UMhtMuwo8ovYcMXt4Xv/LWaMhndD67b2UGawQCRqr5ghRTABWdDD/HuuMBjrkPsX0861"};
+var KeyManager=function(){this.certificate="MIIBmzCCAQQCCQC32FyQa61S7jANBgkqhkiG9w0BAQUFADASMRAwDgYDVQQDEwdheGVsY2R2MB4XDTEyMDQyODIzNDQzN1oXDTEyMDUyODIzNDQzN1owEjEQMA4GA1UEAxMHYXhlbGNkdjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA4X0wp9goqxuECxdULcr2IHr9Ih4Iaypg0Wy39URIup8/CLzQmdsh3RYqd55hqonu5VTTpH3iMLx6xZDVJAZ8OJi7pvXcQ2C4Re2kjL2c8SanI0RfDhlS1zJadfr1VhRPmpivcYawJ4aFuOLAi+qHFxtN7lhcGCgpW1OV60oXd58CAwEAATANBgkqhkiG9w0BAQUFAAOBgQDLOrA1fXzSrpftUB5Ro6DigX1Bjkf7F5Bkd69hSVp+jYeJFBBlsILQAfSxUZPQtD+2Yc3iCmSYNyxqu9PcufDRJlnvB7PG29+L3y9lR37tetzUV9eTscJ7rdp8Wt6AzpW32IJ/54yKNfP7S6ZIoIG+LP6EIxq6s8K1MXRt8uBJKw==";this.publicKey=
+"30819F300D06092A864886F70D010101050003818D0030818902818100E17D30A7D828AB1B840B17542DCAF6207AFD221E086B2A60D16CB7F54448BA9F3F08BCD099DB21DD162A779E61AA89EEE554D3A47DE230BC7AC590D524067C3898BBA6F5DC4360B845EDA48CBD9CF126A723445F0E1952D7325A75FAF556144F9A98AF7186B0278685B8E2C08BEA87171B4DEE585C1828295B5395EB4A17779F0203010001";this.privateKey="MIICXQIBAAKBgQDhfTCn2CirG4QLF1QtyvYgev0iHghrKmDRbLf1REi6nz8IvNCZ2yHdFip3nmGqie7lVNOkfeIwvHrFkNUkBnw4mLum9dxDYLhF7aSMvZzxJqcjRF8OGVLXMlp1+vVWFE+amK9xhrAnhoW44sCL6ocXG03uWFwYKClbU5XrShd3nwIDAQABAoGAGkv6T6jC3WmhFZYL6CdCWvlc6gysmKrhjarrLTxgavtFY6R5g2ft5BXAsCCVbUkWxkIFSKqxpVNl0gKZCNGEzPDN6mHJOQI/h0rlxNIHAuGfoAbCzALnqmyZivhJAPGijAyKuU9tczsst5+Kpn+bn7ehzHQuj7iwJonS5WbojqECQQD851K8TpW2GrRizNgG4dx6orZxAaon/Jnl8lS7soXhllQty7qG+oDfzznmdMsiznCqEABzHUUKOVGE9RWPN3aRAkEA5D/w9N55d0ibnChFJlc8cUAoaqH+w+U3oQP2Lb6AZHJpLptN4y4b/uf5d4wYU5/i/gC7SSBH3wFhh9bjRLUDLwJAVOx8vN0Kqt7myfKNbCo19jxjVSlA8TKCn1Oznl/BU1I+rC4oUaEW25DjmX6IpAR8kq7S59ThVSCQPjxqY/A08QJBAIRaF2zGPITQk3r/VumemCvLWiRK/yG0noc9dtibqHOWbCtcXtOm/xDWjq+lis2i3ssOvYrvrv0/HcDY+Dv1An0CQQCLJtMsfSg4kvG/FRY5UMhtMuwo8ovYcMXt4Xv/LWaMhndD67b2UGawQCRqr5ghRTABWdDD/HuuMBjrkPsX0861"};
KeyManager.prototype.verify=function(a,b){var c=this.certificate,d=new X509;d.readCertPEM(c);return d.subjectPublicKeyRSA.verifyString(a,b)};KeyManager.prototype.sign=function(a){var b=this.privateKey,c=new RSAKey;c.readPrivateKeyFromPEMString(b);return c.signString(a,"sha256")};var globalKeyManager=new KeyManager,MerklePath=function(){this.index=null;this.digestList=[]},Witness=function(){this.oid=null;this.path=new MerklePath};
-Witness.prototype.decode=function(a){var a=DataUtils.toHex(a).toLowerCase(),b=Hex.decode(a),b=ASN1.decode(b);this.oid=b.sub[0].sub[0].content();this.path.index=b.sub[1].sub[0].sub[0].content();for(i=0;i<b.sub[1].sub[0].sub[1].sub.length;i++)pos=b.sub[1].sub[0].sub[1].sub[i].stream.pos,str=a.substring(2*pos+4,2*pos+68),this.path.digestList.push(str)};var hexcase=0,b64pad="";function hex_sha256_from_bytes(a){return rstr2hex(binb2rstr(binb_sha256(byteArray2binb(a),8*a.length)))}
+function parseOID(a,b,c){for(var d,e=0,f=0;b<c;++b){var g=a[b],e=e<<7|g&127,f=f+7;g&128||(d=void 0==d?parseInt(e/40)+"."+e%40:d+("."+(31<=f?"bigint":e)),e=f=0);d+=String.fromCharCode()}return d}function parseInteger(a,b,c){for(var d=0;b<c;++b)d=d<<8|a[b];return d}
+Witness.prototype.decode=function(a){for(var b=0,c=0;b<a.length;){var d=0;48==a[b]?(0!=(a[b+1]&128)&&(d=a[b+1]&127),c++):6==a[b]?(d=a[b+1],this.oid=parseOID(a,b+2,b+2+d)):2==a[b]?(d=a[b+1],this.path.index=parseInteger(a,b+2,b+2+d)):4==a[b]&&(d=0!=(a[b+1]&128)?a[b+1]&127:a[b+1],4==c&&(str=DataUtils.toHex(a.subarray(b+2,b+2+d)),this.path.digestList.push(str)));b=b+2+d}};var hexcase=0,b64pad="";function hex_sha256_from_bytes(a){return rstr2hex(binb2rstr(binb_sha256(byteArray2binb(a),8*a.length)))}
function hex_sha256(a){return rstr2hex(rstr_sha256(str2rstr_utf8(a)))}function b64_sha256(a){return rstr2b64(rstr_sha256(str2rstr_utf8(a)))}function any_sha256(a,b){return rstr2any(rstr_sha256(str2rstr_utf8(a)),b)}function hex_hmac_sha256(a,b){return rstr2hex(rstr_hmac_sha256(str2rstr_utf8(a),str2rstr_utf8(b)))}function b64_hmac_sha256(a,b){return rstr2b64(rstr_hmac_sha256(str2rstr_utf8(a),str2rstr_utf8(b)))}
function any_hmac_sha256(a,b,c){return rstr2any(rstr_hmac_sha256(str2rstr_utf8(a),str2rstr_utf8(b)),c)}function sha256_vm_test(){return"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"==hex_sha256("abc").toLowerCase()}function rstr_sha256(a){return binb2rstr(binb_sha256(rstr2binb(a),8*a.length))}
function rstr_hmac_sha256(a,b){var c=rstr2binb(a);16<c.length&&(c=binb_sha256(c,8*a.length));for(var d=Array(16),e=Array(16),f=0;16>f;f++)d[f]=c[f]^909522486,e[f]=c[f]^1549556828;c=binb_sha256(d.concat(rstr2binb(b)),512+8*b.length);return binb2rstr(binb_sha256(e.concat(c),768))}function rstr2hex(a){try{hexcase}catch(b){hexcase=0}for(var c=hexcase?"0123456789ABCDEF":"0123456789abcdef",d="",e,f=0;f<a.length;f++)e=a.charCodeAt(f),d+=c.charAt(e>>>4&15)+c.charAt(e&15);return d}