From f0213b88c8dec2c3e5b900c90e6670266318655f Mon Sep 17 00:00:00 2001 From: Didactic Drunk <1479616+didactic-drunk@users.noreply.github.com> Date: Sat, 18 Jul 2020 22:21:09 -0700 Subject: [PATCH] Expose Sodium::Sign::SecretKey#seed. --- spec/sodium/sign/secret_key_spec.cr | 2 ++ src/sodium/sign/secret_key.cr | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/spec/sodium/sign/secret_key_spec.cr b/spec/sodium/sign/secret_key_spec.cr index 8ab8327..4af7cf6 100644 --- a/spec/sodium/sign/secret_key_spec.cr +++ b/spec/sodium/sign/secret_key_spec.cr @@ -52,6 +52,8 @@ describe Sodium::Sign::SecretKey do key2 = Sodium::Sign::SecretKey.new seed: seed key1.to_slice.should eq key2.to_slice key1.public_key.to_slice.should eq key2.public_key.to_slice + key1.seed.should eq seed + key1.seed.should eq key2.seed end it "signs and verifies" do diff --git a/src/sodium/sign/secret_key.cr b/src/sodium/sign/secret_key.cr index 9e158de..0891218 100644 --- a/src/sodium/sign/secret_key.cr +++ b/src/sodium/sign/secret_key.cr @@ -70,6 +70,11 @@ module Sodium end end + def seed + # BUG: Generate seed if not set. + @seed.not_nil!.to_slice + end + # Signs message and returns a detached signature. # Verify using `secret_key.public_key.verify_detached(message, sig)` def sign_detached(message)