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

Class Method Summary

Instance Method Summary

Instance methods inherited from module Sodium::Wipe

close close, finalize finalize

Constructor Detail

def self.new(key : Bytes, erase = false) #

Copies secret key to a SecureBuffer

DEPRECATED Use .copy_from or .move_from


[View source]
def self.new(key : Crypto::Secret) #

References existing Crypto::Secret


[View source]
def self.new #

DEPRECATED Use .random


[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 : Crypto::Secret) #

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


[View source]

Class Method Detail

def self.copy_from(key : Bytes) #

Copies secret key to a SecureBuffer


[View source]
def self.move_from(key : Bytes) #

Copies secret key to a SecureBuffer Erases key


[View source]
def self.random #

Generates a new random secret/public key pair.


[View source]

Instance Method Detail

def key : Crypto::Secret #

[View source]
def public_key : Sodium::Sign::PublicKey #

[View source]
def seed : Crypto::Secret #

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

Signs message and returns a combined signature. Verify using secret_key.public_key.verify(messagesig) Other verify methods exist. Review the docs and choose carefully

EXPERIMENTAL


[View source]
def sign_detached(message : Bytes, sig : Bytes | Nil = nil) : Bytes #

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

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 #

DEPRECATED Switching to Crypto::Secret. Use key.readonly or key.readwrite


[View source]