diff --git a/include/ndn-cpp/data.hpp b/include/ndn-cpp/data.hpp
index a227c7f..1fb098f 100644
--- a/include/ndn-cpp/data.hpp
+++ b/include/ndn-cpp/data.hpp
@@ -10,51 +10,94 @@
 
 #include "common.hpp"
 #include "name.hpp"
-#include "util/signed-blob.hpp"
-#include "c/data-types.h"
-#include "encoding/wire-format.hpp"
+#include "encoding/block.hpp"
 
-struct ndn_MetaInfo;
-struct ndn_Signature;
-struct ndn_Data;
 
 namespace ndn {
 
 /**
- * A Signature is an abstract base class providing methods to work with the signature information in a Data packet.
- * You must create an object of a subclass, for example Sha256WithRsaSignature.
+ * A Signature is storage for the signature-related information (info and value) in a Data packet.
  */
 class Signature {
 public:
-  /**
-   * Return a pointer to a new Signature which is a copy of this signature.
-   * This is pure virtual, the subclass must implement it.
-   */
-  virtual ptr_lib::shared_ptr<Signature> 
-  clone() const = 0;
+  enum {
+    DigestSha256 = 0,
+    SignatureSha256WithRsa = 1
+  };
   
-  /**
-   * The virtual destructor.
-   */
-  virtual 
-  ~Signature();
+  Signature()
+    : type_(-1)
+  {
+  }
   
-    /**
-   * Set the signatureStruct to point to the values in this signature object, without copying any memory.
-   * WARNING: The resulting pointers in signatureStruct are invalid after a further use of this object which could reallocate memory.
-   * This is pure virtual, the subclass must implement it.
-   * @param signatureStruct a C ndn_Signature struct where the name components array is already allocated.
-   */
-  virtual void 
-  get(struct ndn_Signature& signatureStruct) const = 0;
+  Signature(const Block &info, const Block &value)
+    : info_(info)
+    , value_(value)
+  {
+    Buffer::const_iterator i = info_.value_begin();
+    type_ = Tlv::readVarNumber(i, info_.value_end());
+  }
 
-  /**
-   * Clear this signature, and set the values by copying from the ndn_Signature struct.
-   * This is pure virtual, the subclass must implement it.
-   * @param signatureStruct a C ndn_Signature struct
-   */
-  virtual void 
-  set(const struct ndn_Signature& signatureStruct) = 0;
+  operator bool() const
+  {
+    return type_ != -1;
+  }
+
+  uint32_t
+  getType() const
+  {
+    return type_;
+  }
+  
+  const Block&
+  getInfo() const
+  {
+    return info_;
+  }
+
+  void
+  setInfo(const Block &info)
+  {
+    info_ = info;
+    if (info_.hasWire() || info_.hasValue())
+      {
+        info_.parse();
+        const Block &signatureType = info_.get(Tlv::SignatureType);
+        
+        Buffer::const_iterator i = signatureType.value_begin();
+        type_ = Tlv::readVarNumber(i, signatureType.value_end());
+      }
+    else
+      {
+        type_ = -1;
+      }
+  }  
+
+  const Block&
+  getValue() const
+  {
+    return value_;
+  }
+
+  void
+  setValue(const Block &value)
+  {
+    value_ = value;
+  }
+
+  void
+  reset()
+  {
+    type_ = -1;
+    info_.reset();
+    value_.reset();
+  }
+
+private:
+  int32_t type_;
+  
+  Block info_;
+  Block value_;
 };
 
 /**
@@ -62,56 +105,39 @@
  */
 class MetaInfo {
 public:
-  MetaInfo() 
+  enum {
+    TYPE_DEFAULT = 0,
+    TYPE_LINK = 1,
+    TYPE_KEY = 2
+  };
+  
+  MetaInfo()
+    : type_(TYPE_DEFAULT)
+    , freshnessPeriod_(-1)
   {   
-    type_ = ndn_ContentType_DATA;
-    freshnessSeconds_ = -1;
   }
+  
+  uint32_t 
+  getType() const
+  { return type_; }
+  
+  void 
+  setType(uint32_t type)
+  { type_ = type; }
+  
+  Milliseconds 
+  getFreshnessPeriod() const
+  { return freshnessPeriod_; }
+  
+  void 
+  setFreshnessPeriod(Milliseconds freshnessPeriod)
+  { freshnessPeriod_ = freshnessPeriod; }
 
-  /**
-   * Set the metaInfoStruct to point to the values in this meta info object, without copying any memory.
-   * WARNING: The resulting pointers in metaInfoStruct are invalid after a further use of this object which could reallocate memory.
-   * @param metaInfoStruct a C ndn_MetaInfo struct where the name components array is already allocated.
-   */
-  void 
-  get(struct ndn_MetaInfo& metaInfoStruct) const;
-
-  /**
-   * Clear this meta info, and set the values by copying from the ndn_MetaInfo struct.
-   * @param metaInfoStruct a C ndn_MetaInfo struct
-   */
-  void 
-  set(const struct ndn_MetaInfo& metaInfoStruct);
-
-  MillisecondsSince1970 
-  getTimestampMilliseconds() const { return timestampMilliseconds_; }
-  
-  ndn_ContentType 
-  getType() const { return type_; }
-  
-  int 
-  getFreshnessSeconds() const { return freshnessSeconds_; }
-  
-  const Name::Component& 
-  getFinalBlockID() const { return finalBlockID_; }
-  
-  void 
-  setTimestampMilliseconds(MillisecondsSince1970 timestampMilliseconds) { timestampMilliseconds_ = timestampMilliseconds; }
-  
-  void 
-  setType(ndn_ContentType type) { type_ = type; }
-  
-  void 
-  setFreshnessSeconds(int freshnessSeconds) { freshnessSeconds_ = freshnessSeconds; }
-
-  void 
-  setFinalBlockID(const Name::Component& finalBlockID) { finalBlockID_ = finalBlockID; }
-    
 private:
-  MillisecondsSince1970 timestampMilliseconds_; /**< milliseconds since 1/1/1970. -1 for none */
-  ndn_ContentType type_;         /**< default is ndn_ContentType_DATA. -1 for none */
-  int freshnessSeconds_;         /**< -1 for none */
-  Name::Component finalBlockID_; /** size 0 for none */
+  uint32_t type_;
+  Milliseconds freshnessPeriod_;
+
+  Block wire_;
 };
   
 class Data {
@@ -119,31 +145,25 @@
   /**
    * Create a new Data object with default values and where the signature is a blank Sha256WithRsaSignature.
    */
-  Data();
+  Data()
+  {
+  }
 
   /**
    * Create a new Data object with the given name and default values and where the signature is a blank Sha256WithRsaSignature.
    * @param name A reference to the name which is copied.
    */
-  Data(const Name& name);
-  
-  /**
-   * The copy constructor: Create a deep copy of the given data object, including a clone of the signature object.
-   * @param data The data object to copy.
-   */
-  Data(const Data& data);
+  Data(const Name& name)
+    : name_(name)
+  {
+  }
   
   /**
    * The virtual destructor.
    */
-  virtual ~Data();
-  
-  /**
-   * The assignment operator: Copy fields and make a clone of the signature.
-   * @param data The other object to copy from.
-   * @return A reference to this object.
-   */
-  Data& operator=(const Data& data);
+  virtual ~Data()
+  {
+  }
   
   /**
    * Encode this Data for a particular wire format. If wireFormat is the default wire format, also set the defaultWireEncoding 
@@ -152,8 +172,11 @@
    * @param wireFormat A WireFormat object used to encode the input. If omitted, use WireFormat getDefaultWireFormat().
    * @return The encoded byte array.
    */
-  SignedBlob 
-  wireEncode(WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) const;
+  const Block& 
+  wireEncode() const;
+  
+  void
+  wireDecode(const Block &wire);
   
   /**
    * Decode the input using a particular wire format and update this Data. If wireFormat is the default wire format, also 
@@ -162,155 +185,127 @@
    * @param inputLength The length of input.
    * @param wireFormat A WireFormat object used to decode the input. If omitted, use WireFormat getDefaultWireFormat().
    */
-  void 
-  wireDecode(const uint8_t* input, size_t inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat());
-  
-  /**
-   * Decode the input using a particular wire format and update this Data. If wireFormat is the default wire format, also 
-   * set the defaultWireEncoding field to the input.
-   * @param input The input byte array to be decoded.
-   * @param wireFormat A WireFormat object used to decode the input. If omitted, use WireFormat getDefaultWireFormat().
-   */
-  void 
-  wireDecode(const std::vector<uint8_t>& input, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) 
+  void
+  wireDecode(const uint8_t* input, size_t inputLength);
+
+  const Signature&
+  getSignature() const
   {
-    wireDecode(&input[0], input.size(), wireFormat);
+    return signature_;
   }
   
   /**
-   * Set the dataStruct to point to the values in this interest, without copying any memory.
-   * WARNING: The resulting pointers in dataStruct are invalid after a further use of this object which could reallocate memory.
-   * @param dataStruct a C ndn_Data struct where the name components array is already allocated.
-   */
-  void 
-  get(struct ndn_Data& dataStruct) const;
-
-  /**
-   * Clear this data object, and set the values by copying from the ndn_Data struct.
-   * @param dataStruct a C ndn_Data struct
-   */
-  void 
-  set(const struct ndn_Data& dataStruct);
-
-  const Signature* 
-  getSignature() const { return signature_.get(); }
-  
-  Signature* 
-  getSignature() 
-  { 
-    // TODO: Should add an OnChanged listener instead of always calling onChanged.
-    onChanged();
-    return signature_.get(); 
-  }
-  
-  const Name& 
-  getName() const { return name_; }
-  
-  Name& 
-  getName() 
-  { 
-    // TODO: Should add an OnChanged listener instead of always calling onChanged.
-    onChanged();
-    return name_; 
-  }
-  
-  const MetaInfo& 
-  getMetaInfo() const { return metaInfo_; }
-  
-  MetaInfo& 
-  getMetaInfo() 
-  { 
-    // TODO: Should add an OnChanged listener instead of always calling onChanged.
-    onChanged();
-    return metaInfo_; 
-  }
-  
-  const Blob& 
-  getContent() const { return content_; }
-
-  /**
-   * Return a pointer to the defaultWireEncoding.  It may be null.
-   */
-  const SignedBlob&
-  getDefaultWireEncoding() const { return defaultWireEncoding_; }
-  
-  /**
    * Set the signature to a copy of the given signature.
    * @param signature The signature object which is cloned.
    * @return This Data so that you can chain calls to update values.
    */
   Data& 
   setSignature(const Signature& signature) 
-  { 
-    signature_ = signature.clone(); 
+  {
+    signature_ = signature;
     onChanged();
     return *this;
   }
   
+  const Name& 
+  getName() const
+  {
+    return name_;
+  }
+  
   /**
    * Set name to a copy of the given Name.  This is virtual so that a subclass can override to validate the name.
    * @param name The Name which is copied.
    * @return This Data so that you can chain calls to update values.
    */
-  virtual Data& 
-  setName(const Name& name);
+  void
+  setName(const Name& name)
+  { 
+    name_ = name; 
+    onChanged();
+  }
+  
+  const MetaInfo& 
+  getMetaInfo() const { return metaInfo_; }
   
   /**
    * Set metaInfo to a copy of the given MetaInfo.
    * @param metaInfo The MetaInfo which is copied.
    * @return This Data so that you can chain calls to update values.
    */
-  Data& 
+  void
   setMetaInfo(const MetaInfo& metaInfo) 
   { 
     metaInfo_ = metaInfo; 
     onChanged();
-    return *this;
   }
 
+  const Block& 
+  getContent() const { return content_; }
+
   /**
    * Set the content to a copy of the data in the vector.
    * @param content A vector whose contents are copied.
    * @return This Data so that you can chain calls to update values.
    */
-  Data& 
+  void
   setContent(const std::vector<uint8_t>& content) 
-  { 
-    content_ = content; 
+  {
+    setContent(&content[0], content.size());
     onChanged();
-    return *this;
   }
   
-  Data& 
+  void
   setContent(const uint8_t* content, size_t contentLength) 
-  { 
-    content_ = Blob(content, contentLength); 
+  {
+    OBufferStream os;
+    Tlv::writeVarNumber(os, Tlv::Content);
+    Tlv::writeVarNumber(os, contentLength);
+    os.write(reinterpret_cast<const char *>(content), contentLength);
+    
+    content_ = Block(os.buf());
     onChanged();
-    return *this;
   }
-      
-  Data& 
-  setContent(const Blob& content) 
+
+  void
+  setContent(const ConstBufferPtr &contentValue)
+  {
+    content_ = Block(Tlv::Content, contentValue); // not real a wire encoding yet
+    onChanged();
+  }
+  
+  void
+  setContent(const Block& content) 
   { 
     content_ = content;
     onChanged();
-    return *this;
   }
 
 private:
   /**
    * Clear the wire encoding.
    */
-  void 
+  inline void 
   onChanged();
-  
-  ptr_lib::shared_ptr<Signature> signature_;
+
+private:
   Name name_;
   MetaInfo metaInfo_;
-  Blob content_;
-  SignedBlob defaultWireEncoding_;
+  Block content_;
+  Signature signature_;
+
+  Block wire_;
 };
-  
+
+
+inline void 
+Data::onChanged()
+{
+  // The values have changed, so the signature and wire format is invalidated
+  signature_.reset();
+  wire_.reset();
 }
 
+} // namespace ndn
+
 #endif
diff --git a/include/ndn-cpp/key-locator.hpp b/include/ndn-cpp/key-locator.hpp
index 5c1f6c1..f6c6f9d 100644
--- a/include/ndn-cpp/key-locator.hpp
+++ b/include/ndn-cpp/key-locator.hpp
@@ -8,88 +8,71 @@
 #ifndef NDN_KEY_LOCATOR_HPP
 #define NDN_KEY_LOCATOR_HPP
 
-#include <vector>
-#include "c/key-types.h"
+#include "encoding/tlv-element.hpp"
 #include "name.hpp"
 
-struct ndn_KeyLocator;
-
 namespace ndn {
-  
+
+namespace error {
+struct KeyLocator : public std::runtime_error { KeyLocator(const std::string &what) : std::runtime_error(what) {} };
+} // error
+
 class KeyLocator {
 public:
+  enum {
+    KeyLocator_None = -1,
+    KeyLocator_Name = 0
+  };
+  
   KeyLocator()
-  : type_((ndn_KeyLocatorType)-1), keyNameType_((ndn_KeyNameType)-1)
+    : type_(KeyLocator_None)
   {
   }
-  
-  /**
-   * Clear the keyData and set the type to none.
-   */
-  void 
-  clear()
-  {
-    type_ = (ndn_KeyLocatorType)-1;
-    keyNameType_ = (ndn_KeyNameType)-1;
-    keyData_.reset();
-  }
-  
-  /**
-   * Set the keyLocatorStruct to point to the values in this key locator, without copying any memory.
-   * WARNING: The resulting pointers in keyLocatorStruct are invalid after a further use of this object which could reallocate memory.
-   * @param keyLocatorStruct a C ndn_KeyLocator struct where the name components array is already allocated.
-   */
-  void 
-  get(struct ndn_KeyLocator& keyLocatorStruct) const;
-  
-  /**
-   * Clear this key locator, and set the values by copying from the ndn_KeyLocator struct.
-   * @param keyLocatorStruct a C ndn_KeyLocator struct
-   */
-  void 
-  set(const struct ndn_KeyLocator& keyLocatorStruct);
 
-  ndn_KeyLocatorType 
+  inline bool
+  empty() const
+  {
+    return type_ == KeyLocator_None;
+  }
+  
+  uint32_t 
   getType() const { return type_; }
   
-  const Blob& 
-  getKeyData() const { return keyData_; }
-
-  const Name& 
-  getKeyName() const { return keyName_; }
-  
-  Name& 
-  getKeyName() { return keyName_; }
-
-  ndn_KeyNameType 
-  getKeyNameType() const { return keyNameType_; }
-
   void 
-  setType(ndn_KeyLocatorType type) { type_ = type; }
+  setType(uint32_t type) { type_ = type; }
     
+  const Block& 
+  getValue() const { return value_; }
+
   void 
-  setKeyData(const Blob& keyData) { keyData_ = keyData; }
+  setValue(const Block &value) { value_ = value; }
+
+  ////////////////////////////////////////////////////////
+  // Helper methods for different types of key locators
+  //
+  // For now only Name type is actually supported
+  
+  Name
+  getName() const
+  {
+    if (type_ != KeyLocator_Name)
+      throw error::KeyLocator("Requested Name, but KeyLocator is not of the Name type");
+
+    return Name(getValue());
+  }
 
   void
-  setKeyName(const Name &keyName) { keyName_ = keyName; }
+  setName(const Name &name)
+  {
+    type_ = KeyLocator_Name;
+    value_ = name.wireEncode();
+  }
   
-  void 
-  setKeyNameType(ndn_KeyNameType keyNameType) { keyNameType_ = keyNameType; }
-
 private:
-  ndn_KeyLocatorType type_; /**< -1 for none */
-  Blob keyData_; /**< An array for the key data as follows:
-    *   If type_ is ndn_KeyLocatorType_KEY, the key data.
-    *   If type_ is ndn_KeyLocatorType_CERTIFICATE, the certificate data. 
-    *   If type_ is ndn_KeyLocatorType_KEYNAME and keyNameType_ is ndn_KeyNameType_PUBLISHER_PUBLIC_KEY_DIGEST, the publisher public key digest. 
-    *   If type_ is ndn_KeyLocatorType_KEYNAME and keyNameType_ is ndn_KeyNameType_PUBLISHER_CERTIFICATE_DIGEST, the publisher certificate digest. 
-    *   If type_ is ndn_KeyLocatorType_KEYNAME and keyNameType_ is ndn_KeyNameType_PUBLISHER_ISSUER_KEY_DIGEST, the publisher issuer key digest. 
-    *   If type_ is ndn_KeyLocatorType_KEYNAME and keyNameType_ is ndn_KeyNameType_PUBLISHER_ISSUER_CERTIFICATE_DIGEST, the publisher issuer certificate digest. 
-                                */
-  Name keyName_;                /**< The key name (only used if type_ is ndn_KeyLocatorType_KEYNAME.) */
-  ndn_KeyNameType keyNameType_; /**< The type of data for keyName_, -1 for none. (only used if type_ is ndn_KeyLocatorType_KEYNAME.) */
+  uint32_t type_;
+  Block value_;
 };
-  
+
 }
 
 #endif
diff --git a/include/ndn-cpp/publisher-public-key-digest.hpp b/include/ndn-cpp/publisher-public-key-digest.hpp
deleted file mode 100644
index 289e682..0000000
--- a/include/ndn-cpp/publisher-public-key-digest.hpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
- * See COPYING for copyright and distribution information.
- */
-
-#ifndef NDN_PUBLISHERPUBLICKEYDIGEST_HPP
-#define NDN_PUBLISHERPUBLICKEYDIGEST_HPP
-
-#include <vector>
-#include "common.hpp"
-#include "util/blob.hpp"
-
-struct ndn_PublisherPublicKeyDigest;
-
-namespace ndn {
-  
-/**
- * A PublisherPublicKeyDigest holds the publisher public key digest value, if any.
- * We make a separate class since this is used by multiple other classes.
- */
-class PublisherPublicKeyDigest {
-public:    
-  PublisherPublicKeyDigest() {
-  }
-  
-  /**
-   * Set the publisherPublicKeyDigestStruct to point to the entries in this PublisherPublicKeyDigest, without copying any memory.
-   * WARNING: The resulting pointers in publisherPublicKeyDigestStruct are invalid after a further use of this object which could reallocate memory.
-   * @param publisherPublicKeyDigestStruct a C ndn_PublisherPublicKeyDigest struct to receive the pointer
-   */
-  void 
-  get(struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct) const;
-  
-  /**
-   * Clear this PublisherPublicKeyDigest, and copy from the ndn_PublisherPublicKeyDigest struct.
-   * @param excludeStruct a C ndn_Exclude struct
-   */
-  void 
-  set(const struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct);
-
-  const Blob& 
-  getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
-
-  void 
-  setPublisherPublicKeyDigest(const Blob& publisherPublicKeyDigest) { publisherPublicKeyDigest_ = publisherPublicKeyDigest; }
-  
-  /**
-   * Clear the publisherPublicKeyDigest.
-   */
-  void 
-  clear()
-  {
-    publisherPublicKeyDigest_.reset();
-  }
-
-private:
-  Blob publisherPublicKeyDigest_;
-};
-  
-}
-
-#endif
diff --git a/include/ndn-cpp/sha256-with-rsa-signature.hpp b/include/ndn-cpp/sha256-with-rsa-signature.hpp
deleted file mode 100644
index d2e5374..0000000
--- a/include/ndn-cpp/sha256-with-rsa-signature.hpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
- * See COPYING for copyright and distribution information.
- */
-
-#ifndef NDN_SHA256_WITH_RSA_SIGNATURE_HPP
-#define NDN_SHA256_WITH_RSA_SIGNATURE_HPP
-
-#include "data.hpp"
-#include "key-locator.hpp"
-#include "publisher-public-key-digest.hpp"
-
-namespace ndn {
-
-/**
- * A Sha256WithRsaSignature extends Signature and holds the signature bits and other info representing a
- * SHA256-with-RSA signature in a data packet.
- */
-class Sha256WithRsaSignature : public Signature {
-public:
-  /**
-   * Return a pointer to a new Sha256WithRsaSignature which is a copy of this signature.
-   */
-  virtual ptr_lib::shared_ptr<Signature> 
-  clone() const;
-
-  /**
-   * Set the signatureStruct to point to the values in this signature object, without copying any memory.
-   * WARNING: The resulting pointers in signatureStruct are invalid after a further use of this object which could reallocate memory.
-   * @param signatureStruct a C ndn_Signature struct where the name components array is already allocated.
-   */
-  virtual void 
-  get(struct ndn_Signature& signatureStruct) const;
-
-  /**
-   * Clear this signature, and set the values by copying from the ndn_Signature struct.
-   * @param signatureStruct a C ndn_Signature struct
-   */
-  virtual void 
-  set(const struct ndn_Signature& signatureStruct);
-
-  const Blob& 
-  getDigestAlgorithm() const { return digestAlgorithm_; }
-
-  const Blob& 
-  getWitness() const { return witness_; }
-
-  const Blob& 
-  getSignature() const { return signature_; }
-  
-  const PublisherPublicKeyDigest& 
-  getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
-  
-  PublisherPublicKeyDigest& 
-  getPublisherPublicKeyDigest() { return publisherPublicKeyDigest_; }
-  
-  const KeyLocator& 
-  getKeyLocator() const { return keyLocator_; }
-  
-  KeyLocator& 
-  getKeyLocator() { return keyLocator_; }
-
-  void 
-  setDigestAlgorithm(const Blob& digestAlgorithm) { digestAlgorithm_ = digestAlgorithm; }
-
-  void 
-  setWitness(const Blob& witness) { witness_ = witness; }
-
-  void 
-  setSignature(const Blob& signature) { signature_ = signature; }
-
-  void 
-  setPublisherPublicKeyDigest(const PublisherPublicKeyDigest& publisherPublicKeyDigest) { publisherPublicKeyDigest_ = publisherPublicKeyDigest; }
-  
-  void 
-  setKeyLocator(const KeyLocator& keyLocator) { keyLocator_ = keyLocator; }
-  
-  /**
-   * Clear all the fields.
-   */
-  void 
-  clear()
-  {
-    digestAlgorithm_.reset();
-    witness_.reset();
-    signature_.reset();
-    publisherPublicKeyDigest_.clear();
-    keyLocator_.clear();
-  }
-
-private:
-  Blob digestAlgorithm_; /**< if empty, the default is 2.16.840.1.101.3.4.2.1 (sha-256) */
-  Blob witness_;
-  Blob signature_;
-  PublisherPublicKeyDigest publisherPublicKeyDigest_;
-  KeyLocator keyLocator_;
-};
-
-}
-
-#endif
