neofsecdsa

package
v0.0.0-...-bb55e7d Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 12

Documentation

Overview

Package neofsecdsa collects ECDSA primitives for NeoFS cryptography.

Signer and PublicKey support ECDSA signature algorithm with SHA-512 hashing. SignerRFC6979 and PublicKeyRFC6979 implement signature algorithm described in RFC 6979. All these types provide corresponding interfaces from neofscrypto package.

Package import causes registration of next signature schemes via neofscrypto.RegisterScheme:

  • neofscrypto.ECDSA_SHA512
  • neofscrypto.ECDSA_DETERMINISTIC_SHA256

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PublicKey

type PublicKey ecdsa.PublicKey

PublicKey is a wrapper over ecdsa.PublicKey used for NeoFS needs. Provides neofscrypto.PublicKey interface.

Instances MUST be initialized from ecdsa.PublicKey using type conversion.

func (*PublicKey) Decode

func (x *PublicKey) Decode(data []byte) error

Decode decodes compressed binary representation of the PublicKey.

See also Encode.

func (PublicKey) Encode

func (x PublicKey) Encode(buf []byte) int

Encode encodes ECDSA public key in compressed form into buf. Uses exactly MaxEncodedSize bytes of the buf.

Encode panics if buf length is less than MaxEncodedSize.

See also Decode.

func (PublicKey) MaxEncodedSize

func (x PublicKey) MaxEncodedSize() int

MaxEncodedSize returns size of the compressed ECDSA public key.

func (PublicKey) Verify

func (x PublicKey) Verify(data, signature []byte) bool

Verify verifies data signature calculated by ECDSA algorithm with SHA-512 hashing.

type PublicKeyRFC6979

type PublicKeyRFC6979 ecdsa.PublicKey

PublicKeyRFC6979 is a wrapper over ecdsa.PublicKey used for NeoFS needs. Provides neofscrypto.PublicKey interface.

Instances MUST be initialized from ecdsa.PublicKey using type conversion.

func (*PublicKeyRFC6979) Decode

func (x *PublicKeyRFC6979) Decode(data []byte) error

Decode decodes binary representation of the ECDSA public key.

See also Encode.

func (PublicKeyRFC6979) Encode

func (x PublicKeyRFC6979) Encode(buf []byte) int

Encode encodes ECDSA public key in compressed form into buf. Uses exactly MaxEncodedSize bytes of the buf.

Encode panics if buf length is less than MaxEncodedSize.

See also Decode.

func (PublicKeyRFC6979) MaxEncodedSize

func (x PublicKeyRFC6979) MaxEncodedSize() int

MaxEncodedSize returns size of the compressed ECDSA public key.

func (PublicKeyRFC6979) Verify

func (x PublicKeyRFC6979) Verify(data, signature []byte) bool

Verify verifies data signature calculated by deterministic ECDSA algorithm with SHA-256 hashing.

See also RFC 6979.

type PublicKeyWalletConnect

type PublicKeyWalletConnect ecdsa.PublicKey

PublicKeyWalletConnect is a wrapper over ecdsa.PublicKey used for NeoFS needs. Provides neofscrypto.PublicKey interface.

Instances MUST be initialized from ecdsa.PublicKey using type conversion.

func (*PublicKeyWalletConnect) Decode

func (x *PublicKeyWalletConnect) Decode(data []byte) error

Decode decodes compressed binary representation of the PublicKeyWalletConnect.

See also Encode.

func (PublicKeyWalletConnect) Encode

func (x PublicKeyWalletConnect) Encode(buf []byte) int

Encode encodes ECDSA public key in compressed form into buf. Uses exactly MaxEncodedSize bytes of the buf.

Encode panics if buf length is less than MaxEncodedSize.

See also Decode.

func (PublicKeyWalletConnect) MaxEncodedSize

func (x PublicKeyWalletConnect) MaxEncodedSize() int

MaxEncodedSize returns size of the compressed ECDSA public key.

func (PublicKeyWalletConnect) Verify

func (x PublicKeyWalletConnect) Verify(data, signature []byte) bool

Verify verifies data signature calculated by ECDSA algorithm with SHA-512 hashing.

type Signer

type Signer ecdsa.PrivateKey

Signer wraps ecdsa.PrivateKey and represents signer based on ECDSA with SHA-512 hashing. Provides neofscrypto.Signer interface.

Instances MUST be initialized from ecdsa.PrivateKey using type conversion.

func (Signer) Public

func (x Signer) Public() neofscrypto.PublicKey

Public initializes PublicKey and returns it as neofscrypto.PublicKey. Implements neofscrypto.Signer.

func (Signer) Scheme

func (x Signer) Scheme() neofscrypto.Scheme

Scheme returns neofscrypto.ECDSA_SHA512. Implements neofscrypto.Signer.

func (Signer) Sign

func (x Signer) Sign(data []byte) ([]byte, error)

Sign signs data using ECDSA algorithm with SHA-512 hashing. Implements neofscrypto.Signer.

type SignerRFC6979

type SignerRFC6979 ecdsa.PrivateKey

SignerRFC6979 wraps ecdsa.PrivateKey and represents signer based on deterministic ECDSA with SHA-256 hashing (RFC 6979). Provides neofscrypto.Signer interface.

Instances SHOULD be initialized from ecdsa.PrivateKey using type conversion.

func (SignerRFC6979) Public

func (x SignerRFC6979) Public() neofscrypto.PublicKey

Public initializes PublicKeyRFC6979 and returns it as neofscrypto.PublicKey. Implements neofscrypto.Signer.

func (SignerRFC6979) Scheme

func (x SignerRFC6979) Scheme() neofscrypto.Scheme

Scheme returns neofscrypto.ECDSA_DETERMINISTIC_SHA256. Implements neofscrypto.Signer.

func (SignerRFC6979) Sign

func (x SignerRFC6979) Sign(data []byte) ([]byte, error)

Sign signs data using deterministic ECDSA algorithm with SHA-256 hashing. Implements neofscrypto.Signer.

See also RFC 6979.

type SignerWalletConnect

type SignerWalletConnect ecdsa.PrivateKey

SignerWalletConnect is similar to SignerRFC6979 with 2 changes: 1. The data is base64 encoded before signing/verifying. 2. The signature is a concatenation of the signature itself and 16-byte salt.

Instances MUST be initialized from ecdsa.PrivateKey using type conversion.

func (SignerWalletConnect) Public

Public initializes PublicKey and returns it as neofscrypto.PublicKey. Implements neofscrypto.Signer.

func (SignerWalletConnect) Scheme

Scheme returns neofscrypto.ECDSA_WALLETCONNECT. Implements neofscrypto.Signer.

func (SignerWalletConnect) Sign

func (x SignerWalletConnect) Sign(data []byte) ([]byte, error)

Sign signs data using ECDSA algorithm with SHA-512 hashing. Implements neofscrypto.Signer.

Jump to

Keyboard shortcuts

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