eddsa

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package eddsa implements the EdDSA signature schemes as per RFC 8032 https://tools.ietf.org/html/rfc8032. Note: Currently only Ed25519 is supported

Index

Constants

View Source
const (
	ED25519JWACurve    string = "Ed25519"
	ED25519AlgorithmID string = ED25519JWACurve
)
View Source
const (
	JWA     string = "EdDSA"
	KeyType string = "OKP"
)

Variables

This section is empty.

Functions

func AlgorithmID added in v0.11.0

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

AlgorithmID returns the algorithm ID for the given jwk.JWK

func BytesToPublicKey added in v0.2.0

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 ED25519BytesToPublicKey added in v0.2.0

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

ED25519BytesToPublicKey deserializes the byte array into a jwk.JWK public key

func ED25519GeneratePrivateKey

func ED25519GeneratePrivateKey() (jwk.JWK, error)

ED25519GeneratePrivateKey generates a new ED25519 private key

func ED25519PublicKeyToBytes added in v0.3.0

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

ED25519PublicKeyToBytes serializes the given public key int a byte array

func ED25519Sign

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

ED25519Sign signs the given payload with the given private key

func ED25519Verify

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

ED25519Verify verifies the given signature against the given payload using the given public key

func GeneratePrivateKey

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

GeneratePrivateKey generates an EdDSA private key for the given algorithm

func GetJWA

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

GetJWA returns the JWA for the given EdDSA key

Note

The only supported JWA is "EdDSA"

func GetPublicKey

func GetPublicKey(privateKey jwk.JWK) jwk.JWK

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

func PublicKeyToBytes added in v0.3.0

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

PublicKeyToBytes serializes the given public key into a byte array

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 EdDSA 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 EdDSA 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