address

package
v0.0.0-...-3927449 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: MIT Imports: 24 Imported by: 8

README

GoDoc

address

Overview

This library is for generating addresses, marshaling/unmarshalling of addresses, signing and verifying by addresses for AidosKuneen.

Example

(This example omits error handlings for simplicity.)

	import "github.com/AidosKuneen/aklib/address"
	
	pwd := []byte("some password")
	seed := address.GenerateSeed32()
	adr1 := address.New(MainConfig, seed)
	seed58 := HDSeed58(MainConfig,seed,pwd,false) //base58 encoded seed

	//For node
	// adr1 := address.NewNode(MainConfig, seed)
	// seed58 := HDSeed58(MainConfig,seed,pwd,true) //base58 encoded seed

	seed581,_,err := HDFrom58(MainConfig,seed58,pwd) //base58 encoded seed
	//seed58 and seed581 should be same

	pk58 := adr1.Address58(MainConfig) //base58 encoded public key
	pk, err := address.ParseAddress58(  MainConfig,pk58)

	msg := []byte("This is a test.")
	sig := adr1.Sign(msg)	
	err := address.Verify(sig,msg)	

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthAddress = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowAddress   = fmt.Errorf("proto: integer overflow")
)

Functions

func Address58

func Address58(config *aklib.Config, p Bytes) (string, error)

Address58 converts address bytes to encode58 format.

func Address58ForAddress

func Address58ForAddress(p Bytes) string

Address58ForAddress converts address bytes to encode58 format.

func Decapsulate

func Decapsulate(priv *sidh.PrivateKey, ctext []byte) ([]byte, error)

Decapsulate returns decrypted plain bytes.

func Decode58

func Decode58(value string) ([]byte, error)

Decode58 decodes base58 value to bytes.

func DecryptSeed

func DecryptSeed(ct []byte, pwd []byte) ([]byte, error)

DecryptSeed decrypts by AES256 with MAC.

func Encapsulate

func Encapsulate(cfg *aklib.Config, d string) (ctext []byte, secret []byte, err error)

Encapsulate returns secret and cipher bytes encrypted by pub.

func Encode58

func Encode58(encoded []byte) string

Encode58 encodes byte slice to base58.

func EncryptSeed

func EncryptSeed(pt []byte, pwd []byte) []byte

EncryptSeed encrypts by AES256 with MAC.

func GenerateSeed32

func GenerateSeed32() []byte

GenerateSeed32 generates a new 32 bytes seed.

func HDFrom58

func HDFrom58(cfg *aklib.Config, seed58 string, pwd []byte) ([]byte, bool, error)

HDFrom58 returns seed bytes from base58-encoded seed and its password.

func HDSeed58

func HDSeed58(conf *aklib.Config, seed, pwd []byte, isNode bool) string

HDSeed58 returns base58-encoded encrypted seed..

func HDseed

func HDseed(masterkey []byte, indices ...uint32) []byte

HDseed returns HD seed.

func IsValidSIKEPublicKey

func IsValidSIKEPublicKey(cfg *aklib.Config, d string) (*sidh.PublicKey, error)

IsValidSIKEPublicKey returns pubkey if d is a valid public key.

func MultisigAddress

func MultisigAddress(cfg *aklib.Config, m byte, address ...Bytes) string

MultisigAddress returns an multisig address.

func MultisigAddress58

func MultisigAddress58(cfg *aklib.Config, bmul Bytes) (string, error)

MultisigAddress58 returns an multisig address string.

func NewSIKEPrivatekey

func NewSIKEPrivatekey(seed []byte) (*sidh.PrivateKey, error)

NewSIKEPrivatekey makes a sike privatekey from seed

func ParseAddress58ForAddress

func ParseAddress58ForAddress(pub58 string) ([]byte, error)

ParseAddress58ForAddress parses and checks base58 encoded address and returns binary public key.

func SIKEPublicKey

func SIKEPublicKey(cfg *aklib.Config, priv *sidh.PrivateKey) string

SIKEPublicKey returns the public key in transaction in string.

Types

type Address

type Address struct {
	IsNode     bool               `protobuf:"varint,1,opt,name=is_node,json=isNode,proto3" json:"is_node,omitempty"`
	PrivateKey *bliss.PrivateKeyT `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"`
}

Address represents an address an assciated Merkle Tree in ADK.

func FromSeed

func FromSeed(config *aklib.Config, seed []byte) (*Address, error)

FromSeed makes Address struct from the seed.

func New

func New(config *aklib.Config, seed []byte) (*Address, error)

