sm3 CLAUDE.md

A set of project instructions for building SM3, a cryptographic hash function, as a Swift package. It describes the required Swift version, implementation limits, and official algorithm details.

In plain words
What is it for?
Use it when developing or reviewing an all-Swift SM3 implementation, including its 256-bit hash output and standard-defined constants.
Why use it?
It gives the coding agent the rules needed to keep the implementation compatible with the SM3 standard and the project's technical requirements.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/ekscrypto/sm3/claude-md
Clone the repo
git clone --depth 1 https://github.com/ekscrypto/sm3
Per session 3,860 This file is loaded in full into every session.
When invoked 3,860 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.03860 $0.03860
Opus 5 $0.01930 $0.01930
Sonnet 5 $0.00772 $0.00772
Haiku 4.5 $0.00386 $0.00386

Measured 2d ago against content hash 7f8c30a899fe, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sm3 CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 436 lines

How it starts

The opening of the file, as written. The whole thing — 436 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SM3 Swift Implementation Project

Project Description

This project implements the ShangMi 3 (SM3) cryptographic hash algorithm as a Swift Package. The implementation must:

  • Use Swift 6.2
  • Be entirely implemented in Swift (no C or Objective-C)
  • No third-party libraries
  • Produce 256-bit hash values
  • Be compatible with official SM3 specifications

SM3 Algorithm Overview

SM3 is a cryptographic hash function published by the Chinese National Cryptography Administration on 2010-12-17 as GM/T 0004-2012: SM3 cryptographic hash algorithm. It is also standardized in:

  • GB/T 32905-2016 (Chinese standard)
  • ISO/IEC 10118-3:2018 (International standard)
  • IETF Draft: draft-sca-cfrg-sm3

Key Characteristics

  • Output Size: 256 bits (32 bytes)
  • Block Size: 512 bits (64 bytes)
  • Input Limit: Messages up to 2^64 bits
  • Construction: Merkle-Damgård with Davies-Meyer compression function
  • Security Level: Similar to SHA-256

Technical Specification

Constants

Initial Hash Value (IV)
0x7380166f, 0x4914b2b9, 0x172442d7, 0xda8a0600,
0xa96f30bc, 0x163138aa, 0xe38dee4d, 0xb0fb0e4e
Step Constants (T_j)
  • For j = 0 to 15: 0x79cc4519
  • For j = 16 to 63: 0x7a879d8a

Boolean Functions

FF_j (Message Schedule Function)
  • For j = 0 to 15: FF_j(X,Y,Z) = X ⊕ Y ⊕ Z
  • For j = 16 to 63: FF_j(X,Y,Z) = (X ∧ Y) ∨ (X ∧ Z) ∨ (Y ∧ Z)
GG_j (Compression Function)
  • For j = 0 to 15: GG_j(X,Y,Z) = X ⊕ Y ⊕ Z
  • For j = 16 to 63: GG_j(X,Y,Z) = (X ∧ Y) ∨ (¬X ∧ Z)

Permutation Functions

P₀(X)
P₀(X) = X ⊕ (X <<< 9) ⊕ (X <<< 17)

Where <<< denotes circular left shift (rotate left).

P₁(X)
P₁(X) = X ⊕ (X <<< 15) ⊕ (X <<< 23)

Algorithm Steps

1. Message Padding

Given a message M of length l bits:

  1. Append a single "1" bit to the message
  2. Append k "0" bits where k is the smallest non-negative solution to:
    l + 1 + k ≡ 448 (mod 512)
    
  3. Append the 64-bit big-endian representation of l
  4. Result: padded message with length ≡ 0 (mod 512)

Read the full file on GitHub · 436 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 436 lines · 3,860 tokens per session scan A 7f8c30a899fe

Subscribe to this mod's changes

sm3 CLAUDE.md is an instructions file published in the GitHub repository ekscrypto/sm3 (10 stars, last pushed 9mo ago), licensed MIT. It adds 3,860 tokens to every session, about $0.0193 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.