Overview
This node provides utility functions for working with Nostr keys and events, focusing on key transformations and event conversions. It is useful in scenarios where you need to convert between different Nostr key formats (such as Bech32 and hex) or encode/decode event references. For example, if you have a secret key in hex format and want to convert it to the Bech32 "nsec" format, this node can perform that transformation. Similarly, it can convert an event JSON into special encoded references used in Nostr protocols.
Practical examples:
- Transforming a hex public key into a Bech32 npub key for easier sharing.
- Encoding an event into a "nevent" or "naddr" reference string for relay communication.
- Decrypting NIP-04 encrypted messages using a secret key credential.
Properties
| Name | Meaning |
|---|---|
| TransformTo | The target key format to transform the input into. Options: npub (Bech32 npub), nsec (Bech32 nsec from hex secret key), hexpubkey (hexadecimal public key), hexseckey (hexadecimal secret key from nsec). |
| TransformInput | The input key value to be transformed. This should be a string representing a key in one of the supported formats. |
| Npubnotice | Notice shown when transforming to npub: instructs to select input value from nsec or hexpubkey. |
| Nsecnotice | Notice shown when transforming to nsec: instructs to set hex secret key as input value. |
| Hexpubkeynotice | Notice shown when transforming to hexpubkey: instructs to select input value from npub, nsec, or hexseckey. |
| hexseckeynotice | Notice shown when transforming to hexseckey: instructs to set nsec as input value. |
Output
The output JSON structure depends on the operation:
- For the TransformKeys operation:
{ "output": "<transformed_key_string>", "type": "<target_format>" }output: The transformed key string in the requested format.type: The target format chosen (npub,nsec,hexpubkey, orhexseckey).
No binary data output is produced by this operation.
Dependencies
- Uses the
nostr-toolslibrary for encoding/decoding Nostr keys. - Uses helper modules for converting between key formats.
- No external API calls are made for the TransformKeys operation.
- Requires no credentials for the TransformKeys operation.
Troubleshooting
- Invalid transformTo value error: Occurs if the selected target format is not recognized. Ensure you select one of the valid options (
npub,nsec,hexpubkey,hexseckey). - Invalid input format: If the input key string does not match expected formats, the transformation may fail or produce incorrect results. Verify the input key is correct and corresponds to the expected source format.
- Empty or missing input: The
transformInputproperty is required. Make sure it is provided and non-empty. - Unexpected errors: If the underlying conversion functions throw errors, check that the input strings are properly formatted hex or Bech32 keys.