New returns a new Address struct built from the seed.

func NewNode

func NewNode(config *aklib.Config, seed []byte) (*Address, error)

NewNode returns a new node address struct built from the seed.

func NewPopulatedAddress

func NewPopulatedAddress(r randyAddress, easy bool) *Address

func (*Address) Address

func (a *Address) Address(cfg *aklib.Config) Bytes

Address returns the address in binary..

func (*Address) Address58

func (a *Address) Address58(cfg *aklib.Config) string

Address58 returns base58 encoded address.

func (*Address) Descriptor

func (*Address) Descriptor() ([]byte, []int)

func (*Address) Equal

func (this *Address) Equal(that interface{}) bool

func (*Address) Marshal

func (m *Address) Marshal() (dAtA []byte, err error)

func (*Address) MarshalTo

func (m *Address) MarshalTo(dAtA []byte) (int, error)

func (*Address) ProtoMessage

func (*Address) ProtoMessage()

func (*Address) PublicKey

func (a *Address) PublicKey() []byte

PublicKey returns public key of bliss..

func (*Address) Reset

func (m *Address) Reset()

func (*Address) Sign

func (a *Address) Sign(msg []byte) (*Signature, error)

Sign signs msg.

func (*Address) Size

func (m *Address) Size() (n int)

func (*Address) String

func (m *Address) String() string

func (*Address) Unmarshal

func (m *Address) Unmarshal(dAtA []byte) error

func (*Address) XXX_DiscardUnknown

func (m *Address) XXX_DiscardUnknown()

func (*Address) XXX_Marshal

func (m *Address) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Address) XXX_Merge

func (dst *Address) XXX_Merge(src proto.Message)

func (*Address) XXX_Size

func (m *Address) XXX_Size() int

func (*Address) XXX_Unmarshal

func (m *Address) XXX_Unmarshal(b []byte) error

type Bytes

type Bytes []byte

Bytes is a byte representation of address.

func MultisigAddressByte

func MultisigAddressByte(cfg *aklib.Config, m byte, address ...Bytes) Bytes

MultisigAddressByte returns an multisig address bytes.

func ParseAddress58

func ParseAddress58(cfg *aklib.Config, pub58 string) (Bytes, bool, error)

ParseAddress58 parses and checks base58 encoded address and returns binary public key and its height.

func ParseMultisigAddress

func ParseMultisigAddress(cfg *aklib.Config, pub58 string) (Bytes, error)

ParseMultisigAddress parses and checks base58 encoded multisig address and returns binary address..

func (Bytes) MarshalJSON

func (bs Bytes) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of m.

func (Bytes) String

func (bs Bytes) String() string

func (*Bytes) UnmarshalJSON

func (bs *Bytes) UnmarshalJSON(b []byte) error

UnmarshalJSON sets *bs to a copy of data.

type Signature

type Signature struct {
	PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
	Sig       []byte `protobuf:"bytes,2,opt,name=sig,proto3" json:"sig,omitempty"`
}

Signature is a signature for hashed-address..

func NewPopulatedSignature

func NewPopulatedSignature(r randyAddress, easy bool) *Signature

func (*Signature) Address

func (sig *Signature) Address(cfg *aklib.Config, isNode bool) Bytes

Address returns address bytes from sig.

func (*Signature) Descriptor

func (*Signature) Descriptor() ([]byte, []int)

func (*Signature) Equal

func (this *Signature) Equal(that interface{}) bool

func (*Signature) Marshal

func (m *Signature) Marshal() (dAtA []byte, err error)

func (*Signature) MarshalTo

func (m *Signature) MarshalTo(dAtA []byte) (int, error)

func (*Signature) ProtoMessage

func (*Signature) ProtoMessage()

func (*Signature) Reset

func (m *Signature) Reset()

func (*Signature) Size

func (m *Signature) Size() (n int)

func (*Signature) String

func (m *Signature) String() string

func (*Signature) Unmarshal

func (m *Signature) Unmarshal(dAtA []byte) error

func (*Signature) Verify

func (sig *Signature) Verify(msg []byte) error

Verify verifies msg from a node with node key..

func (*Signature) XXX_DiscardUnknown

func (m *Signature) XXX_DiscardUnknown()

func (*Signature) XXX_Marshal

func (m *Signature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Signature) XXX_Merge

func (dst *Signature) XXX_Merge(src proto.Message)

func (*Signature) XXX_Size

func (m *Signature) XXX_Size() int

func (*Signature) XXX_Unmarshal

func (m *Signature) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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