neofscrypto

package
v1.25.1-0...-2fdc35d Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package neofscrypto collects common cryptographic primitives used in NeoFS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sign

func Sign(signer Signer, prm SignPrm) error

Sign reads signed data from source (SRC), calculates signature (S) via Signer, and passes (S) into parameterized (SH).

If (KH) is proved, signer's public key is marshaled and passed into it. If MarshalBinary returns an error, it is ignored w/o handler call.

Panics if SRC is nil. Panics if SH is nil.

func Verify

func Verify(key PublicKey, prm VerifyPrm) bool

Verify verifies the signature (S) of the data from (SRC) via PublicKey. Return true if signature is correct.

Panics if SRC is nil.

Types

type BytesHandler

type BytesHandler func([]byte)

BytesHandler is a function over []byte.

type DataSource

type DataSource func() ([]byte, error)

DataSource is a data read function.

type PublicKey

type PublicKey interface {
	// Verify checks if signature calculated from
	// the data via corresponding Signer is correct.
	Verify(data, signature []byte) bool

	// Binary format for network transmission.
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
}

PublicKey represents a public key using a particular algorithm.

type SignPrm

type SignPrm struct {
	// contains filtered or unexported fields
}

SignPrm groups the parameters of Sign operation.

Required parameters:

  • data source (SRC);
  • signature handler (SH).

func (*SignPrm) SetDataSource

func (x *SignPrm) SetDataSource(f DataSource)

SetDataSource sets signed data source (SRC).

The parameter is required and should not be nil.

func (*SignPrm) SetSignatureHandler

func (x *SignPrm) SetSignatureHandler(f BytesHandler)

SetSignatureHandler sets handler of the calculated signature (SH).

The parameter is required and should not be nil.

func (*SignPrm) WrapSignedDataHandler

func (x *SignPrm) WrapSignedDataHandler(f BytesHandler)

WrapSignedDataHandler wraps handler of the signed data buffer. If some handler is already wrapped, it will be called before f.

If provided, all wrapped handlers are called right after the signature is calculated.

type Signer

type Signer interface {
	// Sign signs data with the private key.
	Sign(data []byte) ([]byte, error)

	// Public returns the public key corresponding to the Signer.
	Public() PublicKey
}

Signer is an interface for an opaque private key that can be used for signing operations. It is an adaptation of crypto.Signer to the needs of NeoFS.

type VerifyPrm

type VerifyPrm struct {
	// contains filtered or unexported fields
}

VerifyPrm groups the parameters of Verify operation.

Required parameters:

  • data source (SRC);
  • signature (S).

func (*VerifyPrm) SetDataSource

func (x *VerifyPrm) SetDataSource(f DataSource)

SetDataSource sets signed data source (SRC).

The parameter is required and should not be nil.

func (*VerifyPrm) SetSignature

func (x *VerifyPrm) SetSignature(s []byte)

SetSignature sets signature to check (S).

(S) should not be modified before the end of the Verify call.

func (*VerifyPrm) WrapSignedDataHandler

func (x *VerifyPrm) WrapSignedDataHandler(f BytesHandler)

WrapSignedDataHandler wraps handler of the signed data buffer. If some handler is already wrapped, it will be called before f.

If provided, all wrapped handlers are called right after the signature is calculated.

Directories

Path Synopsis
Package cryptoalgo provides functionality for working with various cryptographic signature algorithms.
Package cryptoalgo provides functionality for working with various cryptographic signature algorithms.
Package neofsecdsa provides ECDSA implementations of neofscrypto elements.
Package neofsecdsa provides ECDSA implementations of neofscrypto elements.
Package cryprotobuf provides elements for working with Protocol Buffers format data.
Package cryprotobuf provides elements for working with Protocol Buffers format data.
Package neofsrfc6979 provides RFC 6979's deterministic DSA implementations of neofscrypto elements.
Package neofsrfc6979 provides RFC 6979's deterministic DSA implementations of neofscrypto elements.
Package neofscryptotest provides a set of helper functions that can make testing easier.
Package neofscryptotest provides a set of helper functions that can make testing easier.
Package cryptoutil provides the utilities abstract utilities that can be used in NeoFS cryptography.
Package cryptoutil provides the utilities abstract utilities that can be used in NeoFS cryptography.

Jump to

Keyboard shortcuts

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