address

package
v0.0.0-...-29e903f Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: MIT Imports: 4 Imported by: 8

Documentation

Overview

ZooBC lib

ZooBC is architected by Roberto Capodieci & Barton Johnston

contact us at roberto.capodieci[at]blockchainzoo.com
and barton.johnston[at]blockchainzoo.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package address handle the address decoding and encoding in zoobc format

ZooBC lib

ZooBC is architected by Roberto Capodieci & Barton Johnston

contact us at roberto.capodieci[at]blockchainzoo.com
and barton.johnston[at]blockchainzoo.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Examples

Constants

View Source
const (
	PrefixLength           = 3
	InputPublicKeyLength   = 32
	ZbcIDLength            = 66
	ZbcIDDataSegment       = 7
	ZbcIDDataSegmentLength = 8
)

Variables

View Source
var (
	// errors
	ErrInvalidPrefixLength     = errors.New("ErrInvalidPrefixLength")
	ErrInvalidInputLength      = errors.New("ErrInvalidInputLength")
	ErrInvalidZbcIDLength      = errors.New("ErrInvalidZbcIDLength")
	ErrInvalidZbcIDDataSegment = errors.New("ErrInvalidZbcIDDataSegment")
	// ErrInvalidDataSegment must have exactly 7 data segments
	ErrInvalidDataSegment = errors.New("ErrInvalidDataSegment")
	// ErrInvalidDataSegmentLength each segment must be 8 char long
	ErrInvalidDataSegmentLength = errors.New("ErrInvalidDataSegmentLength")
	ErrChecksumNotMatch         = errors.New("ErrChecksumNotMatch")
)

Functions

func DecodeZbcID

func DecodeZbcID(zbcID string, publicKey []byte) error

DecodeZbcID decode the provided zbcID (zoobc address) and fill to provided publicKey publicKey is constrained to 32 bytes and zbcID's length 66

Example
var publicKey = make([]byte, 32)
err := DecodeZbcID("ZBC_4FAIBHLR_RSTERRKF_ZOOK7HFT_R7C3CXLU_PXGSWYBJ_ZYOR727G_6NQE2QGD", publicKey)
if err != nil {
	fmt.Printf("an error occured: %v", err)
}
fmt.Printf("%v", publicKey)
Output:

[225 64 128 157 113 140 166 72 197 69 203 156 175 156 179 143 197 177 93 116 125 205 43 96 41 206 29 31 235 230 243 96]

func EncodeZbcID

func EncodeZbcID(prefix string, publicKey []byte) (string, error)

EncodeZbcID encode the publicKey to zoobc address publicKey is constrained to 32 bytes and address's length will be 66

Example
pubKey := sha3.Sum256([]byte("your public key"))
id, err := EncodeZbcID("ZBC", pubKey[:])
if err != nil {
	fmt.Printf("error occured: %v\n", err)
}
fmt.Printf("%s", id)
Output:

ZBC_4FAIBHLR_RSTERRKF_ZOOK7HFT_R7C3CXLU_PXGSWYBJ_ZYOR727G_6NQE2QGD

Types

This section is empty.

Jump to

Keyboard shortcuts

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