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 Encoding

31..20
imm[11:0]
19..15
rs1
14..12
funct3
11..7
rd
6..0
opcode

SM3P1 uses opcode 0010011 (0x13), funct3 001, funct7 0001101. The rs1 field selects the source register, the 12-bit immediate provides the second operand, and rd selects the destination.

Format: I-type
opcode: 0010011 (0x13)
funct3: 001 (0x1)
funct7: 0001101 (0x0d)

Instruction Behavior

sm3p1 is the Zksh SM3 hash P1 permutation instruction. Implements P1(x) = x ^ ROTL(x, 15) ^ ROTL(x, 23). Reads rs1, computes P1, writes to rd. P1 is used in SM3 message expansion for non-linear mixing of 32-bit words.

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 P1 transform from the SM3 hash algorithm with rotate amounts different from P0.
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
  • Confirm the current instruction format is I-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

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 is a low-level step from AES, SHA, SM3, or SM4; software still combines instructions with the algorithm schedule, round constants, or round keys.