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 string, attestorSigningKey *ec.PrivateKey, attributeName, attributeValue, identityAttributeSecret string) (*transaction.Transaction, 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()
privBuf, _ := hex.DecodeString("127d0ab318252b4622d8eac61407359a4cab7c1a5d67754b5bf9db910eaf052c")
priv, _ := ec.PrivateKeyFromBytes(privBuf)
tx, err := CreateAttestation(
idKey,
priv,
"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().String())
Output: tx generated: afa78310343de3a8b23703c1556ff587ea8839eb8f224b31ce76155d1b8cd6c4
func CreateIdentity ¶
func CreateIdentity(xPrivateKey, idKey string, currentCounter uint32) (*transaction.Transaction, error)
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: 187a4133bf007ca0aae2b31b0600772fa93eab33aa0ed9f05e94b5415523224c
Types ¶
type AttestationType ¶
type AttestationType string
AttestationType is an enum for BAP Type Constants
const ( ATTEST AttestationType = "ATTEST" ID AttestationType = "ID" REVOKE AttestationType = "REVOKE" ALIAS AttestationType = "ALIAS" )
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"`
Profile string `json:"profile,omitempty" bson:"profile,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

