Anchor Service

Anchor Service continuously anchors hashes to blockchains, which is similar to what Chainpoint does, but with much better performance and flexibility. It supports multiple anchor types and proof formats. Digital signing can be also done at the Merkle root level

Protobuf definition: anchor/anchor.proto

Table of Contents

AnchorService

Method NameRequest TypeResponse TypeDescription
GetAnchorsgoogle.protobuf.EmptyAnchor streamGetAnchors gets all anchors
GetAnchorAnchorRequestAnchorGetAnchor gets an anchor
GetProofProofRequestProofGetProof gets a proof
SubmitProofSubmitProofRequestProofSubmitProof submits a proof for the given hash
VerifyProofVerifyProofRequestVerifyProofReplyVerifyProof verifies the given proof. When the proof is unverifiable, an exception is thrown
GetBatchBatchRequestBatchGetBatch gets a batch
SubscribeBatchesSubscribeBatchesRequestBatch streamSubscribeBatches subscribes to batch status updates

Anchor

Anchor represents an anchor of a blockchain, through which a hash can be anchored to that blockchain

FieldTypeLabelDescription
typeAnchor.TypeType is the anchor type
statusAnchor.StatusStatus is the anchor status
errorstringError is the error message when the anchor status is ERROR
supported_formatsProof.FormatrepeatedSupportedFormats are the supported proof formats of the anchor

AnchorRequest

AnchorRequest represents a request to get information for the given anchor type

FieldTypeLabelDescription
typeAnchor.TypeType is the anchor type

Batch

Batch represents a batch of hashes. When hash stream comes in, Anchor Service will try to process them in batches, just like blockchain processes transactions in blocks. This makes utilization of expensive resources, such as making Bitcoin transaction, more economic. Each batch's root hash will be embedded in a transaction made to the blockchain

FieldTypeLabelDescription
idstringId is the batch ID
anchor_typeAnchor.TypeAnchorType is the batch's anchor type
proof_formatProof.FormatProofFormat is the batch's proof format, which determines how the merkle tree is constructed for the batch.
statusBatch.StatusStatus is the batch status. FLOW: created_at -> BATCHING -> flushed_at -> QUEUING -> started_at -> PROCESSING -> submitted_at -> PENDING -> finalized_at -> CONFIRMED / ERROR; * -> ERROR; if a batch has not yet reached PENDING and its anchor has restarted, the batch will be put back to QUEUING
errorstringError is the error message when status is ERROR
sizeint64Size is the number of hashes contained in the batch
created_atgoogle.protobuf.TimestampCreateAt is the batch's created at timestamp. FLOW: created_at -> BATCHING
flushed_atgoogle.protobuf.TimestampFlushedAt is the batch's flushed at timestamp. FLOW: BATCHING -> flushed_at -> QUEUING
started_atgoogle.protobuf.TimestampStartedAt is the batch's started at timestamp. FLOW: QUEUING -> started_at -> PROCESSING
submitted_atgoogle.protobuf.TimestampSubmittedAt is the batch's submitted at timestamp. FLOW: PROCESSING -> submitted_at -> PENDING
finalized_atgoogle.protobuf.TimestampFinalizedAt is the batch's finalized at timestamp. FLOW: * -> finalized_at -> CONFIRMED / ERROR. NOTE: this is not the real block confirmed time, use the timestamp in the batch data instead
hashstringHash is the batch's root hash
datastringData is the batch data in JSON

BatchRequest

BatchRequest represents a batch request

FieldTypeLabelDescription
batch_idstringBatchId is the batch ID
anchor_typeAnchor.TypeAnchorType is the batch's anchor type

Proof

Proof represents a blockchain proof of a hash, which is a Merkle path from the hash to the root hash of the proof's batch

FieldTypeLabelDescription
hashstringHash is the hash the proof is proving for
batch_idstringBatchId is the proof's batch ID
anchor_typeAnchor.TypeAnchorType is the proof's anchor type
batch_statusBatch.StatusBatchStatus is the proof's batch status
formatProof.FormatFormat is the proof format
datastringData is the proof data in base64
batchBatchBatch is the proof's batch detail

ProofRequest

ProofRequest represents a proof request

FieldTypeLabelDescription
hashstringHash is the hash the proof is proving for
batch_idstringBatchId is the proof's batch ID
anchor_typeAnchor.TypeAnchorType is the proof's anchor type
with_batchboolWithBatch indicates whether to include the proof's batch detail

SubmitProofRequest

SubmitProofRequest represents a submit proof request

