Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce hash addressable content interface #5

Closed
loongy opened this issue May 12, 2020 · 1 comment
Closed

Introduce hash addressable content interface #5

loongy opened this issue May 12, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@loongy
Copy link
Contributor

loongy commented May 12, 2020

It is common, when using this library, that someone wants to use a hash to uniquely identify an object (for example, a block in a blockchain). However, this is not always the same as the hash of the bytes of the marshaled object (blocks in blockchains contain signatures, but you cannot include these when hashing a block so that you can sign it, because this is a recursive definition with no terminal case).

This library should define an interface that can be implemented by any type that knows how to convert itself to a hash. By convention, this hash is used to uniquely identify the object, and used to sign the object (prove authenticity). It does not have to be the same as the hash of the marshaled object.

type Content interface {
    Hash() Hash
}
@loongy loongy added the enhancement New feature or request label May 12, 2020
@loongy loongy self-assigned this May 12, 2020
@loongy loongy closed this as completed Jun 18, 2020
@loongy
Copy link
Contributor Author

loongy commented Jun 18, 2020

We ended up with

type Content interface {
    surge.Marshaler
    Hash() (Hash, error)
}

and the supporting helper type

type Blob struct { .. }

for types where the hash is known to be a hash of the binary representation (this is often the case, but should not be assumed to be the case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant