class Sodium::Sign::SecretKey
- Sodium::Sign::SecretKey
- Sodium::Key
- Reference
- Object
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.crConstant 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
-
.new(key : Bytes, erase = false)
Copies secret key to a
SecureBuffer
DEPRECATED Use .copy_from or .move_from
-
.new(key : Crypto::Secret)
References existing Crypto::Secret
-
.new
DEPRECATED Use .random
-
.new(*, seed : Bytes, erase = false)
Derive a new secret/public key pair based on a consistent seed.
-
.new(*, seed : Crypto::Secret)
Derive a new secret/public key pair based on a consistent seed.
Class Method Summary
-
.copy_from(key : Bytes)
Copies secret key to a
SecureBuffer
-
.move_from(key : Bytes)
Copies secret key to a
SecureBuffer
Erases key -
.random
Generates a new random secret/public key pair.
Instance Method Summary
- #key : Crypto::Secret
- #public_key : Sodium::Sign::PublicKey
- #seed : Crypto::Secret
-
#sign(message) : Bytes
Signs message and returns a combined signature.
EXPERIMENTAL
- #sign_detached(message : Bytes, sig : Bytes | Nil = nil) : Bytes
-
#sign_detached(message) : Bytes
Signs message and returns a detached signature.
- #to_curve25519 : CryptoBox::SecretKey
-
#to_slice : Bytes
DEPRECATED Switching to Crypto::Secret. Use
key.readonly
orkey.readwrite
Constructor Detail
Copies secret key to a SecureBuffer
DEPRECATED Use .copy_from or .move_from
Derive a new secret/public key pair based on a consistent seed.
Copies seed to a SecureBuffer
Derive a new secret/public key pair based on a consistent seed.
References passed SecureBuffer
Class Method Detail
Instance Method Detail
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
Signs message and returns a detached signature.
Verify using secret_key.public_key.verify_detached(message, sig)