FieldTypeLabelDescription
hashstringHash is the hash to be submitted
anchor_typeAnchor.TypeAnchorType is the anchor type to be used
formatProof.FormatFormat is the proof format to be used
skip_batchingboolSkipBatching indicates whether to skip batching and submit a proof for the hash directly
with_batchboolWithBatch indicates whether to include the batch detail in the reply

SubscribeBatchesRequest

SubscribeBatchesRequest represents a subscription request for batch information

FieldTypeLabelDescription
filterBatchRequestFilter is the batch filter. When nil, all batches of all anchors will be subscribed; otherwise, only the batches of the given anchor will be subscribed; if batch_id is non-empty, only the matched batch will be subscribed

VerifyProofReply

VerifyProofReply represents a verify proof reply

FieldTypeLabelDescription
verifiedboolVerified indicates whether the proof is verified
errorstringErorr is the error message when the proof is falsified
provenHashstringProvenHash is the hash the proof is proving for

VerifyProofRequest

VerifyProofRequest represents a verify proof request

FieldTypeLabelDescription
anchor_typeAnchor.TypeAnchorType is the proof's anchor type
formatProof.FormatFormat is the proof format. If skipping the signature checking is desired, please use the corresponding non-signed format, eg. use CHP_PATH instead of CHP_PATH_SIGNED in request
datastringData is the proof data in base64

Anchor.Status

Status represents an anchor's status

NameNumberDescription
ERROR0Error means the anchor has an error
STOPPED1STOPPED means the anchor is stopped
RUNNING2RUNNING means the anchor is running

Anchor.Type

Type represents an anchor type. Please refer to this list for all available anchor types

NameNumberDescription
ETH0Ethereum Rinkeby Testnet
ETH_MAINNET3Ethereum Mainnet. Ethereum is the second-largest cryptocurrency
ETH_ELASTOS4Elastos, which employs a "main chain-sidechain architecture"
ETH_GOCHAIN9GoChain, which is scalable, low cost and energy efficient
BTC1Bitcoin Testnet
BTC_MAINNET5Bitcoin Mainnet. Bitcoin is the largest cryptocurrency
CHP2Chainpoint
HEDERA6Hedera Testnet
HEDERA_MAINNET7Hedera Mainnet. Hedera is a DAG based blockchain that provides much better TPS than tranditional blockchains
HYPERLEDGER8Hyperledger Fabric, which is a modular blockchain framework for private enterprises

Batch.Status

Status represents a batch's status

NameNumberDescription
ERROR0ERROR means the batch has an error. FLOW: * -> ERROR
BATCHING1BATCHING means the batch is batching for more hashes. FLOW: created_at -> BATCHING -> flushed_at
QUEUING2QUEUING means the batch is queuing to be processed. FLOW: flushed_at -> QUEUING -> started_at
PROCESSING3PROCESSING means the batch is constructing merkle roots and submitting hashes. FLOW: started_at -> PROCESSING -> submitted_at
PENDING4PENDING means the batch's root hash is pending to be confirmed. FLOW: submitted_at -> PENDING -> finalized_at
CONFIRMED5CONFIRMED means the batch's root hash is confirmed by the anchor's blockchain. FLOW: finalized_at -> CONFIRMED

Proof.Format

Format represents a proof format

NameNumberDescription
CHP_PATH0CHP_PATH means Chainpoint Path format, which is the format used by Chainpoint
ETH_TRIE1ETH_TRIE means Ethereum Trie format
CHP_PATH_SIGNED2CHP_PATH_SIGNED means signed Chainpoint Path format
ETH_TRIE_SIGNED3ETH_TRIE_SIGNED means signed Ethereum Trie format

Scalar Value Types

.proto TypeNotesC++JavaPythonGoC#PHPRuby
doubledoubledoublefloatfloat64doublefloatFloat
floatfloatfloatfloatfloat32floatfloatFloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intintint32intintegerBignum or Fixnum (as required)
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/longint64longinteger/stringBignum
uint32Uses variable-length encoding.uint32intint/longuint32uintintegerBignum or Fixnum (as required)
uint64Uses variable-length encoding.uint64longint/longuint64ulonginteger/stringBignum or Fixnum (as required)
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intintint32intintegerBignum or Fixnum (as required)
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/longint64longinteger/stringBignum
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intintuint32uintintegerBignum or Fixnum (as required)
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/longuint64ulonginteger/stringBignum
sfixed32Always four bytes.int32intintint32intintegerBignum or Fixnum (as required)
sfixed64Always eight bytes.int64longint/longint64longinteger/stringBignum
boolboolbooleanbooleanboolboolbooleanTrueClass/FalseClass
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicodestringstringstringString (UTF-8)
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr[]byteByteStringstringString (ASCII-8BIT)