text‹
This theory defines the rsacrypt function which implements RSA using fast
exponentiation. An proof, that this function calculates RSA is also given ›
definition rsa_crypt :: "nat ==> nat ==> nat ==> nat" where
cryptcorrect: "rsa_crypt M e n = M ^ e mod n"
lemma rsa_crypt_code [code]: "rsa_crypt M e n = (if e = 0 then 1 mod n else if even e then rsa_crypt M (e div 2) n ^ 2 mod n else (M * rsa_crypt M (e div 2) n ^ 2 mod n) mod n)" proof -
{ fix m have"(M ^ m mod n)2 mod n = (M ^ m)2 mod n" by (simp add: power_mod) thenhave"(M mod n) * ((M ^ m mod n)2 mod n) = (M mod n) * ((M ^ m)2 mod n)" by simp have"M * (M ^ m mod n)2 mod n = M * (M ^ m)2 mod n" by (metis mod_mult_right_eq power_mod)
} thenshow ?thesis by (auto simp add: cryptcorrect power_even_eq remainderexp elim!: evenE oddE) 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.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.