Major update: refactored the API of all classes to make attributes start with a lower case letter and rename encode=>to_ccnb() and decode()=>from_ccnb.
(according to the API notes: http://sea.remap.ucla.edu:8080/attachments/download/23/lwndn_api-notes_21020830.txt )
diff --git a/js/Signature.js b/js/Signature.js
index 7eef1d1..9672b3f 100644
--- a/js/Signature.js
+++ b/js/Signature.js
@@ -4,17 +4,17 @@
*/
-var Signature = function Signature(_Witness,_Signature,_DigestAlgorithm) {
+var Signature = function Signature(_witness,_signature,_digestAlgorithm) {
- this.Witness = _Witness;//byte [] _witness;
- this.Signature = _Signature;//byte [] _signature;
- this.DigestAlgorithm = _DigestAlgorithm//String _digestAlgorithm;
+ this.Witness = _witness;//byte [] _witness;
+ this.signature = _signature;//byte [] _signature;
+ this.digestAlgorithm = _digestAlgorithm//String _digestAlgorithm;
};
var generateSignature = function(contentName,content,signedinfo){
var enc = new BinaryXMLEncoder();
- contentName.encode(enc);
+ contentName.to_ccnb(enc);
var hex1 = toHex(enc.getReducedOstream());
var enc = new BinaryXMLEncoder();
@@ -22,7 +22,7 @@
var hex2 = toHex(enc.getReducedOstream());
var enc = new BinaryXMLEncoder();
- signedinfo.encode(enc);
+ signedinfo.to_ccnb(enc);
var hex3 = toHex(enc.getReducedOstream());
var hex = hex1+hex2+hex3;
@@ -31,7 +31,7 @@
};
-Signature.prototype.decode =function( decoder) {
+Signature.prototype.from_ccnb =function( decoder) {
decoder.readStartElement(this.getElementLabel());
if(LOG>4)console.log('STARTED DECODING SIGNATURE ');
@@ -39,7 +39,7 @@
if (decoder.peekStartElement(CCNProtocolDTags.DigestAlgorithm)) {
if(LOG>4)console.log('DIGIEST ALGORITHM FOUND');
- this.DigestAlgorithm = decoder.readUTF8Element(CCNProtocolDTags.DigestAlgorithm);
+ this.digestAlgorithm = decoder.readUTF8Element(CCNProtocolDTags.DigestAlgorithm);
}
if (decoder.peekStartElement(CCNProtocolDTags.Witness)) {
if(LOG>4)console.log('WITNESS FOUND FOUND');
@@ -49,7 +49,7 @@
//FORCE TO READ A SIGNATURE
//if(LOG>4)console.log('SIGNATURE FOUND ');
- this.Signature = decoder.readBinaryElement(CCNProtocolDTags.SignatureBits);
+ this.signature = decoder.readBinaryElement(CCNProtocolDTags.SignatureBits);
if(LOG>4)console.log('READ SIGNATURE ');
decoder.readEndElement();
@@ -57,7 +57,7 @@
};
-Signature.prototype.encode= function( encoder){
+Signature.prototype.to_ccnb= function( encoder){
if (!this.validate()) {
throw new Exception("Cannot encode: field values missing.");
@@ -65,7 +65,7 @@
encoder.writeStartElement(this.getElementLabel());
- if ((null != this.DigestAlgorithm) && (!this.DigestAlgorithm.equals(CCNDigestHelper.DEFAULT_DIGEST_ALGORITHM))) {
+ if ((null != this.digestAlgorithm) && (!this.digestAlgorithm.equals(CCNDigestHelper.DEFAULT_DIGEST_ALGORITHM))) {
encoder.writeElement(CCNProtocolDTags.DigestAlgorithm, OIDLookup.getDigestOID(this.DigestAlgorithm));
}
@@ -74,7 +74,7 @@
encoder.writeElement(CCNProtocolDTags.Witness, this.Witness);
}
- encoder.writeElement(CCNProtocolDTags.SignatureBits, this.Signature);
+ encoder.writeElement(CCNProtocolDTags.SignatureBits, this.signature);
encoder.writeEndElement();
};
@@ -83,6 +83,6 @@
Signature.prototype.validate = function() {
- return null != this.Signature;
+ return null != this.signature;
};