![]() |
![]() |
#1 |
Feb 2004
France
91410 Posts |
![]()
Hello,
I'm reading "Prime Numbers, A Computational Perspective, 2nd Edition" and I'm experimenting with the "Montgomery powering" explained in pages 447-450, and I fail with my example. Let: As explained in the book, I've computed: I want to compute: I'm now using Th 9.2.6 based on (9.7): The binary bits of y are: Step 1 (Initialize): Step 2 (Power ladder): j=1 : j=0 : Step 3 (Final extraction of power): I expected to find 4 instead of 2. OK, I'm wrong. Where ? (In my opinion, a numerical example would help in the book ...). My final goal is to search if a faster Thanks, Tony Last fiddled with by T.Rex on 2006-04-17 at 15:37 |
![]() |
![]() |
![]() |
#2 |
Feb 2004
France
2·457 Posts |
![]()
A small mistake:
I've used PARI/gp to check: Code:
M(a,b)=shift((a*b+5*bitand(a*b*3,7))),-3) So, the last Step is now: T. |
![]() |
![]() |
![]() |
#3 |
Feb 2004
France
91410 Posts |
![]()
And another mistake in the text (but the value of N' is OK):
T. |
![]() |
![]() |
![]() |
#4 |
Aug 2002
Buenos Aires, Argentina
17·79 Posts |
![]()
I wrote an article on Mersenne Wiki about Montgomery multiplication. Maybe it can help you.
|
![]() |
![]() |
![]() |
#5 | |
Feb 2004
France
39216 Posts |
![]() Quote:
But I have problems with your Wiki explanations. With: m=5 , n=3 , a=b = 3 , I have: R=5 , 1/8 mod 5 = 2 a' = 8.3 (mod 5) = 4 x = a' . b' (mod 5) = 1 And I do not understand why you recompute m : Using m=5, I have a problem with: t = (x + mR)/(2^n) = (1+5.5)/8 = 26/8 . Not an integer ... A mistake ? T. |
|
![]() |
![]() |
![]() |
#6 | |
Jun 2003
113758 Posts |
![]() Quote:
I hope I am making some sense ![]() |
|
![]() |
![]() |
![]() |
#7 | |
Jun 2003
113758 Posts |
![]() Quote:
First, R should be the negative of modular inverse of M. Second, x = a' * b' (mod m) should be just plain x = a' * b'. Third, m = (x mod 2^n)*R mod 2^n is confusing since it redefines m. m shouldn't change throughout the computation. Let's call that one m'. Then the next line becomes t = (x + m*m')/(2^n) |
|
![]() |
![]() |
![]() |
#8 |
Aug 2002
Buenos Aires, Argentina
17·79 Posts |
![]()
I corrected the formulas (there were some errors) and I also included your example with a step-by-step solution. Please see the new version of the MersenneWiki page.
|
![]() |
![]() |
![]() |
#9 |
Jun 2003
4,861 Posts |
![]()
The third step should use 'm' instead of 'R' -- i.e. t = (x + s.m)/2^n
Also, the second step is defined as x*R mod 2^n with R itself defined as -m^-1 (mod 2^n). This way, the whole computation just uses unsigned multiplication. |
![]() |
![]() |
![]() |
#10 |
Aug 2002
Buenos Aires, Argentina
17·79 Posts |
![]()
I added the changes you wrote in you last post. Thanks.
|
![]() |
![]() |
![]() |
#11 | |
Feb 2004
France
2·457 Posts |
![]() Quote:
Tony |
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Peter Montgomery's Thesis | mickfrancis | Computer Science & Computational Number Theory | 3 | 2015-06-25 14:32 |
Peter Montgomery (IMPORTANT) | R.D. Silverman | Factoring | 8 | 2014-06-07 18:43 |
Brent-Montgomery-te Riele numbers | FactorEyes | Factoring | 23 | 2008-02-22 00:36 |
VIA C7 Montgomery Multiplier? | akruppa | Hardware | 1 | 2005-08-04 10:25 |
Montgomery Multiplication | dave_dm | Math | 2 | 2004-12-24 11:00 |