Hedera.PrivateKey (Hedera v0.1.0)

Copy Markdown View Source

A Hedera private key — Ed25519 or ECDSA secp256k1.

Signing follows Hedera's conventions: Ed25519 signs the message bytes directly; ECDSA secp256k1 signs the Keccak-256 digest of the message and returns the canonical 64-byte r ‖ s (low-S) signature.

Summary

Functions

Parse a 32-byte ECDSA secp256k1 private key from a hex string (0x optional).

Parse a 32-byte Ed25519 private key from a hex string (0x optional).

Generate a new ECDSA secp256k1 private key.

Generate a new Ed25519 private key.

Derive the corresponding public key.

Sign a message with Hedera's per-key-type convention.

Lowercase hex (no 0x) of the raw private key bytes.

Types

key_type()

@type key_type() :: :ed25519 | :ecdsa_secp256k1

t()

@type t() :: %Hedera.PrivateKey{bytes: binary(), type: key_type()}

Functions

from_string_ecdsa(hex)

@spec from_string_ecdsa(binary()) :: t()

Parse a 32-byte ECDSA secp256k1 private key from a hex string (0x optional).

from_string_ed25519(hex)

@spec from_string_ed25519(binary()) :: t()

Parse a 32-byte Ed25519 private key from a hex string (0x optional).

generate_ecdsa()

@spec generate_ecdsa() :: t()

Generate a new ECDSA secp256k1 private key.

generate_ed25519()

@spec generate_ed25519() :: t()

Generate a new Ed25519 private key.

public_key(private_key)

@spec public_key(t()) :: Hedera.PublicKey.t()

Derive the corresponding public key.

sign(private_key, message)

@spec sign(t(), binary()) :: binary()

Sign a message with Hedera's per-key-type convention.

to_string(private_key)

@spec to_string(t()) :: binary()

Lowercase hex (no 0x) of the raw private key bytes.