bap

package module
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 9 Imported by: 4

README

go-bap

Library for working with Bitcoin Attestation Protocol in Go

Release Build Status Report codecov Go
Mergify Status Sponsor Donate


Table of Contents


Installation

go-bap requires a supported release of Go.

go get -u github.com/bitcoinschema/go-bap

Documentation

View the generated documentation

GoDoc

Features
Package Dependencies
Library Deployment

goreleaser for easy binary or library deployment to Github and can be installed via: brew install goreleaser.

The .goreleaser.yml file is used to configure goreleaser.

Use make release-snap to create a snapshot version of the release, and finally make release to ship to production.

Makefile Commands

View all makefile commands

make help

List of all current commands:

all                   Runs multiple commands
clean                 Remove previous builds and any test cache data
clean-mods            Remove all the Go mod cache
coverage              Shows the test coverage
diff                  Show the git diff
generate              Runs the go generate command in the base of the repo
godocs                Sync the latest tag with GoDocs
help                  Show this help message
install               Install the application
install-go            Install the application (Using Native Go)
install-releaser      Install the GoReleaser application
lint                  Run the golangci-lint application (install if not found)
release               Full production release (creates release in Github)
release               Runs common.release then runs godocs
release-snap          Test the full release (build binaries)
release-test          Full production test release (everything except deploy)
replace-version       Replaces the version in HTML/JS (pre-deploy)
tag                   Generate a new tag and push (tag version=0.0.0)
tag-remove            Remove a tag if found (tag-remove version=0.0.0)
tag-update            Update an existing tag to current commit (tag-update version=0.0.0)
test                  Runs lint and ALL tests
test-ci               Runs all tests via CI (exports coverage)
test-ci-no-race       Runs all tests via CI (no race) (exports coverage)
test-ci-short         Runs unit tests via CI (exports coverage)
test-no-lint          Runs just tests
test-short            Runs vet, lint and tests (excludes integration tests)
test-unit             Runs tests and outputs coverage
uninstall             Uninstall the application (and remove files)
update-linter         Update the golangci-lint package (macOS only)
vet                   Run the Go vet application

Examples & Tests

All unit tests and examples run via GitHub Actions and uses Go version 1.18.x. View the configuration file.

Run all tests (including integration tests)

make test

Run tests (excluding integration tests)

make test-short

Benchmarks

Run the Go benchmarks:

make bench

Code Standards

Read more about this Go project's code standards.


Usage

Checkout all the examples!


Maintainers

MrZ MrZ
Satchmo MrZ

Contributing

View the contributing guidelines and follow the code of conduct.

How can I help?

All kinds of contributions are welcome 🙌! The most basic way to show your support is to star 🌟 the project, or to raise issues 💬. You can also support this project by becoming a sponsor on GitHub 👏 or by making a bitcoin donation to ensure this journey continues indefinitely! 🚀

Credits

Siggi for creating BAP 👏


License

License

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

View Source
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

func CreateIdentity(privateKey, idKey string, currentCounter uint32) (*bt.Tx, 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: 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

func NewFromTape(tape *bpu.Tape) (b *Bap, err error)

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

func NewFromTapes(tapes []bpu.Tape) (*Bap, error)

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

func (*Bap) FromTape added in v0.1.12

func (b *Bap) FromTape(tape *bpu.Tape) (err error)

FromTape takes a bob.Tape and returns a BAP data structure

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL