2017-07-12 05:13:52 +02:00
|
|
|
require "./lib_sodium"
|
|
|
|
|
|
|
|
module Cox
|
|
|
|
class PublicKey < Key
|
|
|
|
property bytes : Bytes
|
|
|
|
|
2019-06-25 18:29:16 +02:00
|
|
|
KEY_SIZE = LibSodium::PUBLIC_KEY_SIZE
|
2017-07-12 05:13:52 +02:00
|
|
|
|
|
|
|
def initialize(@bytes : Bytes)
|
2019-06-25 18:29:16 +02:00
|
|
|
if bytes.bytesize != KEY_SIZE
|
|
|
|
raise ArgumentError.new("Public key must be #{KEY_SIZE} bytes, got #{bytes.bytesize}")
|
2017-07-12 05:13:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|