ecdsa

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SECP256K1JWA         string = "ES256K"
	SECP256K1JWACurve    string = "secp256k1"
	SECP256K1AlgorithmID string = SECP256K1JWACurve
)
View Source
const (
	KeyType = "EC"
)

Variables

This section is empty.

Functions

func AlgorithmID

func AlgorithmID(jwk *jwk.JWK) (string, error)

AlgorithmID returns the algorithm ID for the given jwk.JWK

func BytesToPublicKey

func BytesToPublicKey(algorithmID string, input []byte) (jwk.JWK, error)

BytesToPublicKey deserializes the given byte array into a jwk.JWK for the given cryptographic algorithm

func GeneratePrivateKey

func GeneratePrivateKey(algorithmID string) (jwk.JWK, error)

GeneratePrivateKey generates an ECDSA private key for the given algorithm

func GetJWA

func GetJWA(jwk jwk.JWK) (string, error)

GetJWA returns the JWA for the given ECDSA key

func GetPublicKey

func GetPublicKey(privateKey jwk.JWK) jwk.JWK

GetPublicKey builds an ECDSA public key from the given ECDSA private key

func PublicKeyToBytes

func PublicKeyToBytes(publicKey jwk.JWK) ([]byte, error)

PublicKeyToBytes serializes the given public key into a byte array

func SECP256K1BytesToPublicKey

func SECP256K1BytesToPublicKey(input []byte) (jwk.JWK, error)

SECP256K1BytesToPublicKey converts a secp256k1 public key to a JWK. Supports both Compressed and Uncompressed public keys described in https://www.secg.org/sec1-v2.pdf section 2.3.3

func SECP256K1GeneratePrivateKey

func SECP256K1GeneratePrivateKey() (jwk.JWK, error)

SECP256K1GeneratePrivateKey generates a new private key

func SECP256K1PublicKeyToBytes

func SECP256K1PublicKeyToBytes(publicKey jwk.JWK) ([]byte, error)

SECP256K1PublicKeyToBytes converts a secp256k1 public key JWK to bytes. Note: this function returns the uncompressed public key. compressed is not yet supported

func SECP256K1Sign

func SECP256K1Sign(payload []byte, privateKey jwk.JWK) ([]byte, error)

SECP256K1Sign signs the given payload with the given private key

func SECP256K1Verify

func SECP256K1Verify(payload []byte, signature []byte, publicKey jwk.JWK) (bool, error)

SECP256K1Verify verifies the given signature over the given payload with the given public key

func Sign

func Sign(payload []byte, privateKey jwk.JWK) ([]byte, error)

Sign generates a cryptographic signature for the given payload with the given private key

Note

The function will automatically detect the given ECDSA cryptographic curve from the given private key

func SupportsAlgorithmID

func SupportsAlgorithmID(id string) bool

SupportsAlgorithmID informs as to whether or not the given algorithm ID is supported by this package

func Verify

func Verify(payload []byte, signature []byte, publicKey jwk.JWK) (bool, error)

Verify verifies the given signature over a given payload by the given public key

Note

The function will automatically detect the given ECDSA cryptographic curve from the given public key

Types

This section is empty.

Jump to

Keyboard shortcuts

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