Documentation ¶
Overview ¶
Package bap is a library for working with Bitcoin Attestation Protocol (BAP) in Go
Protocol: https://github.com/icellan/bap
If you have any suggestions or comments, please feel free to open an issue on this GitHub repository!
By BitcoinSchema Organization (https://bitcoinschema.org)
Index ¶
Examples ¶
Constants ¶
const Prefix = "1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT"
Prefix is the bitcom prefix for Bitcoin Attestation Protocol (BAP)
Variables ¶
This section is empty.
Functions ¶
func CreateAttestation ¶
func CreateAttestation(idKey, attestorSigningKey, attributeName, attributeValue, identityAttributeSecret string) (*bt.Tx, error)
CreateAttestation creates an attestation transaction from an id key, signing key, and signing address
Source: https://github.com/icellan/bap
Example ¶
ExampleCreateAttestation example using CreateAttestation()
tx, err := CreateAttestation( idKey, "127d0ab318252b4622d8eac61407359a4cab7c1a5d67754b5bf9db910eaf052c", "person", "john doe", "some-secret-hash", ) if err != nil { fmt.Printf("failed to create attestation: %s", err.Error()) return } fmt.Printf("tx generated: %s", tx.TxID())
Output: tx generated: 3cd2baf76b7fc8324a117119daf77c0f428e5defb686be9b7631daaa036d5a61
func CreateIdentity ¶
CreateIdentity creates an identity from a private key, an id key, and a counter
Source: https://github.com/icellan/bap
Example ¶
ExampleCreateIdentity example using CreateIdentity()
tx, err := CreateIdentity(privateKey, idKey, 0) if err != nil { fmt.Printf("failed to create identity: %s", err.Error()) return } fmt.Printf("tx generated: %s", tx.TxID())
Output: tx generated: d2384b0946b8c3137bc0bf12d122efb8b77be998118b65c21448864234188f20
Types ¶
type AttestationType ¶
type AttestationType string
AttestationType is an enum for BAP Type Constants
const ( ATTEST AttestationType = "ATTEST" ID AttestationType = "ID" REVOKE AttestationType = "REVOKE" )
BAP attestation type constants
type Bap ¶ added in v0.1.12
type Bap struct { Address string `json:"address,omitempty" bson:"address,omitempty"` IDKey string `json:"id_key,omitempty" bson:"id_key,omitempty"` Sequence uint64 `json:"sequence" bson:"sequence"` Type AttestationType `json:"type,omitempty" bson:"type,omitempty"` URNHash string `json:"urn_hash,omitempty" bson:"urn_hash,omitempty"` }
Bap is BAP data object from the bob.Tape
func NewFromTape ¶ added in v0.1.5
NewFromTape takes a bob.Tape and returns a BAP data structure
Example ¶
ExampleNewFromTape example using NewFromTape()
// Get BOB data from string bobData, err := bob.NewFromString(sampleValidBobTx) if err != nil { fmt.Printf("error occurred: %s", err.Error()) return } // Get from tape var b *Bap b, err = NewFromTape(&bobData.Out[0].Tape[1]) if err != nil { fmt.Printf("error occurred: %s", err.Error()) return } fmt.Printf("BAP type: %s", b.Type)
Output: BAP type: ATTEST
func NewFromTapes ¶ added in v0.1.12
NewFromTapes will create a new BAP object from a []bob.Tape
Example ¶
ExampleNewFromTapes example using NewFromTapes()
// Get BOB data from string bobData, err := bob.NewFromString(sampleValidBobTx) if err != nil { fmt.Printf("error occurred: %s", err.Error()) return } // Get from tapes var b *Bap b, err = NewFromTapes(bobData.Out[0].Tape) if err != nil { fmt.Printf("error occurred: %s", err.Error()) return } fmt.Printf("BAP type: %s", b.Type)
Output: BAP type: ATTEST