miaou — le blogv1.0.3

sig256.miaou

← Le code · src/outil/miaou/sig256.miaou · 24 lignes

(node sig256
  (params (x Nat) (k Nat))
  (returns Nat)
  (intent "les fonctions de SHA-256 sur le mot x : k = 0 σ0 (rotr 7, rotr 18, shr 3), 1 σ1 (rotr 17, rotr 19, shr 10), 2 Σ0 (rotr 2, 13, 22), 3 Σ1 (rotr 6, 11, 25)")
  (origin "phase 8f6 : le hasard de Python en miaou, d'après h_sha256 de l'outil inter")
  (effects)
  (uses b_xor3 b_rotr32 b_shr)
  (requires
    true)
  (ensures
    true)
  (examples
    (ex (1 0) 33570816)
    (ex (1 3) 69206144))
  (equivalence exact)
  (body.high
    (if (lt k 2)
      (if (eq k 0)
        (b_xor3 (b_rotr32 x 7) (b_rotr32 x 18) (b_shr x 3))
        (b_xor3 (b_rotr32 x 17) (b_rotr32 x 19) (b_shr x 10)))
      (if (eq k 2)
        (b_xor3 (b_rotr32 x 2) (b_rotr32 x 13) (b_rotr32 x 22))
        (b_xor3 (b_rotr32 x 6) (b_rotr32 x 11) (b_rotr32 x 25)))))
  (end node sig256))