subtle

package
v0.0.0-...-64dd8ac Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package subtle provides subtle implementations of the digital signature primitive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertCurveName

func ConvertCurveName(name string) string

ConvertCurveName converts different forms of a curve name to the name that tink recognizes.

func GetCurve

func GetCurve(curve string) elliptic.Curve

GetCurve returns the curve object that corresponds to the given curve type. It returns null if the curve type is not supported.

func ValidateSecp256K1Params

func ValidateSecp256K1Params(hashAlg, curve, encoding string) error

ValidateSecp256K1Params validates secp256k1 parameters. The hash's strength must not be weaker than the curve's strength. DER and IEEE_P1363 encodings are supported.

Types

type ECDSAVerifier

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

ECDSAVerifier is an implementation of Verifier for ECDSA. At the moment, the implementation only accepts signatures with strict DER encoding.

func NewSecp256K1Verifier

func NewSecp256K1Verifier(hashAlg, curve, encoding string, x, y []byte) (*ECDSAVerifier, error)

NewSecp256K1Verifier creates a new instance of Secp256K1Verifier.

func NewSecp256K1VerifierFromPublicKey

func NewSecp256K1VerifierFromPublicKey(hashAlg, encoding string, publicKey *ecdsa.PublicKey) (*ECDSAVerifier, error)

NewSecp256K1VerifierFromPublicKey creates a new instance of ECDSAVerifier.

func (*ECDSAVerifier) Verify

func (e *ECDSAVerifier) Verify(signatureBytes, data []byte) error

Verify verifies whether the given signature is valid for the given data. It returns an error if the signature is not valid; nil otherwise.

type Secp256K1Signer

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

Secp256K1Signer is an implementation of Signer for secp256k1 Secp256k2 (Koblitz curve). At the moment, the implementation only accepts DER encoding.

func NewSecp256K1Signer

func NewSecp256K1Signer(hashAlg string,
	curve string,
	encoding string,
	keyValue []byte) (*Secp256K1Signer, error)

NewSecp256K1Signer creates a new instance of Secp256K1Signer.

func NewSecp256K1SignerFromPrivateKey

func NewSecp256K1SignerFromPrivateKey(hashAlg string, encoding string,
	privateKey *ecdsa.PrivateKey) (*Secp256K1Signer, error)

NewSecp256K1SignerFromPrivateKey creates a new instance of Secp256K1Signer.

func (*Secp256K1Signer) Sign

func (e *Secp256K1Signer) Sign(data []byte) ([]byte, error)

Sign computes a signature for the given data.

type Secp256k1Signature

type Secp256k1Signature struct {
	R, S *big.Int
}

Secp256k1Signature is a struct holding the r and s values of an secp256k1 signature.

func DecodeSecp256K1Signature

func DecodeSecp256K1Signature(encodedBytes []byte, encoding string) (*Secp256k1Signature, error)

DecodeSecp256K1Signature creates a new secp256k1 signature using the given byte slice. The function assumes that the byte slice is the concatenation of the BigEndian representation of two big integer r and s.

func NewSecp256K1Signature

func NewSecp256K1Signature(r, s *big.Int) *Secp256k1Signature

NewSecp256K1Signature creates a new Secp256k1Signature instance.

func (*Secp256k1Signature) EncodeSecp256K1Signature

func (sig *Secp256k1Signature) EncodeSecp256K1Signature(encoding, curveName string) ([]byte, error)

EncodeSecp256K1Signature converts the signature to the given encoding format.

Jump to

Keyboard shortcuts

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