crypto

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Uint256Size = 32
	Uint160Size = 20
)
View Source
const (
	// SuiteECDSA is a ECDSA suite over P-256 curve
	// with 64-byte uncompressed signatures.
	SuiteECDSA suiteType = 1 + iota
)

Variables

This section is empty.

Functions

func Generate

func Generate(r io.Reader) (dbft.PrivateKey, dbft.PublicKey)

Generate generates new key pair using r as a source of entropy.

func GenerateWith

func GenerateWith(t suiteType, r io.Reader) (dbft.PrivateKey, dbft.PublicKey)

GenerateWith generates new key pair for suite t using r as a source of entropy.

func NewECDSAPrivateKey

func NewECDSAPrivateKey(key *ecdsa.PrivateKey) dbft.PrivateKey

NewECDSAPrivateKey returns new PublicKey from *ecdsa.PrivateKey.

func NewECDSAPublicKey

func NewECDSAPublicKey(pub *ecdsa.PublicKey) dbft.PublicKey

NewECDSAPublicKey returns new PublicKey from *ecdsa.PublicKey.

Types

type ECDSAPriv

type ECDSAPriv struct {
	*ecdsa.PrivateKey
}

ECDSAPriv is a wrapper over *ecdsa.PrivateKey.

func (ECDSAPriv) Sign

func (e ECDSAPriv) Sign(msg []byte) ([]byte, error)

Sign signs message using P-256 curve.

type ECDSAPub

type ECDSAPub struct {
	*ecdsa.PublicKey
}

ECDSAPub is a wrapper over *ecsda.PublicKey.

func (ECDSAPub) MarshalBinary

func (e ECDSAPub) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler interface.

func (*ECDSAPub) UnmarshalBinary

func (e *ECDSAPub) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler interface.

func (ECDSAPub) Verify

func (e ECDSAPub) Verify(msg, sig []byte) error

Verify verifies signature using P-256 curve.

type Uint160

type Uint160 [Uint160Size]byte

func Hash160

func Hash160(data []byte) Uint160

Hash160 returns ripemd160 from sha256 of data.

func (Uint160) String

func (h Uint160) String() string

String implements fmt.Stringer interface.

type Uint256

type Uint256 [Uint256Size]byte

func Hash256

func Hash256(data []byte) Uint256

Hash256 returns double sha-256 of data.

func (Uint256) String

func (h Uint256) String() string

String implements fmt.Stringer interface.

Jump to

Keyboard shortcuts

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