master
Didactic Drunk 2020-07-14 15:52:06 -07:00
parent 3d700b6157
commit c998625056
2 changed files with 16 additions and 0 deletions

View File

@ -76,6 +76,16 @@ describe Sodium::Sign::SecretKey do
message = "foo"
sskey = Sodium::Sign::SecretKey.new
cskey = sskey.to_curve25519
spkey = sskey.public_key
cpkey = spkey.to_curve25519
data = "foo".to_slice
cskey.box cpkey do |box|
enc, nonce = box.encrypt data
dec = box.decrypt enc, nonce: nonce
dec.should eq data
end
end
it "RbNaCl detached test vectors" do

View File

@ -35,6 +35,12 @@ module Sodium
end
end
def to_curve25519 : CryptoBox::PublicKey
pk = CryptoBox::PublicKey.new
LibSodium.crypto_sign_ed25519_pk_to_curve25519 pk.to_slice, @bytes
pk
end
module SerializeConverter
def self.to_json(value : PublicKey, json : JSON::Builder)
json.string Base64.strict_encode(value.to_slice)