cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cometa.Crypto.Ed25519.PublicKey

Description

Ed25519 public keys as immutable 32-byte values. Import checks encoded length; it does not establish that a key belongs to a particular person or that a signature verifies. Use verify to check a message and signature.

import qualified Cometa.Crypto.Ed25519.PublicKey as PublicKey

roundTrip :: PublicKey.PublicKey -> Bool
roundTrip value = PublicKey.fromBytes (PublicKey.toBytes value) == Right value
Synopsis

Documentation

data PublicKey Source #

An immutable 32-byte Ed25519 public key. Equality compares bytes; ordering is lexicographic byte ordering. Show is diagnostic; use toHex for a stable textual representation.

Import

fromBytes :: ByteString -> Either Error PublicKey Source #

Import exactly 32 bytes. Other lengths return InvalidEd25519PublicKeyLength. Only length is validated; this constructor does not check curve-point validity.

fromHex :: Text -> Either Error PublicKey Source #

Import 64 ASCII hexadecimal digits, accepting either case. No whitespace or prefix is accepted. Empty, odd-length or nonhexadecimal text returns InvalidHex; valid hex of another byte length returns InvalidEd25519PublicKeyLength.

Inspection

toBytes :: PublicKey -> ByteString Source #

Retrieve the exact encoded bytes.

toHex :: PublicKey -> Text Source #

Render lowercase ASCII hexadecimal digits without a prefix or whitespace.

byteLength :: PublicKey -> Int Source #

Encoded byte length, always 32.

hexLength :: PublicKey -> Int Source #

Hexadecimal digit count, always 64. No terminator is included.

Verification and hashing

verify :: PublicKey -> ByteString -> Signature -> IO (Either Error Bool) Source #

Check an Ed25519 signature for the exact message bytes. Empty messages and embedded NUL bytes are supported. Right True means verification succeeded; Right False means it did not. Allocation or other operation failures return NativeError. This operation uses ordinary Ed25519 on the supplied message.

hash :: PublicKey -> IO (Either Error Blake2bHash) Source #

Compute the 28-byte BLAKE2b-224 digest of the encoded public key. The result is a general digest, without a payment/stake role distinction. Operation failures return NativeError.