Documentation
¶
Overview ¶
Package chainpoint provides functionality to access the Chainpoint Node API.
A Chainpoint Node allows anyone to run a server that accepts hashes, anchors them to public blockchains, creates and verifies proofs, and participates in the Chainpoint Network.
Index ¶
- Constants
- func IsPerm(err error) bool
- func IsTemporary(err error) bool
- func Marshal(v interface{}) ([]byte, error)
- func Unmarshal(data []byte, v interface{}) error
- type Anchor
- type Branch
- type CalendarResponse
- type Chainpoint
- type ConfigResponse
- type Error
- type HashItem
- type OpEnum
- type Operation
- type ParsedAnchor
- type ParsedBranch
- type ParsedChainpoint
- type PostHash
- type ProcessingHints
- type Proof
- type Service
- func (s *Service) Calendar(ctx context.Context, uri, height string) (*CalendarResponse, error)
- func (s *Service) CalendarData(ctx context.Context, uri, height string) (string, error)
- func (s *Service) CalendarHash(ctx context.Context, uri, height string) (string, error)
- func (s *Service) Config(ctx context.Context, uri string) (*ConfigResponse, error)
- func (s *Service) Hashes(ctx context.Context, uri string, hashes []string) (*PostHash, error)
- func (s *Service) Proofs(ctx context.Context, nodeURI string, proofIDs []string, contentType ...string) ([]*Proof, error)
- func (s *Service) Verify(ctx context.Context, uri string, proofs []*Chainpoint) ([]*VerifyResponse, error)
- type Time
- type VerifyResponse
- type VerifyResponseAnchor
Constants ¶
const ( // ChpContext is the value for Chainpoint.Context ChpContext = "https://w3id.org/chainpoint/v4" // ChpType is the value for Chainpoint.Type ChpType = "Chainpoint" )
const ( AnchorCal = "cal" AnchorBTC = "btc" AnchorETH = "eth" AnchorTCal = "tcal" AnchorTBTC = "tbtc" )
Anchors ...
const ( ContentTypeJSON = "application/vnd.chainpoint.ld+json" ContentTypeBase64 = "application/vnd.chainpoint.json+base64" )
ContentTypes supported in responses.
const UserAgent = "Chainpoint Node API Go Client"
UserAgent is the header string used to identify this package.
Variables ¶
This section is empty.
Functions ¶
func IsTemporary ¶
IsTemporary gets a value indicating whether the error is a temporary error.
Types ¶
type Anchor ¶
type Anchor struct {
Type string `json:"type"`
AnchorID string `json:"anchor_id"`
URIs []string `json:"uris,omitempty"`
}
Anchor ...
type Branch ¶
type Branch struct {
Label string `json:"label,omitempty"`
Branches []Branch `json:"branches,omitempty"`
Ops []Operation `json:"ops"`
}
Branch ...
type CalendarResponse ¶
type CalendarResponse struct {
ID int `json:"id"`
Time int `json:"time"`
Version int `json:"version"`
StackID string `json:"stackId"`
Type string `json:"type"`
DataID string `json:"dataId"`
DataVal string `json:"dataVal"`
PrevHash string `json:"prevHash"`
Hash string `json:"hash"`
Sig string `json:"sig"`
}
CalendarResponse ...
type Chainpoint ¶
type Chainpoint struct {
Context string `json:"@context"`
Type string `json:"type"`
Hash string `json:"hash"`
ProofID string `json:"proof_id"`
HashReceived Time `json:"hash_received"`
Branches []Branch `json:"branches"`
}
Chainpoint ...
func (*Chainpoint) MarshalBinary ¶
func (chp *Chainpoint) MarshalBinary() ([]byte, error)
MarshalBinary ...
func (*Chainpoint) UnmarshalBinary ¶
func (chp *Chainpoint) UnmarshalBinary(proof []byte) error
UnmarshalBinary unmarshales text into the Chainpoint structure.
func (*Chainpoint) Valid ¶
func (chp *Chainpoint) Valid() bool
Valid returns a value indicating whether the Chainpoint is valid.
type ConfigResponse ¶
type ConfigResponse struct {
Version string `json:"version"`
ProofExpireMinutes int `json:"proof_expire_minutes"`
GetProofsMaxRest int `json:"get_proofs_max_rest"`
PostHashesMax int `json:"post_hashes_max"`
PostVerifyProofsMax int `json:"post_verify_proofs_max"`
Time time.Time `json:"time"`
Calendar struct {
Height int `json:"height"`
AuditResponse string `json:"audit_response"`
} `json:"calendar"`
}
ConfigResponse ...
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error response from Chainpoint APIs.
type OpEnum ¶
type OpEnum string
OpEnum ...
const ( OpUnknown OpEnum = "" OpSHA224 OpEnum = "sha-224" OpSHA256 OpEnum = "sha-256" OpSHA384 OpEnum = "sha-384" OpSHA512 OpEnum = "sha-512" OpSHA3224 OpEnum = "sha3-224" OpSHA3256 OpEnum = "sha3-256" OpSHA3384 OpEnum = "sha3-384" OpSHA3512 OpEnum = "sha3-512" OpSHA256x2 OpEnum = "sha-256-x2" )
OpEnums introduced by package chainpoint.
type Operation ¶
type Operation struct {
L string `json:"l,omitempty"`
R string `json:"r,omitempty"`
Op OpEnum `json:"op,omitempty"`
Anchors []Anchor `json:"anchors,omitempty"`
}
Operation ...
type ParsedAnchor ¶
ParsedAnchor ...
type ParsedBranch ¶
type ParsedBranch struct {
Label string
Branches []ParsedBranch
Anchors []ParsedAnchor
OpReturnValue string
BTCTxID string
}
ParsedBranch ...
type ParsedChainpoint ¶
type ParsedChainpoint struct {
Hash string
ProofID string
HashReceived Time
Branches []ParsedBranch
}
ParsedChainpoint ...
type PostHash ¶
type PostHash struct {
URI string `json:"uri,omitempty"`
Meta struct {
SubmittedAt time.Time `json:"submitted_at"`
ProcessingHints ProcessingHints `json:"processing_hints"`
} `json:"meta"`
Hashes []HashItem `json:"hashes"`
}
PostHash ...
type ProcessingHints ¶
ProcessingHints ...
type Proof ¶
type Proof struct {
ProofID string `json:"proof_id"` // The Version 1 UUID used to retrieve the proof.
Proof json.RawMessage `json:"proof"` // The JSON or Base64 encoded binary form of the proof.
AnchorsCompleted []string `json:"anchors_complete"` // An Array that indicates which blockchains the proof is anchored to at the time of retrieval.
}
Proof ...
type Service ¶
type Service struct {
UserAgent string // optional additional User-Agent fragment
// contains filtered or unexported fields
}
A Service is a Chainpoint Node API client.
func (*Service) CalendarData ¶
CalendarData retrieves the calendar block data_val at the given height.
func (*Service) CalendarHash ¶
CalendarHash retrieves the calendar block hash at the given height.
func (*Service) Hashes ¶
Hashes submits one or more hashes to one Node, returning an array of proof handle objects, one for each submitted hash.
func (*Service) Proofs ¶
func (s *Service) Proofs(ctx context.Context, nodeURI string, proofIDs []string, contentType ...string) ([]*Proof, error)
Proofs retrieves a collection of proofs for one or more hash IDs from the specified Node URI.
func (*Service) Verify ¶
func (s *Service) Verify(ctx context.Context, uri string, proofs []*Chainpoint) ([]*VerifyResponse, error)
Verify submits one or more proofs for verification.
type VerifyResponse ¶
type VerifyResponse struct {
ProofIndex int `json:"proof_index"`
Hash string `json:"hash"`
HashCore string `json:"hash_core"`
HashReceived time.Time `json:"hash_received"`
Anchors []VerifyResponseAnchor `json:"anchors"`
Status string `json:"status"`
}
VerifyResponse ...
type VerifyResponseAnchor ¶
type VerifyResponseAnchor struct {
Branch string `json:"branch"`
Type string `json:"type"`
Valid bool `json:"valid"`
}
VerifyResponseAnchor ...