signHash method

  1. @override
Future<Uint8List> signHash(
  1. Uint8List hash
)
override

Signs a raw hash directly without any prefix.

Use this for:

  • ERC-4337 UserOperation signing (userOpHash is already a 32-byte hash)
  • Any case where you need to sign a pre-computed hash

WARNING: The hash should be exactly 32 bytes. This method does NOT add any prefix (unlike signMessage which adds EIP-191 prefix).

Implementation

@override
Future<Uint8List> signHash(Uint8List hash) async {
  // Sign raw hash directly without any prefix
  // Used for ERC-4337 UserOperation signing
  if (hash.length != 32) {
    throw ArgumentError('Hash must be exactly 32 bytes');
  }
  return Secp256k1.sign(hash, privateKey);
}