mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Miscellaneous Math

Reply
 
Thread Tools
Old 2019-01-23, 21:44   #1
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

4,129 Posts
Default Possible obfuscation for Mersennes

Carried out on an idle Pi Zero W:

Code:
? gettime();p=21701;n=2^p-1;e=n;r=Mod(3,n)^((e))-3;print([length(e),lift(r)]);gettime()
[679, 0]
54996
? gettime();p=21701;n=2^p-1;e=lift(Mod(2,n-1)^(p-1));r=Mod(3,n)^((e))+3;print([length(e),lift(r)]);gettime()
[679, 0]
54455
paulunderwood is online now   Reply With Quote
Old 2019-01-23, 22:10   #2
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

4,129 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
Carried out on an idle Pi Zero W:

Code:
? gettime();p=21701;n=2^p-1;e=n;r=Mod(3,n)^((e))-3;print([length(e),lift(r)]);gettime()
[679, 0]
54996
? gettime();p=21701;n=2^p-1;e=lift(Mod(2,n-1)^(p-1));r=Mod(3,n)^((e))+3;print([length(e),lift(r)]);gettime()
[679, 0]
54455
Oh this is poor. I should have used e=n+1. Other than this the test was 3^((n+1)/2)+3 == 0 (mod n)
paulunderwood is online now   Reply With Quote
Old 2019-01-23, 22:10   #3
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

25×72 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
Carried out on an idle Pi Zero W:

Code:
? gettime();p=21701;n=2^p-1;e=n;r=Mod(3,n)^((e))-3;print([length(e),lift(r)]);gettime()
[679, 0]
54996
? gettime();p=21701;n=2^p-1;e=lift(Mod(2,n-1)^(p-1));r=Mod(3,n)^((e))+3;print([length(e),lift(r)]);gettime()
[679, 0]
54455
Not surprising, in the 1st case e=2^p-1, while in the 2nd case e=2^(p-1) and that enables a simple repeated squaring at powmod. Actually we're doing the 2nd variant with error checking, probably it is better to do 3^(2^p) mod mp to allow a fast space efficient cofactor test for mp/d.
R. Gerbicz is offline   Reply With Quote
Old 2019-01-24, 03:14   #4
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Incidentally, rather than
Code:
? gettime(); foo; print(bar); gettime()
I would write
Code:
? #
? foo; bar
where # turns the timer on (or off). In your case this would have resulted in
Code:
? #
   timer = 1 (on)
? p=21701;n=2^p-1;e=n;r=Mod(3,n)^((e))-3;[length(e),lift(r)]
time = 54,996 ms.
%1 = [679, 0]
? p=21701;n=2^p-1;e=lift(Mod(2,n-1)^(p-1));r=Mod(3,n)^((e))+3;[length(e),lift(r)]
time = 54,455 ms.
%2 = [679, 0]
(Apologies if this was known/obvious.)
CRGreathouse is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Primality testing non-Mersennes lukerichards Software 8 2018-01-24 22:30
Betting on Mersennes -- update #1 CRGreathouse Lounge 9 2016-03-31 13:41
GPU attack on double Mersennes? Uncwilly GPU Computing 29 2013-09-08 20:53
Stars and Mersennes David John Hill Jr Science & Technology 2 2009-12-13 09:47
Factoring Double mersennes Citrix Miscellaneous Math 2 2005-10-04 08:08

All times are UTC. The time now is 14:56.


Sun May 22 14:56:36 UTC 2022 up 38 days, 12:57, 0 users, load averages: 0.79, 0.93, 0.99

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