sodium.cr/spec/cox/sign/secret_key.cr
Didactic Drunk 0eb4a8991a Breaking API changes:
SignSecretKey rename to Sign::SecretKey
  SignPublicKey rename to Sign::PublicKey
  SignKeyPair removed.  Use Sign::SecretKey instead.

  Cox.sign_detached moved to Sign::SecretKey#sign_detached
  Cox.verify_detached moved to Sign::PublicKey#verify_detached

  verify_detached raises on failure instead of using a return value.

  More validation of data sizes.
2019-06-28 03:30:33 -07:00

23 lines
523 B
Crystal

require "../../spec_helper"
require "../../../src/cox/sign/secret_key"
describe Cox::Sign::SecretKey do
it "signs and verifies" do
message = "foo"
skey = Cox::Sign::SecretKey.new
sig = skey.sign_detached message
skey.public_key.verify_detached message, sig
end
it "signs and fails" do
message = "foo"
skey = Cox::Sign::SecretKey.new
sig = skey.sign_detached message
expect_raises Cox::Error::VerificationFailed do
skey.public_key.verify_detached "bar", sig
end
end
end