class Sodium::Sign::SecretKey

Overview

Ed25519 secret key used for signing.

https://libsodium.gitbook.io/doc/public-key_cryptography/public-key_signatures

Usage:

key = Sodium::Sign::SecretKey.new
sig = key.sign_detached data
key.public_key.verify_detached data, sig

Defined in:

sodium/sign/secret_key.cr

Constant Summary

KEY_SIZE = LibSodium.crypto_sign_secretkeybytes.to_i
SEED_SIZE = LibSodium.crypto_sign_seedbytes.to_i
SIG_SIZE = LibSodium.crypto_sign_bytes.to_i

Constructors

Instance Method Summary

Instance methods inherited from class Sodium::Key

to_slice : Bytes to_slice

Instance methods inherited from module Sodium::Wipe

close close, finalize finalize

Constructor Detail

def self.new(bytes : Bytes, pkey : Bytes? = nil, *, erase = false) #

Use existing secret and public keys. Copies secret key to a SecureBuffer. Recomputes the public key from a secret key if missing.


[View source]
def self.new #

Generates a new random secret/public key pair.


[View source]
def self.new(*, seed : Bytes, erase = false) #

Derive a new secret/public key pair based on a consistent seed. Copies seed to a SecureBuffer.


[View source]
def self.new(*, seed : SecureBuffer) #

Derive a new secret/public key pair based on a consistent seed.


[View source]

Instance Method Detail

def public_key : PublicKey #

[View source]
def seed : SecureBuffer? #

[View source]
def sign_detached(message : Bytes) #

[View source]
def sign_detached(message) #

Signs message and returns a detached signature. Verify using secret_key.public_key.verify_detached(message, sig)


[View source]
def to_curve25519 : CryptoBox::SecretKey #

[View source]
def to_slice : Bytes #

Returns key


[View source]