sodium.cr/src/cox/sign_key_pair.cr
2019-06-25 09:29:16 -07:00

24 lines
543 B
Crystal

require "./lib_sodium"
module Cox
class SignKeyPair
property public : SignPublicKey
property secret : SignSecretKey
def initialize(@public, @secret)
end
def self.new(pub : Bytes, sec : Bytes)
new(SignPublicKey.new(pub), SignSecretKey.new(sec))
end
def self.new
public_key = Bytes.new(SignPublicKey::KEY_SIZE)
secret_key = Bytes.new(SignSecretKey::KEY_SIZE)
LibSodium.crypto_sign_keypair(public_key.to_unsafe, secret_key.to_unsafe)
new(public_key, secret_key)
end
end
end