Home/Instructions/SM3 Permutation P1
SM3P1

RISC-V SM3P1 Instruction Details

Instruction ManualI-type

SM3 hash P1 permutation: P1(x) = x ^ ROTL(x,15) ^ ROTL(x,23)

Instruction Syntax

sm3p1 rd, rs1
Operand Breakdown
Destination rd: general-purpose register receiving the result.
Source rs1: register holding the first operand.
Immediate imm: 12-bit signed value, sign-extended before operation with rs1.
ZkshCrypto & Security

Instruction Behavior

sm3p1 is the Zksh SM3 hash P1 transform instruction. It implements P1(x) = x ^ ROTL(x, 15) ^ ROTL(x, 23): it reads the low 32 bits of rs1, computes the result, and writes rd; RV64 sign-extends that result to XLEN. P1 is a transform used by the SM3 hash function.

SM3P1 Decode And Execute Animation

Bounded teaching inputs execute the official SM3 fixed-width bit operations; this does not model a complete algorithm or microarchitecture.

rd
rs1
sm3p1
,

SM3P1 is defined in RV32/RV64; RV64 uses X(rs1)[31:0] and sign-extends the 32-bit result to XLEN.

fixed selector
source
fixed
destination
OP-IMM
31..20
000100001001
19..15
rs1=x11
14..12
001
11..7
rd=x10
6..0
0010011
Execution Data Path
inb
0x89ABCDEF
rol32(inb, 15)
0xE6F7C4D5
rol32(inb, 23)
0xF7C4D5E6
result
0x11331133
Architectural Result
a0(x10) = 0x11331133

This animation shows only official ISA fields and architectural state; it does not model a complete hash algorithm, pipeline, cache, or timing implementation.

Quick Understanding & Search Notes

SM3P1 is a Zksh scalar cryptography instruction for SM3 P1 transform. This page is checked against the official scalar crypto extension, avoiding confusion among round functions, key schedule steps, and operand sources.

Performs the SM3 P1 transform from rs1[31:0] with rotate-left amounts 15 and 23; RV64 sign-extends the result.
Scalar crypto instructions use integer X registers, and the official spec requires the relevant crypto instructions to be implemented with data-independent execution latency.

Common Usage Scenarios

Crypto & Security

Understand this scenario with real code like «sm3p1 a0, a1».

Chinese National Crypto

Understand this scenario with real code like «sm3p1 a0, a1».

Pre-Use Checklist

Syntax Check
  • Verify the immediate field is within the valid range.
  • Confirm source register rs1 points to the correct operand.
Semantic Check
  • Check if the immediate sign-extension matches expectations.
  • Ensure the result register rd has a clear purpose.

Pitfalls / Common Confusions

P1 differs from P0 in shift amounts: (15,23) vs (9,17).
Uses rotate-left (ROTL), not right shift.

FAQ

Does SM3P1 use floating-point or vector registers?

No. These scalar crypto extension instructions use integer X registers.

Is SM3P1 a complete algorithm implementation?

No. It implements only the SM3 P1 transform; software still combines the required operations for its SM3 algorithm flow.