---
title: "Accelerating zk-SNARKs - MSM and NTT algorithms on FPGAs with Hardcaml"
description: "A Hardcaml-built FPGA implementation of Pippenger's algorithm for multi-scalar multiplication on the BLS12-377 curve won first place in the ZPrize MSM track, computing a 2^26-point MSM in about 5.08s on an AWS f1.2xlarge at 52W."
url: "https://swe.quest/articles/accelerating-zk-snarks-msm-and-ntt-algorithms-on-fpgas-with-hardcaml-e0e40be298934874"
canonical: "https://blog.janestreet.com/zero-knowledge-fpgas-hardcaml/"
source: "Jane Street Tech Blog"
published: "2022-12-07"
difficulty: "hard"
kind: "Research"
reading_minutes: 8
tags: ["hardware","cryptography","algorithms","performance","functional-programming"]
---

# Accelerating zk-SNARKs - MSM and NTT algorithms on FPGAs with Hardcaml

A post on [Jane Street Tech Blog](https://swe.quest/sources/jane-street.md), published 2022-12-07, 8 min read, Research. Original: [https://blog.janestreet.com/zero-knowledge-fpgas-hardcaml/](https://blog.janestreet.com/zero-knowledge-fpgas-hardcaml/)

## Summary

A Hardcaml-built FPGA implementation of Pippenger's algorithm for multi-scalar multiplication on the BLS12-377 curve won first place in the ZPrize MSM track, computing a 2^26-point MSM in about 5.08s on an AWS f1.2xlarge at 52W. Its core is a 200+ stage pipelined elliptic curve point adder whose controller stalls on bucket data hazards instead of flushing the pipeline, with the host combining partial bucket sums in parallel with the next round. A companion NTT design uses the 4-step algorithm to split a 2^24 NTT into 2^12 Cooley-Tukey transforms that fit in on-chip SRAM, running on clusters of 8 cores matched to the 512-bit HBM bus. It placed second, scaling from 0.23s at 8 cores to 0.045s at 64 cores, with power and resource figures reported for each configuration.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)
- [Cryptography](https://swe.quest/tags/cryptography.md) (Security)
- [Algorithms](https://swe.quest/tags/algorithms.md) (Architecture & design)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Functional programming](https://swe.quest/tags/functional-programming.md) (Languages)

## Prerequisites

- elliptic curve arithmetic
- FPGA pipelining
- FFT basics
- finite field arithmetic

## Keywords

Hardcaml, ZPrize, zk-SNARK, Pippenger's algorithm, Number Theoretic Transform, BLS12-377, AWS F1, Xilinx UltraScale+

## Related posts

- [Towards Encrypted Large Language Models with FHE](https://swe.quest/articles/towards-encrypted-large-language-models-with-fhe-6e22ac5193234b25.md): Hugging Face · 2023-08-02 · Hard · 7 min read · Cryptography, Privacy, Inference & serving, LLMs
  A single attention head of GPT2's first multi-head attention layer can run on encrypted data using TFHE via Zama's Concrete-Python and Concrete-ML, with the rest of the model executing in plaintext on the client.
- [Advent of Hardcaml](https://swe.quest/articles/advent-of-hardcaml-7a69fcd00d2b9f17.md): Jane Street Tech Blog · 2025-03-22 · Hard · 8 min read · Hardware, Functional programming, Algorithms
  Several Advent of Code 2024 puzzles were solved entirely on a small Lattice ECP5 FPGA (84K LUTs, 4 Mbits RAM) using Hardcaml, Jane Street's OCaml-embedded HDL, with the open-source Yosys + NextPNR toolchain.
- [A Gentle Introduction to 8-bit Matrix Multiplication for transformers at scale using transformers, accelerate and bitsandbytes](https://swe.quest/articles/a-gentle-introduction-to-8-bit-matrix-multiplication-for-transformers-at-scale-af5b5f40a9067e95.md): Hugging Face · 2022-08-17 · Medium · 21 min read · Inference & serving, LLMs, Machine learning, Hardware
  LLM.int8() makes 8-bit inference of 175B-class transformers possible with no measurable quality loss.
- [Arm & ExecuTorch 0.7: Bringing Generative AI to the masses](https://swe.quest/articles/arm-executorch-0-7-bringing-generative-ai-to-the-masses-e0cdd6bbe1a2cf4d.md): Hugging Face · 2025-08-13 · Easy · 4 min read · Inference & serving, Hardware, LLMs, Mobile, Performance engineering
  ExecuTorch 0.7 beta enables Arm KleidiAI by default through XNNPack, bringing optimized Int4 matrix multiplication to Arm CPUs with no code changes.
- [FlashAttention-4: Algorithm and Kernel Pipelining Co-Design for Asymmetric Hardware Scaling](https://swe.quest/articles/flashattention-4-algorithm-and-kernel-pipelining-co-design-for-asymmetric-67fe95e5005d9861.md): Together AI · 2026-03-05 · Hard · 11 min read · Inference & serving, Performance engineering, Hardware, Model training, LLMs
  FlashAttention-4 is an attention kernel co-designed for Blackwell GPUs, where tensor core throughput grew much faster than the exponential (SFU) units and shared memory bandwidth.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
