ed25519

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package ed25519 provides a interface to use the Ed25519 Edwards Curve

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EdKey

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

EdKey is a Edwards Curve private key

func Generate

func Generate() (*EdKey, error)

Generate will create a new Ed25519 edward curve public/private key pair

Example
package main

import (
	"fmt"

	"github.com/go-compile/rome/ed25519"
)

func main() {
	k, err := ed25519.Generate()
	if err != nil {
		panic(err)
	}

	fmt.Printf("Curve: %s\n", k.Public().Name())
}
Output:

Curve: ED25519

func ParseEdPrivate

func ParseEdPrivate(private []byte) (*EdKey, error)

ParseEdPrivate will read a PEM ASN.1 DER encoded key

func ParseEdPrivateASN1

func ParseEdPrivateASN1(private []byte) (*EdKey, error)

ParseEdPrivateASN1 will read a ASN.1 DER encoded key

func PrivateFrom

func PrivateFrom(p []byte) *EdKey

PrivateFrom will take the private key bytes and return a EdKey

func (*EdKey) Decrypt

func (k *EdKey) Decrypt(ciphertext []byte, cipher rome.Cipher, hash hash.Hash, options ...rome.Option) ([]byte, error)

Decrypt is not supported on Edwards Curves

func (*EdKey) Private

func (k *EdKey) Private() ([]byte, error)

Private will return the private key as PEM ASN.1 DER bytes

func (*EdKey) PrivateASN1

func (k *EdKey) PrivateASN1() ([]byte, error)

PrivateASN1 will return the private key as ASN.1 DER bytes

func (*EdKey) PrivateRaw

func (k *EdKey) PrivateRaw() []byte

PrivateRaw returns the private bytes D

func (*EdKey) Public

func (k *EdKey) Public() rome.PublicKey

Public returns the public key interface

func (*EdKey) PublicRaw

func (k *EdKey) PublicRaw() []byte

PublicRaw returns the public key as bytes

func (*EdKey) Sign

func (k *EdKey) Sign(digest []byte) ([]byte, error)

Sign will take a digest and use the private key to sign it

type EdPublicKey

type EdPublicKey []byte

EdPublicKey is a Edward Curve public key

func ParseEdPublic

func ParseEdPublic(public []byte) (*EdPublicKey, error)

ParseEdPublic will read edward curve public key from PEM ASN.1 DER format

func ParseEdPublicASN1

func ParseEdPublicASN1(der []byte) (*EdPublicKey, error)

ParseEdPublicASN1 will read a edward curve public key from ASN.1 DER format

func PublicFrom

func PublicFrom(p []byte) *EdPublicKey

PublicFrom will take the public key bytes and return a EdPublic key

func (*EdPublicKey) Bits

func (k *EdPublicKey) Bits() int

Bits returns the size of the key in bits

func (*EdPublicKey) DH

func (k *EdPublicKey) DH(h hash.Hash, g rome.PrivateKey, options ...rome.Option) ([]byte, error)

DH is a placeholder function to satisfy rome's Key interface.

func (*EdPublicKey) Encrypt

func (k *EdPublicKey) Encrypt(msg []byte, cipher rome.Cipher, hash hash.Hash, options ...rome.Option) ([]byte, error)

Encrypt is not supported on Edwards Curves

func (*EdPublicKey) Fingerprint

func (k *EdPublicKey) Fingerprint(h hash.Hash) []byte

Fingerprint returns the hashed ASN.1 digest representing this public key. This function will panic if it fails to encode the public key.

func (*EdPublicKey) Key

func (k *EdPublicKey) Key() ([]byte, error)

Key returns the public key in PEM ASN.1 DER format

func (*EdPublicKey) KeyASN1

func (k *EdPublicKey) KeyASN1() ([]byte, error)

KeyASN1 returns the public key formatted in ASN.1

func (*EdPublicKey) Name

func (k *EdPublicKey) Name() string

Name returns the name of the Edward Curve

func (*EdPublicKey) Points

func (k *EdPublicKey) Points() (x *big.Int, y *big.Int)

Points are not implemented for Edward Curves. Usage will result in a panic.

func (*EdPublicKey) Size

func (k *EdPublicKey) Size() int

Size returns the size of the key in bytes

func (*EdPublicKey) Verify

func (k *EdPublicKey) Verify(msg []byte, signature []byte) (bool, error)

Verify will take a ASN.1 signature and return true if it's valid

Jump to

Keyboard shortcuts

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