@smartforge/crypto
v1.0.1
Published
Cryptographic utilities for Ethereum signatures and address handling.
Readme
@smartforge/crypto
Cryptographic utilities for Ethereum signatures and address handling.
Installation
npm install @smartforge/crypto
# or
pnpm add @smartforge/cryptoUsage
import {
hashMessage,
verifySignature,
recoverAddress,
formatAddress,
isValidAddress,
} from "@smartforge/crypto";
// Hash a message using EIP-191
const message = "Hello, World!";
const hash = hashMessage(message);
// Verify a signature
const signature = "0x...";
const address = "0x...";
const isValid = verifySignature(message, signature, address);
// Recover address from signature
const recovered = recoverAddress(message, signature);
// Format address with checksum
const checksummed = formatAddress("0x1234...");
// Validate address format
const valid = isValidAddress("0x1234...");API
hashMessage(message: string): Uint8Array
Hashes a message using EIP-191 standard (Ethereum Signed Message prefix).
verifySignature(message: string, signature: string, address: string): boolean
Verifies that a signature was created by the given address for the message.
recoverAddress(message: string, signature: string): string
Recovers the Ethereum address from a message and signature.
formatAddress(address: string): string
Formats an address with EIP-55 checksum encoding.
isValidAddress(address: string): boolean
Validates that a string is a valid Ethereum address format.
License
ISC
