identity

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: ISC Imports: 15 Imported by: 0

Documentation

Overview

Package identity is responsible for creation and management of user identities.

Index

Constants

View Source
const BMPurposeCode = 0x80000052

BMPurposeCode is the purpose code used for HD key derivation.

View Source
const BehaviorAck = 1

BehaviorAck says whether a message to this pubkey should include an ack.

Variables

This section is empty.

Functions

func Encode

func Encode(w io.Writer, pub Public) error

Encode serializes the public identity.

Types

type PrivateAddress

type PrivateAddress struct {
	// contains filtered or unexported fields
}

PrivateAddress contains private keys and the parameters necessary to derive an address from it.

func ImportWIF

func ImportWIF(addrStr, signingKeyWif, decryptionKeyWif string) (*PrivateAddress, error)

ImportWIF creates a Private identity from the Bitmessage address and Wallet Import Format (WIF) signing and encryption keys.

func NewPrivateAddress

func NewPrivateAddress(key *PrivateKey, version, stream uint64) *PrivateAddress

NewPrivateAddress constructs a PrivateAddress.

func (*PrivateAddress) Address

func (id *PrivateAddress) Address() Address

Address constructs the Bitmessage address object corresponding to this PrivateAddress

func (*PrivateAddress) ExportWIF

func (id *PrivateAddress) ExportWIF() (address, signingKeyWif, decryptionKeyWif string)

ExportWIF exports a Private identity to WIF for storage on disk or use by other software. It exports the private signing key and private encryption key.

func (*PrivateAddress) PrivateKey

func (id *PrivateAddress) PrivateKey() *PrivateKey

PrivateKey returns the private key corresponding to this address.

func (*PrivateAddress) PublicKey

func (id *PrivateAddress) PublicKey() *PublicKey

PublicKey returns the public key.

type PrivateID

type PrivateID struct {
	PrivateAddress
	// contains filtered or unexported fields
}

PrivateID contains the identity of the user, which includes private encryption and signing keys, and POW parameters.

func NewPrivateID

func NewPrivateID(id *PrivateAddress, behavior uint32, data *pow.Data) *PrivateID

NewPrivateID constructs a PrivateID.

func (*PrivateID) Behavior

func (id *PrivateID) Behavior() uint32

Behavior returns the Behavior value for this id.

func (*PrivateID) Data

func (id *PrivateID) Data() *obj.PubKeyData

Data turns a PrivateID type into PubKeyData type.

func (*PrivateID) Pow

func (id *PrivateID) Pow() *pow.Data

Pow returns the pow.Data for this identity.

func (*PrivateID) Public

func (id *PrivateID) Public() Public

Public turns a Private identity object into Public identity object.

type PrivateKey

type PrivateKey struct {
	Signing    *btcec.PrivateKey
	Decryption *btcec.PrivateKey
}

PrivateKey contains the private keys.

func NewDeterministic

func NewDeterministic(passphrase string, initialZeros uint64, n int) ([]*PrivateKey, error)

NewDeterministic creates n identities based on a deterministic passphrase. Note that this does not create an address.

func NewHD

func NewHD(masterKey *hdkeychain.ExtendedKey, n uint32, stream uint64) (*PrivateKey, error)

NewHD generates a new hierarchically deterministic key based on BIP-BM01. Master key must be a private master key generated according to BIP32. `n' is the n'th identity to generate. NewHD also generates a v4 address based on the specified stream.

func NewRandom

func NewRandom(initialZeros int) (*PrivateKey, error)

NewRandom creates an identity based on a random data, with the required number of initial zeros in front (minimum 1). Each initial zero requires exponentially more work. Note that this does not create an address.

func (*PrivateKey) ExportWIF

func (pk *PrivateKey) ExportWIF() (SigningWif, DecryptionWif string)

ExportWIF exports the private keys in WIF format.

func (*PrivateKey) Hash

func (pk *PrivateKey) Hash() *hash.Ripe

Hash returns the ripemd160 hash used in the address

func (*PrivateKey) Public

func (pk *PrivateKey) Public() *PublicKey

Public turns a Private identity object into Public identity object.

type PubKey

type PubKey btcec.PublicKey

PubKey is used in several of the bitmessage messages and common structures. The first 32 bytes contain the X value and the other 32 contain the Y value.

func NewPubKey

func NewPubKey(pub *wire.PubKey) (*PubKey, error)

NewPubKey returns a new PubKey from a wire.PubKey. An error is returned if the number of bytes passed in is not PubKeySize.

func (*PubKey) Btcec

func (pubkey *PubKey) Btcec() *btcec.PublicKey

Btcec converts PubKey to btcec.PublicKey so that it can be used for cryptographic operations like encryption/signature verification.

func (*PubKey) Bytes

func (pubkey *PubKey) Bytes() []byte

Bytes returns the bytes which represent the hash as a byte slice.

func (*PubKey) IsEqual

func (pubkey *PubKey) IsEqual(target *PubKey) bool

IsEqual returns true if target is the same as the pubkey.

func (*PubKey) String

func (pubkey *PubKey) String() string

String returns the PubKey as a hexadecimal string.

func (*PubKey) Wire

func (pubkey *PubKey) Wire() *wire.PubKey

Wire returns the PubKey in wire format.

type Public

type Public interface {
	Address() Address
	Key() *PublicKey
	Data() *obj.PubKeyData
	Behavior() uint32
	Pow() *pow.Data
	String() string
}

Public refers to a public identity.

func Decode

func Decode(r io.Reader) (Public, error)

Decode reads a public identity as a publicID type, which implements Public.

func NewPublic

func NewPublic(public *PublicKey, version, stream uint64, behavior uint32,
	data *pow.Data) (Public, error)

NewPublic creates and initializes an *identity.PublicID object.

func NewPublicFromWIF

func NewPublicFromWIF(address *PrivateAddress, behavior uint32,
	data *pow.Data) Public

NewPublicFromWIF creates an *identity.Public object from a PrivateAddress

type PublicKey

type PublicKey struct {
	Verification *PubKey
	Encryption   *PubKey
}

PublicKey contains the identity of the remote user, which includes public encryption and signing keys, and POW parameters.

func NewPublicKey

func NewPublicKey(vk, ek *wire.PubKey) (*PublicKey, error)

NewPublicKey takes two wire.PubKeys and constructs a PublicKey.

func (*PublicKey) Hash

func (k *PublicKey) Hash() *hash.Ripe

Hash returns the ripemd160 hash used in the address

func (*PublicKey) String

func (k *PublicKey) String() string

String creates a human-readible string of a PublicKey.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL