signaturetype

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: GPL-3.0 Imports: 12 Imported by: 1

Documentation

Overview

ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>

ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.

Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:

  1. You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
  1. Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.

ZooBC is architected by Roberto Capodieci & Barton Johnston

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

Core developers that contributed to the current implementation of the software are:

Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com
Allan Bintoro allan.bintoro[at]blockchainzoo.com
Andy Herman
Gede Sukra
Ketut Ariasa
Nawi Kartini nawi.kartini[at]blockchainzoo.com
Stefano Galassi stefano.galassi[at]blockchainzoo.com

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

ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>

ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.

Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:

  1. You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
  1. Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.

ZooBC is architected by Roberto Capodieci & Barton Johnston

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

Core developers that contributed to the current implementation of the software are:

Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com
Allan Bintoro allan.bintoro[at]blockchainzoo.com
Andy Herman
Gede Sukra
Ketut Ariasa
Nawi Kartini nawi.kartini[at]blockchainzoo.com
Stefano Galassi stefano.galassi[at]blockchainzoo.com

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBitcoinCurve

func DefaultBitcoinCurve() *btcec.KoblitzCurve

DefaultBitcoinCurve to return used bitcoin curve

func DefaultBitcoinNetworkParams

func DefaultBitcoinNetworkParams() *chaincfg.Params

DefaultBitcoinNetworkParams to return defult Bitcoin network params

func DefaultBitcoinPrivateKeyLength

func DefaultBitcoinPrivateKeyLength() model.PrivateKeyBytesLength

DefaultBitcoinPrivateKeyLength to

func DefaultBitcoinPublicKeyFormat

func DefaultBitcoinPublicKeyFormat() model.BitcoinPublicKeyFormat

DefaultBitcoinPublicKeyFormat return recommended public key format

Types

type BitcoinSignature

type BitcoinSignature struct {
	NetworkParams *chaincfg.Params
	Curve         *btcec.KoblitzCurve
}

BitcoinSignature represent of bitcoin signature

func NewBitcoinSignature

func NewBitcoinSignature(netParams *chaincfg.Params, curve *btcec.KoblitzCurve) *BitcoinSignature

NewBitcoinSignature is new instance of bitcoin signature

func (*BitcoinSignature) GetAddressBytes

func (b *BitcoinSignature) GetAddressBytes(encodedAddress string) ([]byte, error)

GetAddressBytes Get raw bytes of a string encoded address

func (*BitcoinSignature) GetAddressFromPublicKey

func (b *BitcoinSignature) GetAddressFromPublicKey(publicKey []byte) (string, error)

GetAddressFromPublicKey to get address public key from seed

func (*BitcoinSignature) GetNetworkParams

func (b *BitcoinSignature) GetNetworkParams() *chaincfg.Params

GetNetworkParams to bitcoin network parameters

func (*BitcoinSignature) GetPrivateKeyFromSeed

func (b *BitcoinSignature) GetPrivateKeyFromSeed(
	seed string,
	privkeyLength model.PrivateKeyBytesLength,
) (*btcec.PrivateKey, error)

GetPrivateKeyFromSeed to get private key form seed

func (*BitcoinSignature) GetPublicKeyFromBytes

func (b *BitcoinSignature) GetPublicKeyFromBytes(pubkey []byte) (*btcec.PublicKey, error)

GetPublicKeyFromBytes to get public key from raw bytes public key

func (*BitcoinSignature) GetPublicKeyFromPrivateKey

func (*BitcoinSignature) GetPublicKeyFromPrivateKey(
	privateKey *btcec.PrivateKey,
	format model.BitcoinPublicKeyFormat,
) ([]byte, error)

GetPublicKeyFromPrivateKey get raw public key from private key public key format : https://bitcoin.org/en/wallets-guide#public-key-formats

func (*BitcoinSignature) GetPublicKeyFromSeed

func (b *BitcoinSignature) GetPublicKeyFromSeed(
	seed string,
	format model.BitcoinPublicKeyFormat,
	privkeyLength model.PrivateKeyBytesLength,
) ([]byte, error)

GetPublicKeyFromSeed Get the raw public key corresponding to a seed (secret phrase)

func (*BitcoinSignature) GetPublicKeyString

func (b *BitcoinSignature) GetPublicKeyString(publicKey []byte) (string, error)

GetPublicKeyString will return hex string from bytes public key

func (*BitcoinSignature) GetSignatureFromBytes

func (b *BitcoinSignature) GetSignatureFromBytes(signatureBytes []byte) (*btcec.Signature, error)

