Documentation ¶
Overview ¶
Package bbclib is a library for defining BBcTransaction. This also provides serializer/deserializer and utilities for BBcTransaction object manipulation.
Serialization and deserialization ¶
A BBcTransaction object contains various object, such as BBcEvent, BBcSignature. In order to store a BBcTransaction object in DB or send it to other host, the object must be serialized. Before serialization, the object is packed, meaning that it is transformed into binary format. Then, the header is prepended to the packed data, resulting in a serialized data. According to the header value, the packed data is compressed, so that you will get a smaller-sized serialized data. Deserialization is the opposite transformation to serialization.
Utility functions ¶
To build a BBcTransaction you need to create (new) objects you want to include. In many cases, it is a kind of common coding manner. The utility functions are helpers to build a BBcTransaction with various objects.
Index ¶
- Constants
- func AddEventAssetBodyObject(transaction *BBcTransaction, eventIdx int, assetGroupID, userID *[]byte, ...)
- func AddEventAssetBodyString(transaction *BBcTransaction, eventIdx int, assetGroupID, userID *[]byte, ...)
- func AddEventAssetFile(transaction *BBcTransaction, eventIdx int, assetGroupID, userID *[]byte, ...)
- func AddPointerInRelation(relation *BBcRelation, refTransaction *BBcTransaction, refAssetID *[]byte)
- func AddReference(transaction *BBcTransaction, assetGroupID *[]byte, ...)
- func AddRelationAssetBodyObject(transaction *BBcTransaction, relationIdx int, assetGroupID, userID *[]byte, ...)
- func AddRelationAssetBodyString(transaction *BBcTransaction, relationIdx int, assetGroupID, userID *[]byte, ...)
- func AddRelationAssetFile(transaction *BBcTransaction, relationIdx int, ...)
- func AddRelationPointer(transaction *BBcTransaction, relationIdx int, ...)
- func Get2byte(buf *bytes.Buffer) (uint16, error)
- func Get4byte(buf *bytes.Buffer) (uint32, error)
- func Get8byte(buf *bytes.Buffer) (int64, error)
- func GetBigInt(buf *bytes.Buffer) ([]byte, error)
- func GetBytes(buf *bytes.Buffer, length int) ([]byte, error)
- func GetIdentifier(seed string, length int) []byte
- func GetIdentifierWithTimestamp(seed string, length int) []byte
- func GetRandomValue(length int) []byte
- func Put2byte(buf *bytes.Buffer, val uint16)
- func Put4byte(buf *bytes.Buffer, val uint32)
- func Put8byte(buf *bytes.Buffer, val int64)
- func PutBigInt(buf *bytes.Buffer, val *[]byte, length int)
- func Serialize(transaction *BBcTransaction, formatType uint16) ([]byte, error)
- func SignToTransaction(transaction *BBcTransaction, userID *[]byte, keypair *KeyPair)
- func VerifyBBcSignature(digest []byte, sig *BBcSignature) bool
- func ZlibCompress(dat *[]byte) []byte
- func ZlibDecompress(dat []byte) ([]byte, error)
- type BBcAsset
- func (p *BBcAsset) Add(userID *[]byte)
- func (p *BBcAsset) AddBodyObject(bodyContent interface{}) error
- func (p *BBcAsset) AddBodyString(bodyContent string)
- func (p *BBcAsset) AddFile(fileContent *[]byte)
- func (p *BBcAsset) Digest() []byte
- func (p *BBcAsset) GetBodyObject() (interface{}, error)
- func (p *BBcAsset) Pack() ([]byte, error)
- func (p *BBcAsset) Stringer() string
- func (p *BBcAsset) Unpack(dat *[]byte) error
- type BBcCrossRef
- type BBcEvent
- func (p *BBcEvent) Add(assetGroupID *[]byte, asset *BBcAsset)
- func (p *BBcEvent) AddMandatoryApprover(userID *[]byte)
- func (p *BBcEvent) AddOptionApprover(userID *[]byte)
- func (p *BBcEvent) AddOptionParams(numerator int, denominator int)
- func (p *BBcEvent) AddReferenceIndex(relIndex int)
- func (p *BBcEvent) Pack() ([]byte, error)
- func (p *BBcEvent) Stringer() string
- func (p *BBcEvent) Unpack(dat *[]byte) error
- type BBcPointer
- type BBcReference
- func (p *BBcReference) Add(assetGroupID *[]byte, refTransaction *BBcTransaction, eventIdx int)
- func (p *BBcReference) AddApprover(userID *[]byte) error
- func (p *BBcReference) AddSignature(userID *[]byte, sig *BBcSignature) error
- func (p *BBcReference) Pack() ([]byte, error)
- func (p *BBcReference) SetTransaction(txobj *BBcTransaction)
- func (p *BBcReference) Stringer() string
- func (p *BBcReference) Unpack(dat *[]byte) error
- type BBcRelation
- type BBcSignature
- func (p *BBcSignature) Pack() ([]byte, error)
- func (p *BBcSignature) SetPublicKey(keyType uint32, pubkey *[]byte)
- func (p *BBcSignature) SetPublicKeyByKeypair(keypair *KeyPair)
- func (p *BBcSignature) SetSignature(sig *[]byte)
- func (p *BBcSignature) Stringer() string
- func (p *BBcSignature) Unpack(dat *[]byte) error
- func (p *BBcSignature) Verify(digest []byte) bool
- type BBcTransaction
- func (p *BBcTransaction) AddCrossRef(obj *BBcCrossRef)
- func (p *BBcTransaction) AddEvent(obj *BBcEvent)
- func (p *BBcTransaction) AddReference(obj *BBcReference)
- func (p *BBcTransaction) AddRelation(obj *BBcRelation)
- func (p *BBcTransaction) AddSignature(userID *[]byte, sig *BBcSignature)
- func (p *BBcTransaction) AddWitness(obj *BBcWitness)
- func (p *BBcTransaction) Digest() []byte
- func (p *BBcTransaction) GetSigIndex(userID []byte) int
- func (p *BBcTransaction) Pack() ([]byte, error)
- func (p *BBcTransaction) Sign(keypair *KeyPair) ([]byte, error)
- func (p *BBcTransaction) Stringer() string
- func (p *BBcTransaction) Unpack(dat *[]byte) error
- func (p *BBcTransaction) VerifyAll() (bool, int)
- type BBcWitness
- func (p *BBcWitness) AddSignature(userID *[]byte, sig *BBcSignature) error
- func (p *BBcWitness) AddWitness(userID *[]byte) error
- func (p *BBcWitness) Pack() ([]byte, error)
- func (p *BBcWitness) SetTransaction(txobj *BBcTransaction)
- func (p *BBcWitness) Stringer() string
- func (p *BBcWitness) Unpack(dat *[]byte) error
- type KeyPair
Constants ¶
const ( FormatPlain = 0x0000 FormatZlib = 0x0010 )
Header values for serialized data
const ( KeyTypeNotInitialized = 0 KeyTypeEcdsaSECP256k1 = 1 KeyTypeEcdsaP256v1 = 2 )
Supported ECC curve type is SECP256k1 and Prime-256v1.
const (
DomainIDLength = 32
)
The length of DomainID must be 256-bit in any domain.
Variables ¶
This section is empty.
Functions ¶
func AddEventAssetBodyObject ¶
func AddEventAssetBodyObject(transaction *BBcTransaction, eventIdx int, assetGroupID, userID *[]byte, body interface{})
AddEventAssetBodyObject sets an object (map[string]interface{}) to a BBcAsset object in a BBcEvent object and then, add it in a BBcTransaction object
func AddEventAssetBodyString ¶
func AddEventAssetBodyString(transaction *BBcTransaction, eventIdx int, assetGroupID, userID *[]byte, body string)
AddEventAssetBodyString sets a string to a BBcAsset object in a BBcEvent object and then, add it in a BBcTransaction object
func AddEventAssetFile ¶
func AddEventAssetFile(transaction *BBcTransaction, eventIdx int, assetGroupID, userID *[]byte, assetFile *[]byte)
AddEventAssetFile sets a file digest to a BBcAsset object in a BBcEvent object and then, add it in a BBcTransaction object
func AddPointerInRelation ¶
func AddPointerInRelation(relation *BBcRelation, refTransaction *BBcTransaction, refAssetID *[]byte)
AddPointerInRelation creates and includes a BBcPointer object in BBcRelation
func AddReference ¶
func AddReference(transaction *BBcTransaction, assetGroupID *[]byte, refTransaction *BBcTransaction, eventIdx int)
AddReference creates and includes a BBcReference object in a BBcTransaction object
func AddRelationAssetBodyObject ¶
func AddRelationAssetBodyObject(transaction *BBcTransaction, relationIdx int, assetGroupID, userID *[]byte, body interface{})
AddRelationAssetBodyObject sets an object (map[string]interface{}) in BBcAsset in BBcRelation, convert the info into msgpack, and add it in a BBcTransaction object
func AddRelationAssetBodyString ¶
func AddRelationAssetBodyString(transaction *BBcTransaction, relationIdx int, assetGroupID, userID *[]byte, body string)
AddRelationAssetBodyString sets a string in BBcAsset in BBcRelation and add it to a BBcTransaction object
func AddRelationAssetFile ¶
func AddRelationAssetFile(transaction *BBcTransaction, relationIdx int, assetGroupID, userID, assetFile *[]byte)
AddRelationAssetFile sets a file digest to BBcAsset in BBcRelation and add it to a BBcTransaction object
func AddRelationPointer ¶
func AddRelationPointer(transaction *BBcTransaction, relationIdx int, refTransactionID, refAssetID *[]byte)
AddRelationPointer creates and includes a BBcPointer object in BBcRelation and then, add it in a BBcTransaction object
func GetIdentifier ¶
GetIdentifier returns a random byte data with specified length (seed string ais used)
func GetIdentifierWithTimestamp ¶
GetIdentifierWithTimestamp returns a random byte data with specified length (seed string and timestamp are used)
func GetRandomValue ¶
GetRandomValue returns a random byte data with specified length
func Serialize ¶
func Serialize(transaction *BBcTransaction, formatType uint16) ([]byte, error)
Serialize BBcTransaction object into packed data
formatType = 0x0000: Packed data is simply used for serialized data.
formatType = 0x0010: Packed data is compressed using zlib, and the compressed data is used for serialized data.
func SignToTransaction ¶
func SignToTransaction(transaction *BBcTransaction, userID *[]byte, keypair *KeyPair)
SignToTransaction signs the transaction and append the BBcSignature object to it
func VerifyBBcSignature ¶
func VerifyBBcSignature(digest []byte, sig *BBcSignature) bool
VerifyBBcSignature verifies a given digest with BBcSignature object
func ZlibCompress ¶
ZlibCompress compresses the given data using zlib
func ZlibDecompress ¶
ZlibDecompress decompresses the given data using zlib
Types ¶
type BBcAsset ¶
type BBcAsset struct { IDLength int AssetID []byte UserID []byte Nonce []byte AssetFileSize uint32 AssetFileDigest []byte AssetBodyType uint16 AssetBodySize uint16 AssetBody []byte // contains filtered or unexported fields }
BBcAsset definition
"IDLength" and "digestCalculating" are not included in a packed data. They are for internal use only.
"AssetID" is the SHA256 digest of packed BBcAsset data, which contains from "UserID" to "AssetBody". The length of "AssetID" and "UserID" is defined by "IDLength". "Nonce" is automatically determined with random value. BBcAsset can contain a digest of a file, string, map[string]interface{} object as asset.
func (*BBcAsset) AddBodyObject ¶
AddBodyObject sets an object data in the BBcAsset object and convert it in MessagePack format
func (*BBcAsset) AddBodyString ¶
AddBodyString sets a string data in the BBcAsset object
func (*BBcAsset) AddFile ¶
AddFile add the digest of file in the BBcAsset object Note that this method adds the SHA256 digest of the file content (not file binary itself)
func (*BBcAsset) Digest ¶
Digest calculates the SHA256 digest of the AssetID value of the BBcAsset object
func (*BBcAsset) GetBodyObject ¶
GetBodyObject returns the object which is in MessagePack format
type BBcCrossRef ¶
BBcCrossRef definition
CrossRef stands for CrossReference, which holds information in other domain for inter-domain collaboration of transaction authenticity.
"IDLength" is not included in a packed data. It is for internal use only.
"DomainID" is the identifier of a domain and the length of the ID must be 256 bits (=32 bytes). "TransactionID" is that of transaction object in other domain (specified by the DomainID).
func (*BBcCrossRef) Add ¶
func (p *BBcCrossRef) Add(domainID *[]byte, txid *[]byte)
Add sets essential information to the BBcCrossRef object
func (*BBcCrossRef) Pack ¶
func (p *BBcCrossRef) Pack() ([]byte, error)
Pack returns binary data from the BBcCrossRef object
func (*BBcCrossRef) Stringer ¶
func (p *BBcCrossRef) Stringer() string
Stringer outputs the content of the object
func (*BBcCrossRef) Unpack ¶
func (p *BBcCrossRef) Unpack(dat *[]byte) error
Unpack the binary data to the BBcCrossRef object
type BBcEvent ¶
type BBcEvent struct { IDLength int AssetGroupID []byte ReferenceIndices []int MandatoryApprovers [][]byte OptionApproverNumNumerator uint16 OptionApproverNumDenominator uint16 OptionApprovers [][]byte Asset *BBcAsset }
BBcEvent definition
BBcEvent expresses an output of UTXO (Unspent Transaction Output) structure.
"AssetGroupID" distinguishes a type of asset, e.g., token-X, token-Y, Movie content, etc..
"ReferenceIndices" has the index numbers in BBcReference object list in the transaction object. It expresses that this BBcEvent object has a certain relationship with the BBcReference objects specified by ReferenceIndices. This would be used in the case that the transaction object has multiple BBcReference objects.
BBcEvent designates Mandatory/Option Approvers to be signers to a BBcTransaction in the future, which use the asset in the BBcEvent. As for "OptionApprovers", it is enough that some of them give sign to the BBcTransaction. The number of signers to be included is "OptionApproverNumNumerator".
Asset is the most important part of the BBcTransaction. The BBcAsset object includes the digital asset to be protected by BBc-1.
"IDLength" is not included in a packed data. It is for internal use only.
func (*BBcEvent) AddMandatoryApprover ¶
AddMandatoryApprover sets userID in MandatoryApprover list of the BBcEvent object
func (*BBcEvent) AddOptionApprover ¶
AddOptionApprover sets userID in OptionApprover list of the BBcEvent object
func (*BBcEvent) AddOptionParams ¶
AddOptionParams sets values to OptionApproverNumNumerator and OptionApproverNumDenominator in the BBcEvent object
func (*BBcEvent) AddReferenceIndex ¶
AddReferenceIndex sets an index to ReferenceIndices of the BBcEvent object
type BBcPointer ¶
BBcPointer definition
BBcPointer(s) are included in BBcRelation object. A BBcPointer object includes "TransactionID" and "AssetID" and declares that the transaction has a certain relationship with the BBcTransaction and BBcAsset object specified by those IDs.
IDLength is not included in a packed data. It is for internal use only.
func (*BBcPointer) Add ¶
func (p *BBcPointer) Add(txid *[]byte, asid *[]byte)
Add sets essential information to the BBcPointer object
func (*BBcPointer) Pack ¶
func (p *BBcPointer) Pack() ([]byte, error)
Pack returns the binary data of the BBcPointer object
func (*BBcPointer) Stringer ¶
func (p *BBcPointer) Stringer() string
Stringer outputs the content of the object
func (*BBcPointer) Unpack ¶
func (p *BBcPointer) Unpack(dat *[]byte) error
Unpack the BBcPointer object to the binary data
type BBcReference ¶
type BBcReference struct { IDLength int AssetGroupID []byte TransactionID []byte EventIndexInRef uint16 SigIndices []int Transaction *BBcTransaction RefTransaction *BBcTransaction RefEvent BBcEvent }
BBcReference definition
The BBcReference is an input of UTXO (Unspent Transaction Output) structure and this object must accompanied by a BBcEvent object because it is an output of UTXO.
"AssetGroupID" distinguishes a type of asset, e.g., token-X, token-Y, Movie content, etc.. "TransactionID" is that of a certain transaction in the past. "EventIndexInRef" points to the BBcEvent object in the past BBcTransaction. "SigIndices" is a mapping info between userID and the position (index) of the signature list in the BBcTransaction object.
"Transaction" is the pointer to the parent BBcTransaction object, and "RefTransaction" is the pointer to the past BBcTransaction object.
"IDLength", "Transaction", "RefTransaction" and "RefEvent" are not included in a packed data. They are for internal use only.
func (*BBcReference) Add ¶
func (p *BBcReference) Add(assetGroupID *[]byte, refTransaction *BBcTransaction, eventIdx int)
Add sets essential information to the BBcReference object
func (*BBcReference) AddApprover ¶
func (p *BBcReference) AddApprover(userID *[]byte) error
AddApprover makes a memo for managing approvers who sign this BBcTransaction object
func (*BBcReference) AddSignature ¶
func (p *BBcReference) AddSignature(userID *[]byte, sig *BBcSignature) error
AddSignature sets the BBcSignature object in the object
func (*BBcReference) Pack ¶
func (p *BBcReference) Pack() ([]byte, error)
Pack returns the binary data of the BBcReference object
func (*BBcReference) SetTransaction ¶
func (p *BBcReference) SetTransaction(txobj *BBcTransaction)
SetTransaction links the BBcReference object to the parent transaction object
func (*BBcReference) Stringer ¶
func (p *BBcReference) Stringer() string
Stringer outputs the content of the object
func (*BBcReference) Unpack ¶
func (p *BBcReference) Unpack(dat *[]byte) error
Unpack the BBcReference object to the binary data
type BBcRelation ¶
type BBcRelation struct { IDLength int AssetGroupID []byte Pointers []*BBcPointer Asset *BBcAsset }
BBcRelation definition
The BBcRelation holds the asset (by BBcAsset) and the relationship with the other transaction/asset (by BBcPointer). Different from UTXO, state information or account-type information can be expressed by using this object. If you want to include signature(s) according to the contents of BBcRelation object, BBcWitness should be included in the transaction object.
"AssetGroupID" distinguishes a type of asset, e.g., token-X, token-Y, Movie content, etc.. "Pointers" is a list of BBcPointers object. "Asset" is a BBcAsset object.
"IDLength" is not included in a packed data. It is for internal use only.
func MakeRelationWithAsset ¶
func MakeRelationWithAsset(assetGroupID, userID *[]byte, assetBodyString string, assetBodyObject interface{}, assetFile *[]byte, idLength int) *BBcRelation
MakeRelationWithAsset is a utility for making simple BBcTransaction object with BBcRelation with BBcAsset
func (*BBcRelation) Add ¶
func (p *BBcRelation) Add(assetGroupID *[]byte, asset *BBcAsset)
Add sets essential information (assetGroupID and BBcAsset object) to the BBcRelation object
func (*BBcRelation) AddPointer ¶
func (p *BBcRelation) AddPointer(pointer *BBcPointer)
AddPointer sets the BBcPointer object in the object
func (*BBcRelation) Pack ¶
func (p *BBcRelation) Pack() ([]byte, error)
Pack returns the binary data of the BBcRelation object
func (*BBcRelation) Stringer ¶
func (p *BBcRelation) Stringer() string
Stringer outputs the content of the object
func (*BBcRelation) Unpack ¶
func (p *BBcRelation) Unpack(dat *[]byte) error
Unpack the BBcRelation object to the binary data
type BBcSignature ¶
type BBcSignature struct { KeyType uint32 Pubkey []byte PubkeyLen uint32 Signature []byte SignatureLen uint32 }
BBcSignature definition
The BBcSignature holds public key and signature. The signature is for the TransactionID of the transaction object.
func RecoverSignatureObject ¶
func RecoverSignatureObject(dat *[]byte) *BBcSignature
RecoverSignatureObject is a utility for recovering signature data into BBcSignature object
func (*BBcSignature) Pack ¶
func (p *BBcSignature) Pack() ([]byte, error)
Pack returns the binary data of the BBcSignature object
func (*BBcSignature) SetPublicKey ¶
func (p *BBcSignature) SetPublicKey(keyType uint32, pubkey *[]byte)
SetPublicKey sets signature binary in the object
func (*BBcSignature) SetPublicKeyByKeypair ¶
func (p *BBcSignature) SetPublicKeyByKeypair(keypair *KeyPair)
SetPublicKeyByKeypair sets public key (in keypair object) in the object
func (*BBcSignature) SetSignature ¶
func (p *BBcSignature) SetSignature(sig *[]byte)
SetSignature sets signature binary in the object
func (*BBcSignature) Stringer ¶
func (p *BBcSignature) Stringer() string
Stringer outputs the content of the object
func (*BBcSignature) Unpack ¶
func (p *BBcSignature) Unpack(dat *[]byte) error
Unpack the BBcSignature object to the binary data
func (*BBcSignature) Verify ¶
func (p *BBcSignature) Verify(digest []byte) bool
Verify the TransactionID of the parent BBcTransaction object with the signature in the object
type BBcTransaction ¶
type BBcTransaction struct { TransactionID []byte TransactionBaseDigest []byte TransactionData []byte SigIndices [][]byte Version uint32 Timestamp int64 IDLength int Events []*BBcEvent References []*BBcReference Relations []*BBcRelation Witness *BBcWitness Crossref *BBcCrossRef Signatures []*BBcSignature // contains filtered or unexported fields }
BBcTransaction definition
BBcTransaction is just a container of various objects.
Events, References, Relations and Signatures are list of BBcEvent, BBcReference, BBcRelation and BBcSignature objects, respectively. "digestCalculating", "TransactionBaseDigest", "TransactionData" and "SigIndices" are not included in the packed data. They are internal use only.
Calculating TransactionID ¶
How to calculate the TransactionID of the transaction is a little bit complicated, meaning that 2-step manner. This is because inter-domain transaction authenticity (i.e., CrossReference) can be conducted in secure manner. By presenting TransactionBaseDigest (see below) to an outer-domain, the domain user can confirm the existence of the transaction in the past. (no need to present whole transaction data including the asset information).
1st step:
- Pack info (from version to Witness) by packBase()
- Calculate SHA256 digest of the packed info. This value is TransactionBaseDigest.
2nd step:
- Pack BBcCrossRef object to get packed data by packCrossRef()
- Concatenate TransactionBaseDigest and the packed BBcCrossRef
- Calculate SHA256 digest of the concatenated data. This value is TransactionID
func Deserialize ¶
func Deserialize(dat []byte) (*BBcTransaction, error)
Deserialize BBcTransaction data with header
func MakeTransaction ¶
func MakeTransaction(eventNum, relationNum int, witness bool, idLength int) *BBcTransaction
MakeTransaction is a utility for making simple BBcTransaction object with BBcEvent, BBcRelation or/and BBcWitness
func (*BBcTransaction) AddCrossRef ¶
func (p *BBcTransaction) AddCrossRef(obj *BBcCrossRef)
AddCrossRef sets the BBcCrossRef object in the transaction object
func (*BBcTransaction) AddEvent ¶
func (p *BBcTransaction) AddEvent(obj *BBcEvent)
AddEvent adds the BBcEvent object in the transaction object
func (*BBcTransaction) AddReference ¶
func (p *BBcTransaction) AddReference(obj *BBcReference)
AddReference adds the BBcReference object in the transaction object
func (*BBcTransaction) AddRelation ¶
func (p *BBcTransaction) AddRelation(obj *BBcRelation)
AddRelation adds the BBcRelation object in the transaction object
func (*BBcTransaction) AddSignature ¶
func (p *BBcTransaction) AddSignature(userID *[]byte, sig *BBcSignature)
AddSignature adds the BBcSignature object for the specified userID in the transaction object
func (*BBcTransaction) AddWitness ¶
func (p *BBcTransaction) AddWitness(obj *BBcWitness)
AddWitness sets the BBcWitness object in the transaction object
func (*BBcTransaction) Digest ¶
func (p *BBcTransaction) Digest() []byte
Digest calculates TransactionID of the BBcTransaction object
func (*BBcTransaction) GetSigIndex ¶
func (p *BBcTransaction) GetSigIndex(userID []byte) int
GetSigIndex reserves and returns the position (index) of the corespondent userID in the signature list
func (*BBcTransaction) Pack ¶
func (p *BBcTransaction) Pack() ([]byte, error)
Pack BBcTransaction object in binary data
func (*BBcTransaction) Sign ¶
func (p *BBcTransaction) Sign(keypair *KeyPair) ([]byte, error)
Sign TransactionID using private key in the given keypair
func (*BBcTransaction) Stringer ¶
func (p *BBcTransaction) Stringer() string
Stringer outputs the content of the object
func (*BBcTransaction) Unpack ¶
func (p *BBcTransaction) Unpack(dat *[]byte) error
Unpack binary data to BBcTransaction object
func (*BBcTransaction) VerifyAll ¶
func (p *BBcTransaction) VerifyAll() (bool, int)
VerifyAll verifies TransactionID with all BBcSignature objects in the transaction
type BBcWitness ¶
type BBcWitness struct { IDLength int UserIDs [][]byte SigIndices []int Transaction *BBcTransaction }
BBcWitness definition
The BBcWitness has the mapping info between the userIDs and BBcSignature objects. This object should be used if BBcRelation is used or a certain user wants to sign to the transaction in some reason.
"UserIDs" is the list of userID, and "SigIndices" is a mapping info between userID and the position (index) of the signature list in the BBcTransaction object.
"Transaction" is the pointer to the parent BBcTransaction object.
"IDLength" and "Transaction" are not included in a packed data. They are for internal use only.
func (*BBcWitness) AddSignature ¶
func (p *BBcWitness) AddSignature(userID *[]byte, sig *BBcSignature) error
AddSignature sets the BBcSignature to the parent BBcTransaction and the position in the Signatures list in BBcTransaction is based on the UserID
func (*BBcWitness) AddWitness ¶
func (p *BBcWitness) AddWitness(userID *[]byte) error
AddWitness makes a memo for managing signer who sign this BBcTransaction object This must be done before AddSignature.
func (*BBcWitness) Pack ¶
func (p *BBcWitness) Pack() ([]byte, error)
Pack returns the binary data of the BBcWitness object
func (*BBcWitness) SetTransaction ¶
func (p *BBcWitness) SetTransaction(txobj *BBcTransaction)
SetTransaction links the BBcWitness object to the parent transaction object
func (*BBcWitness) Stringer ¶
func (p *BBcWitness) Stringer() string
Stringer outputs the content of the object
func (*BBcWitness) Unpack ¶
func (p *BBcWitness) Unpack(dat *[]byte) error
Unpack the BBcWitness object to the binary data
type KeyPair ¶
KeyPair definition
A KeyPair object hold a pair of private key and public key. This object includes functions for sign and verify a signature. The sign/verify functions is realized by "libbbcsig".
func GenerateKeypair ¶
GenerateKeypair generates a new Key pair object with new private key and public key
func (*KeyPair) ConvertFromPem ¶
ConvertFromPem outputs PEM formatted public key