Features Digest Sizes Quick Start How It Works Packages GitHub
Open-Source · .NET 10

Texnomic.Keccak

A managed .NET 10 implementation of the Keccak family (224 / 256 / 384 / 512) using the original Keccak padding adopted by Ethereum — not FIPS-202 SHA-3. Allocation-free ref struct hasher, fully unrolled Keccak-f[1600], Span-based API.

NuGet
Downloads
GitHub Stars
License
Program.cs
using Texnomic.Keccak;

byte[] Digest = Keccak.Hash256("abc"u8);

// 4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45
Console.WriteLine(Convert.ToHexString(Digest));
Scroll to explore

Built for Ethereum.
Shaped like HashAlgorithm.

A familiar managed surface, allocation-free under the hood. Every hash matches the Keccak variant that Ethereum and the EVM speak — not the post-FIPS SHA-3.

Original Keccak Padding

The 0x01 .. 0x80 padding rule used by Ethereum, Solidity keccak256, and the EVM — distinct from FIPS-202 SHA-3's 0x06 .. 0x80.

Allocation-Free Hot Path

A ref struct hasher backed by inline arrays. State and buffer live on the stack — no array-pool rentals, no GC traffic.

Span-Based API

ReadOnlySpan<byte> in, Span<byte> out. Hash UTF-8 literals ("abc"u8), stack-allocated buffers, or slices — no copies.

Fully Unrolled Permutation

Keccak-f[1600] with 24 inlined rounds across all 25 lanes. Hot for the JIT, friendly to the branch predictor.

KAT-Verified

Standard Keccak vectors (empty, "abc", 1 M a) plus incremental-vs-one-shot equivalence across all four digest sizes.

Modern .NET 10 + C# Latest

Nullable-enabled, inline arrays, TreatWarningsAsErrors, deterministic builds, SourceLink, and symbol packages.

Four Widths.
One Permutation.

Pick the digest size you need — the rate adjusts automatically (r = 1600 - 2d). Same Keccak-f[1600] core under all four.

Keccak-224

28-byte digest. Rate 1152 bits. Keccak.Hash224 or KeccakSize.Bits224.

Keccak-256

32-byte digest. Rate 1088 bits. Ethereum's hash — addresses, EIP-712, Solidity keccak256.

Keccak-384

48-byte digest. Rate 832 bits. Keccak.Hash384 or KeccakSize.Bits384.

Keccak-512

64-byte digest. Rate 576 bits. Keccak.Hash512 or KeccakSize.Bits512.

Incremental Hashing

KeccakHasher.Update(...) across any number of chunks. Stream files, network frames, or buffered protocol messages.

Dynamic Size

Keccak.Hash(Data, KeccakSize.BitsXxx) — pick the width at runtime from a config value or protocol field.

Three lines from install to digest.

No native dependency. No P/Invoke. Just a NuGet install and a Span-shaped API.

01

Install the package

Pure managed code — runs anywhere .NET 10 runs.

dotnet PackageReference
$ dotnet add package Texnomic.Keccak
02

One-shot a digest

Static helpers cover all four widths. Hash UTF-8 literals, byte arrays, or any ReadOnlySpan<byte>.

C#
using Texnomic.Keccak;

byte[] D224 = Keccak.Hash224(Data);   // 28 bytes
byte[] D256 = Keccak.Hash256(Data);   // 32 bytes — Ethereum's hash
byte[] D384 = Keccak.Hash384(Data);   // 48 bytes
byte[] D512 = Keccak.Hash512(Data);   // 64 bytes

// Or hash into a caller-supplied buffer (zero allocation):
Span<byte> Out = stackalloc byte[32];
Keccak.HashTo("abc"u8, KeccakSize.Bits256, Out);
03

Or stream it

For multi-chunk inputs use the incremental KeccakHasher. It's a ref struct — lives on the stack, no GC pressure.

C#
KeccakHasher Hasher = new(KeccakSize.Bits256);

Hasher.Update(BlockA);
Hasher.Update(BlockB);

Span<byte> Digest = stackalloc byte[32];
Hasher.Finish(Digest);

The Sponge Construction

Keccak is a sponge: the message is absorbed into a 1600-bit state in r-bit blocks, then the digest is squeezed out. The padding byte is the only thing that separates this from FIPS-202 SHA-3.

Layer 1 · Absorb
XOR input into rate r = 1600 − 2d Block size = r/8 bytes Original padding (0x01 .. 0x80)
Layer 2 · Permute · Keccak-f[1600]
5 × 5 × 64 state 24 rounds θ · ρ · π · χ · ι Fully unrolled
Layer 3 · Squeeze
Read first d bytes of state Little-endian lanes Single squeeze (d ≤ rate)
Verify · Known-Answer Tests
Empty input "abc" 1 000 000 × 'a' Incremental ≡ one-shot

Pure Managed.

No native dependency, no per-RID sub-package. Runs anywhere .NET 10 runs — including Native AOT.

Windows x64 · arm64
Linux x64 · arm64
macOS x64 · arm64

No runtime sub-packages

Pure managed C#
Native AOT-ready
Single nupkg

One Package on NuGet

No runtime sub-packages. No native binaries. Just install Texnomic.Keccak and start hashing.

Need keccak256 in .NET?

Install the package. Hash a span. Get back the exact bytes that the EVM would.