I have a struct where merkleTree.MerkleProof is an interface which is implemented by mTree.Proof:
type Checkpoint struct {
Leaves []Leaf
MerkleProof merkleTree.MerkleProof
}
type MerkleProof interface {
Verify(leafHash, treeRoot []byte)
}
type Proof struct {
Hashes [][]byte
Path []byte
}
I am encoding a Checkpoint struct (with a Proof struct in the MerkleProof field) to a file with JSON or Gob and everything goes smoothly; the data is encoded correctly.
"Proof": {
"Hashes": [
"f8kfN1YkWAwRpj1wbX2izMGC5DbHel//d5y5hceamAc="
],
"Path": "AA=="
}
When I go to decode the same encoded data I get the following error:
json: cannot unmarshal object into Go struct field Checkpoint.MerkleProof of type merkleTree.MerkleProof
Gob gives a similar error. How do I get the decoders to recognize that the Proof struct implement MerkleProof and can be stored in the field?