---
title: "How we avoided side-channels in our new post-quantum Go cryptography libraries"
description: "Trail of Bits released pure-Go, open-source implementations of the NIST post-quantum signature schemes ML-DSA (FIPS-204) and SLH-DSA (FIPS-205), engineered to run in constant time."
url: "https://swe.quest/articles/how-we-avoided-side-channels-in-our-new-post-quantum-go-cryptography-libraries-8fe38a6e055d44ab"
canonical: "https://blog.trailofbits.com/2025/11/14/how-we-avoided-side-channels-in-our-new-post-quantum-go-cryptography-libraries/"
source: "Trail of Bits"
published: "2025-11-14"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 6
tags: ["cryptography","go","open-source"]
---

# How we avoided side-channels in our new post-quantum Go cryptography libraries

A post on [Trail of Bits](https://swe.quest/sources/trail-of-bits.md), published 2025-11-14, 6 min read, Deep dive. Original: [https://blog.trailofbits.com/2025/11/14/how-we-avoided-side-channels-in-our-new-post-quantum-go-cryptography-libraries/](https://blog.trailofbits.com/2025/11/14/how-we-avoided-side-channels-in-our-new-post-quantum-go-cryptography-libraries/)

## Summary

Trail of Bits released pure-Go, open-source implementations of the NIST post-quantum signature schemes ML-DSA (FIPS-204) and SLH-DSA (FIPS-205), engineered to run in constant time. SLH-DSA is hash-based and straightforward, but ML-DSA's Decompose step divides by 2γ2, and secret-dependent division and branching are what enabled the KyberSlash timing attack. The fix replaces branches with mask-based constant-time conditional swaps and replaces division with a bit-by-bit constant-time long division, then speeds that up with Barrett reduction using precomputed reciprocals for the two fixed γ2 values plus two branchless correction steps.

Written by swe.quest, not by the author.

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

## Topics

- [Cryptography](https://swe.quest/tags/cryptography.md) (Security)
- [Go](https://swe.quest/tags/go.md) (Languages)
- [Open source](https://swe.quest/tags/open-source.md) (Engineering practices)

## Prerequisites

- timing side-channel attacks
- two's complement bit manipulation
- modular arithmetic
- post-quantum signature schemes ([easy posts on Cryptography](https://swe.quest/tags/cryptography.md?difficulty=easy))

## Keywords

ML-DSA, SLH-DSA, FIPS-204, FIPS-205, KyberSlash, Barrett reduction, ML-KEM

## Related posts

- [Go Turns 17](https://swe.quest/articles/go-turns-17-44df44064c6960cc.md): The Go Blog · 2026-11-10 · Easy · 12 min read · Go, Performance engineering, Developer tools, Cryptography, Memory management
  Go's 17th anniversary recap covers Go 1.26 and 1.27. On the language side, it adds generic methods, self-referential constraints, \`new\` with an initial value, and nested struct literal keys.
- [Safeguarding cryptocurrency by disclosing quantum vulnerabilities responsibly](https://swe.quest/articles/safeguarding-cryptocurrency-by-disclosing-quantum-vulnerabilities-responsibly-1fee66e471cb8bf5.md): Google Research · 2026-03-31 · Hard · 5 min read · Cryptography, Security
  New resource estimates show Shor's algorithm can break 256-bit elliptic curve cryptography (ECDLP-256) using two compiled circuits.
- [From hand-tuned Go to self-optimizing code: Building BitsEvolve](https://swe.quest/articles/from-hand-tuned-go-to-self-optimizing-code-building-bitsevolve-65732e9f0f979e91.md): Datadog Engineering · 2025-09-18 · Medium · 17 min read · Performance engineering, Go, AI agents, Cost optimization, Compilers
  Datadog cut CPU in Go hot paths by removing compiler bounds checks in NormalizeTag (25% faster, 0.75% service CPU) and adding an ASCII fast path to NormalizeTagArbTagValue (90% faster, hundreds of thousands of dollars in projected annual savings), guided by production data showing nearly all inputs were ASCII.
- [Signal Protocol and Post-Quantum Ratchets](https://swe.quest/articles/signal-protocol-and-post-quantum-ratchets-12284f0594462a50.md): Signal · 2025-10-02 · Hard · 26 min read · Cryptography, Communications
  Signal adds the Sparse Post Quantum Ratchet (SPQR), a continuously advancing ML-KEM-based ratchet whose output is mixed with the existing Double Ratchet to form a "Triple Ratchet".
- [Post-quantum security for SSH access on GitHub](https://swe.quest/articles/post-quantum-security-for-ssh-access-on-github-48c898bb38241343.md): GitHub Engineering · 2025-09-15 · Medium · 3 min read · Cryptography, Networking
  GitHub is adding the hybrid post-quantum SSH key exchange sntrup761x25519-sha512 (Streamlined NTRU Prime combined with X25519 ECDH) to its Git SSH endpoints on September 17, 2025.

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)
