Lightweight base package for provenance data "providers" and "consumers".
Packages with types that would like to provide custom provenance data for their
types should extend the provenance function for their types.
using ProvenanceBase
struct MyType
# ...
end
ProvenanceBase.provenance(t::MyType) = (my = "provenance", data = "!")The provenance method must return a NamedTuple containing the associated
provenance data.
Packages that wish to consume provenance data from other providers should
extend signature and provide a subtype of AbstractSignature to "sign" the
consumed provenance data:
using ProvenanceBase, Serialization, SHA
struct CustomSignature <: ProvenanceBase.AbstractSignature
str::String
end
function ProvenanceBase.signature(::Type{CustomSignature}, object, timestamp, data)
io = IOBuffer()
serialize(io, (object, timestamp, data))
return CustomSignature(bytes2hex(sha2_256(seekstart(io))))
endWhether the "signing" is a strong cryptographic signature or a simple content
hash is up to the package extending signature.
Time-stamped provenance data associated with a particular object can be
generated by calling Provenance(object) or Provenance(object, T) where T
is your custom subtype of AbstractSignature.