Documentation
¶
Index ¶
- Constants
- func FromSeed(seed []byte) (ed25519.PublicKey, ed25519.PrivateKey, error)
- func GenerateDeterministicKeyMLDSA44(seed []byte) ([]byte, []byte, error)
- func GenerateDeterministicKeyMLDSA65(seed []byte) ([]byte, []byte, error)
- func GenerateDeterministicKeyMLDSA87(seed []byte) ([]byte, []byte, error)
- func GenerateKey() (ed25519.PublicKey, ed25519.PrivateKey, error)
- func GenerateKeyECDSAP256() (public []byte, private []byte, err error)
- func GenerateKeyMLDSA44() ([]byte, []byte, error)
- func GenerateKeyMLDSA65() ([]byte, []byte, error)
- func GenerateKeyMLDSA87() ([]byte, []byte, error)
- func GenerateKeyP256() (*ecdsa.PrivateKey, error)
- func MarshalPrivateKey(p *ecdsa.PrivateKey) []byte
- func MarshalPublicKey(pub *ecdsa.PublicKey) []byte
- func NewPrivateKey(d []byte) (*ecdsa.PrivateKey, error)
- func ParsePublicKey(b []byte) (*ecdsa.PublicKey, error)
- func ParseSignature(sig []byte) (*big.Int, *big.Int, error)
- func Sign(priv ed25519.PrivateKey, msg []byte) []byte
- func SignASN1(p *ecdsa.PrivateKey, hash []byte) ([]byte, error)
- func SignECDSAP256(private, msg []byte) ([]byte, error)
- func SignWithOptions(priv ed25519.PrivateKey, msg []byte, opts *ed25519.Options) ([]byte, error)
- func Verify(pub ed25519.PublicKey, msg, sig []byte) bool
- func VerifyASN1(pub *ecdsa.PublicKey, hash, sig []byte) bool
- func VerifyECDSAP256(public, msg, signature []byte) bool
- func VerifyWithOptions(pub ed25519.PublicKey, msg, signature []byte, opts *ed25519.Options) error
- type Options
- type Signature
Constants ¶
const ( MLDSA44PublicKeySize = dilithium.PublicKeySize44 MLDSA44SecretKeySize = dilithium.SecretKeySize44 MLDSA44SignatureSize = dilithium.SignatureSize44 MLDSA65PublicKeySize = dilithium.PublicKeySize65 MLDSA65SecretKeySize = dilithium.SecretKeySize65 MLDSA65SignatureSize = dilithium.SignatureSize65 MLDSA87PublicKeySize = dilithium.PublicKeySize87 MLDSA87SecretKeySize = dilithium.SecretKeySize87 MLDSA87SignatureSize = dilithium.SignatureSize87 )
Public, secret, and signature sizes for the Dilithium / ML-DSA variants.
const ( PublicKeySize = ed25519.PublicKeySize PrivateKeySize = ed25519.PrivateKeySize SeedSize = ed25519.SeedSize SignatureSize = ed25519.SignatureSize )
Expose standard ed25519 sizes so callers can allocate buffers without importing crypto/ed25519 directly.
const (
// ScalarSize is the size in bytes of a P-256 private scalar.
ScalarSize = 32
)
Variables ¶
This section is empty.
Functions ¶
func GenerateDeterministicKeyMLDSA44 ¶ added in v1.0.1
GenerateDeterministicKeyMLDSA44 derives a deterministic ML-DSA-44 key pair from seed.
func GenerateDeterministicKeyMLDSA65 ¶ added in v1.0.1
GenerateDeterministicKeyMLDSA65 derives a deterministic ML-DSA-65 key pair from seed.
func GenerateDeterministicKeyMLDSA87 ¶ added in v1.0.1
GenerateDeterministicKeyMLDSA87 derives a deterministic ML-DSA-87 key pair from seed.
func GenerateKey ¶
func GenerateKey() (ed25519.PublicKey, ed25519.PrivateKey, error)
GenerateKey creates a new Ed25519 keypair using crypto/rand.
func GenerateKeyECDSAP256 ¶
GenerateKeyECDSAP256 produces a fresh ECDSA P-256 keypair using crypto/rand and returns the encoded public/private material suitable for use with the Signature interface.
func GenerateKeyMLDSA44 ¶ added in v1.0.1
GenerateKeyMLDSA44 creates a randomized key pair for ML-DSA-44.
func GenerateKeyMLDSA65 ¶ added in v1.0.1
GenerateKeyMLDSA65 creates a randomized key pair for ML-DSA-65.
func GenerateKeyMLDSA87 ¶ added in v1.0.1
GenerateKeyMLDSA87 creates a randomized key pair for ML-DSA-87.
func GenerateKeyP256 ¶
func GenerateKeyP256() (*ecdsa.PrivateKey, error)
GenerateKeyP256 creates a new ECDSA P-256 keypair using crypto/rand.
func MarshalPrivateKey ¶
func MarshalPrivateKey(p *ecdsa.PrivateKey) []byte
MarshalPrivateKey returns the 32-byte scalar for priv.
func MarshalPublicKey ¶
MarshalPublicKey serialises pub as an uncompressed point.
func NewPrivateKey ¶
func NewPrivateKey(d []byte) (*ecdsa.PrivateKey, error)
NewPrivateKey constructs a private key from a scalar encoded as big-endian bytes.
func ParsePublicKey ¶
ParsePublicKey deserializes an uncompressed public key.
func ParseSignature ¶
ParseSignature decodes a DER-encoded ECDSA signature into r and s values.
func Sign ¶
func Sign(priv ed25519.PrivateKey, msg []byte) []byte
Sign produces an Ed25519 signature of msg using priv.
func SignASN1 ¶
func SignASN1(p *ecdsa.PrivateKey, hash []byte) ([]byte, error)
SignASN1 generates an ECDSA signature over hash using priv, returning DER encoding.
func SignECDSAP256 ¶
SignECDSAP256 signs msg using the provided encoded private scalar. The signature is returned in ASN.1 DER format matching crypto/ecdsa.SignASN1.
func SignWithOptions ¶ added in v1.0.1
SignWithOptions signs msg using priv with the supplied options. The returned signature is copied to a fresh slice.
func VerifyASN1 ¶
VerifyASN1 reports whether sig is a valid DER-encoded ECDSA signature for hash.
func VerifyECDSAP256 ¶
VerifyECDSAP256 checks whether signature is a valid ASN.1 DER encoded ECDSA signature over msg under the encoded uncompressed public key.
Types ¶
type Options ¶ added in v1.0.1
Options selects Ed25519 variants when signing or verifying with options.
type Signature ¶
type Signature interface {
// GenerateKey returns the encoded public and private key material.
GenerateKey() (public []byte, private []byte, err error)
// Sign produces a signature over msg using the encoded private key.
Sign(private []byte, msg []byte) ([]byte, error)
// Verify reports whether signature is valid for msg under the encoded public key.
Verify(public []byte, msg, signature []byte) bool
}
Signature defines the minimal single-shot signing API implemented by the signature helpers exposed under sig/.
func New ¶
func New() Signature
New returns a Signature for deterministic ECDSA over P-256 using DER signatures.
func NewDeterministicMLDSA44 ¶ added in v1.0.1
func NewDeterministicMLDSA44() Signature
NewDeterministicMLDSA44 returns ML-DSA-44 operating in deterministic mode.
func NewDeterministicMLDSA65 ¶ added in v1.0.1
func NewDeterministicMLDSA65() Signature
NewDeterministicMLDSA65 returns ML-DSA-65 operating in deterministic mode.
func NewDeterministicMLDSA87 ¶ added in v1.0.1
func NewDeterministicMLDSA87() Signature
NewDeterministicMLDSA87 returns ML-DSA-87 operating in deterministic mode.
func NewECDSAP256 ¶
func NewECDSAP256() Signature
NewECDSAP256 returns a Signature implementation backed by the helpers in p256.go. It exposes the P-256 ECDSA functionality under an explicit name without duplicating the underlying logic.
func NewEd25519 ¶
func NewEd25519() Signature
NewEd25519 returns a Signature backed by the Ed25519 helpers.
func NewMLDSA44 ¶ added in v1.0.1
func NewMLDSA44() Signature
NewMLDSA44 returns a Signature implementation for ML-DSA-44 (Dilithium-2).
func NewMLDSA65 ¶ added in v1.0.1
func NewMLDSA65() Signature
NewMLDSA65 returns a Signature implementation for ML-DSA-65 (Dilithium-3).
func NewMLDSA87 ¶ added in v1.0.1
func NewMLDSA87() Signature
NewMLDSA87 returns a Signature implementation for ML-DSA-87 (Dilithium-5).