GetSignatureFromBytes to get signature type from signature raw bytes

func (*BitcoinSignature) Sign

func (*BitcoinSignature) Sign(privateKey *btcec.PrivateKey, payload []byte) ([]byte, error)

Sign to generates an ECDSA signature for the provided payload

func (*BitcoinSignature) Verify

func (*BitcoinSignature) Verify(
	payload []byte,
	signature *btcec.Signature,
	publicKey *btcec.PublicKey,
) bool

Verify to verify the signature of payload using provided public key

type Ed25519Signature

type Ed25519Signature struct{}

Ed25519Signature represent of ed25519 signature

func NewEd25519Signature

func NewEd25519Signature() *Ed25519Signature

NewEd25519Signature is new instance of ed25519 signature

func (*Ed25519Signature) GetAddressFromPublicKey

func (*Ed25519Signature) GetAddressFromPublicKey(prefix string, publicKey []byte) (string, error)

GetAddressFromPublicKey Get the formatted address from a raw public key

func (*Ed25519Signature) GetAddressFromSeed

func (es *Ed25519Signature) GetAddressFromSeed(prefix, seed string) string

GetAddressFromSeed Get the address corresponding to a seed (secret phrase)

func (*Ed25519Signature) GetPrivateKeyFromSeed

func (*Ed25519Signature) GetPrivateKeyFromSeed(seed string) []byte

GetPrivateKeyFromSeed to get private key form seed

func (*Ed25519Signature) GetPrivateKeyFromSeedUseSlip10

func (*Ed25519Signature) GetPrivateKeyFromSeedUseSlip10(seed string) ([]byte, error)

GetPrivateKeyFromSeedUseSlip10 generate private key form seed using slip10, this private used by hdwallet NOTE: currently this private cannot use to sign message using golang ed25519, The output private key is first 32 bytes from private key golang ed25519

func (*Ed25519Signature) GetPublicKeyFromEncodedAddress

func (*Ed25519Signature) GetPublicKeyFromEncodedAddress(addr string) ([]byte, error)

GetPublicKeyFromEncodedAddress Get the raw public key from a formatted address

func (*Ed25519Signature) GetPublicKeyFromPrivateKey

func (*Ed25519Signature) GetPublicKeyFromPrivateKey(privateKey []byte) ([]byte, error)

GetPublicKeyFromPrivateKey get public key bytes from private key

func (*Ed25519Signature) GetPublicKeyFromPrivateKeyUseSlip10

func (*Ed25519Signature) GetPublicKeyFromPrivateKeyUseSlip10(privateKey []byte) ([]byte, error)

GetPublicKeyFromPrivateKeyUseSlip10 get pubic key from slip10 private key

func (*Ed25519Signature) GetPublicKeyFromSeed

func (es *Ed25519Signature) GetPublicKeyFromSeed(seed string) []byte

GetPublicKeyFromSeed Get the raw public key corresponding to a seed (secret phrase)

func (*Ed25519Signature) GetPublicKeyString

func (*Ed25519Signature) GetPublicKeyString(publicKey []byte) string

GetPublicKeyString will return string of row bytes public key

func (*Ed25519Signature) Sign

func (*Ed25519Signature) Sign(accountPrivateKey, payload []byte) []byte

Sign to generates an ed25519 signature for the provided payload

func (*Ed25519Signature) Verify

func (*Ed25519Signature) Verify(accountPublicKey, payload, signature []byte) bool

Verify to verify the signature of payload using provided account public key

type SignatureTypeInterface

type SignatureTypeInterface interface {
	Sign(accountPrivateKey, payload []byte) []byte
	Verify(accountPublicKey, payload, signature []byte) bool
	GetPrivateKeyFromSeed(seed string) []byte
	GetPrivateKeyFromSeedUseSlip10(seed string) ([]byte, error)
	GetPublicKeyFromPrivateKeyUseSlip10(privateKey []byte) ([]byte, error)
	GetPublicKeyFromSeed(seed string) []byte
	GetAddressFromSeed(prefix, seed string) string
	GetPublicKeyFromPrivateKey(privateKey []byte) ([]byte, error)
	GetPublicKeyString(publicKey []byte) string
	GetPublicKeyFromEncodedAddress(addr string) ([]byte, error)
	GetAddressFromPublicKey(prefix string, publicKey []byte) (string, error)
}

SignatureTypeInterface implements all signature types methods TODO: some of these signatures are specific to some account type and should be separated from the main interface

Jump to

Keyboard shortcuts

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