| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Crypto.Bip32.PublicKey
Description
Cardano Ed25519-BIP32 public keys: a 32-byte verification key followed by a 32-byte chain code. These are not secp256k1 Bitcoin BIP32 keys. Import validates length only; an invalid curve point can fail later derivation.
import qualified Cometa.Crypto.Bip32.PublicKey as PublicKey roundTrip key = PublicKey.fromBytes (PublicKey.toBytes key) == Right key
Synopsis
- data PublicKey
- fromBytes :: ByteString -> Either Error PublicKey
- fromHex :: Text -> Either Error PublicKey
- toBytes :: PublicKey -> ByteString
- toHex :: PublicKey -> Text
- byteLength :: PublicKey -> Int
- hexLength :: PublicKey -> Int
- derive :: PublicKey -> [Word32] -> IO (Either Error PublicKey)
- toEd25519 :: PublicKey -> PublicKey
- hash :: PublicKey -> IO (Either Error Blake2bHash)
Documentation
Immutable 64-byte public key and chain code. Equality compares exact bytes;
ordering is lexicographic. Show is diagnostic; toHex is stable serialization.
Instances
| Show PublicKey Source # | |
| Eq PublicKey Source # | |
| Ord PublicKey Source # | |
Import and serialization
fromBytes :: ByteString -> Either Error PublicKey Source #
Import exactly 64 bytes; other lengths return InvalidBip32PublicKeyLength.
Curve-point validity is not checked.
fromHex :: Text -> Either Error PublicKey Source #
Import 128 ASCII hex digits in either case, without prefix or whitespace.
Empty or malformed text returns InvalidHex; a well-formed wrong length returns
InvalidBip32PublicKeyLength.
toBytes :: PublicKey -> ByteString Source #
Retrieve all 64 bytes, including the chain code.
toHex :: PublicKey -> Text Source #
Render 128 lowercase ASCII hexadecimal digits without prefix or whitespace.
byteLength :: PublicKey -> Int Source #
Encoded length, always 64 bytes.
Derivation and conversion
derive :: PublicKey -> [Word32] -> IO (Either Error PublicKey) Source #
Derive a path in order. Each encoded index must be in 0..2^31-1;
any high-bit (hardened) index returns HardenedPublicDerivation before native
work. An empty path returns the original value. Native derivation failures
return NativeError. The source is unchanged.