text‹We define the encoding and decoding operations for the probabilistic
signature scheme. Finally we show, that encoded messages always can be
verified›
definition show_rightmost_bits:: "bv → nat → bv"(* extract n rightmost bits of a bit string*) where"show_rightmost_bits bvec n = rev (take n (rev bvec))"
definition generate_H:: "bv → nat → nat → bv"(* generate_H returns a bit string of length (sha1 _) *) where"generate_H EM emBits hLen = take hLen (drop ((roundup emBits 8)*8 - hLen - 8) EM)"
definition generate_maskedDB:: "bv → nat → nat → bv "(* outputs a bit string of length "nat (roundup emBits 8) * 8 - length (sha1 _) - 8" *) where"generate_maskedDB EM emBits hLen = take ((roundup emBits 8)*8 - hLen - 8) EM"
definition generate_salt:: "bv → bv"(* outputs a bit string of length sLen *) where"generate_salt DB_zero = show_rightmost_bits DB_zero sLen"
primrec MGF2:: "bv → nat → bv"(* help function for MGF1 *) where "MGF2 Z 0 = sha1 (Z@(nat_to_bv_length 0 32))"
| "MGF2 Z (Suc n) = (MGF2 Z n)@(sha1 (Z@(nat_to_bv_length (Suc n) 32)))"
definition MGF1:: "bv → nat → nat → bv"(* help function for MGF *) where"MGF1 Z n l = take l (MGF2 Z n)"
definition MGF:: "bv → nat → bv"(* mask generation function *) where "MGF Z l = (if l = 0 ∨ 2^32*(length (sha1 Z)) < l then [] else MGF1 Z ( roundup l (length (sha1 Z)) - 1 ) l)"
definition emsapss_encode_help8:: "bv → bv → bv" where"emsapss_encode_help8 DBzero H = DBzero @ H @ BC"
definition emsapss_decode_help3:: "bv → bv → nat → bool" where"emsapss_decode_help3 mHash EM emBits = emsapss_decode_help4 mHash (generate_maskedDB EM emBits (length mHash)) (generate_H EM emBits (length mHash)) emBits"
definition emsapss_decode_help2:: "bv → bv → nat → bool" where"emsapss_decode_help2 mHash EM emBits = (if show_rightmost_bits EM 8 ≠ BC then False else emsapss_decode_help3 mHash EM emBits)"
definition emsapss_decode_help1:: "bv → bv → nat → bool" where"emsapss_decode_help1 mHash EM emBits = (if emBits < length (mHash) + sLen + 16 then False else emsapss_decode_help2 mHash EM emBits)"
definition emsapss_decode:: "bv → bv → nat → bool"(* outputs "true" if EM is encoding of M *) where"emsapss_decode M EM emBits = (if (2^64 ≤ length M ∨ 2^32*160<emBits) then False else emsapss_decode_help1 (sha1 M) EM emBits)"
lemma bv_prepend_equal: "bv_prepend (Suc n) b l = b#bv_prepend n b l" by (simp add: bv_prepend)
lemma length_bv_prepend: "length (bv_prepend n b l) = n+length l" by (induct n) (simp_all add: bv_prepend)
lemma length_bv_prepend_drop: "a <= length xs ⟶ length (bv_prepend a b (drop a xs)) = length xs" by (simp add:length_bv_prepend)
lemma take_bv_prepend: "take n (bv_prepend n b x) = bv_prepend n b []" by (induct n) (simp add: bv_prepend)+
lemma take_bv_prepend2: "take n (bv_prepend n b xs@ys@zs) = bv_prepend n b []" by (induct n) (simp add: bv_prepend)+
lemma bv_prepend_append: "bv_prepend a b x = bv_prepend a b [] @ x" by (induct a) (simp add: bv_prepend, simp add: bv_prepend_equal)
lemma bv_prepend_append2: "x < y ==> bv_prepend y b xs = (bv_prepend x b [])@(bv_prepend (y-x) b [])@xs" by (simp add: bv_prepend replicate_add [symmetric])
lemma drop_bv_prepend_help2: "[x < y]==> drop x (bv_prepend y b []) = bv_prepend (y-x) b []" apply (insert bv_prepend_append2 [of "x""y" b "[]"]) by (simp add: length_bv_prepend)
lemma drop_bv_prepend_help3: "[x = y]==> drop x (bv_prepend y b []) = bv_prepend (y-x) b []" apply (insert length_bv_prepend [of y b "[]"]) by (simp add: bv_prepend)
lemma drop_bv_prepend_help4: "[x ≤ y]==> drop x (bv_prepend y b []) = bv_prepend (y-x) b []" apply (insert drop_bv_prepend_help2 [of x y b] drop_bv_prepend_help3 [of x y b]) by (arith)
lemma bv_prepend_add: "bv_prepend x b [] @ bv_prepend y b [] = bv_prepend (x + y) b []" by (induct x) (simp add: bv_prepend)+
lemma bv_prepend_drop: "x ≤ y ⟶ bv_prepend x b (drop x (bv_prepend y b [])) = bv_prepend y b []" apply (simp add: drop_bv_prepend_help4 [of x y b]) by (simp add: bv_prepend_append [of "x" b "(bv_prepend (y - x) b [])"] bv_prepend_add)
lemma bv_prepend_split: "bv_prepend x b (left @ right) = bv_prepend x b left @ right" by (induct x) (simp add: bv_prepend)+
lemma drop_bv_mapzip: assumes"n <= length x""length x = length y" shows"drop n (bv_mapzip f x y) = bv_mapzip f (drop n x) (drop n y)" proof - have"∧x y. n <= length x ==> length x = length y ==> drop n (bv_mapzip f x y) = bv_mapzip f (drop n x) (drop n y)" apply (induct n) apply simp apply (case_tac x, case_tac[!] y, auto) done with assms show ?thesis by simp qed
lemma [simp]: assumes"length a = length b" shows"bvxor (bvxor a b) b = a" proof - have"∧b. length a = length b ==> bvxor (bvxor a b) b = a" apply (induct a) apply (auto simp add: bvxor) apply (case_tac b) apply (simp)+ apply (case_tac a1) apply (case_tac a) apply (safe) apply (simp)+ apply (case_tac a) apply (simp)+ done with assms show ?thesis by simp qed
lemma bvxorxor_elim_help: assumes"x <= length a"and"length a = length b" shows"bv_prepend x 0 (drop x (bvxor (bv_prepend x 0 (drop x (bvxor a b))) b)) = bv_prepend x 0 (drop x a)" proof - have"drop x (bvxor (bv_prepend x 0 (drop x (bvxor a b))) b) = drop x a" apply (unfold bvxor bv_prepend) apply (cut_tac assms) apply (insert length_replicate [of x 0 ]) apply (insert length_drop [of x a]) apply (insert length_drop [of x b]) apply (insert length_bvxor [of "drop x a""drop x b"]) apply (subgoal_tac "length (replicate x 0 @ drop x (bv_mapzip (⊕b) a b)) = length b") apply (subgoal_tac "b = (take x b)@(drop x b)") apply (insert drop_bv_mapzip [of x "(replicate x 0 @ drop x (bv_mapzip (⊕b) a b))" b "(⊕b)"]) apply (simp) apply (insert drop_bv_mapzip [of x a b "(⊕b)"]) apply (simp) apply (fold bvxor) apply (simp_all) done with assms show ?thesis by simp qed
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.20Bemerkung:
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.