logmod

version 1.4.0.0 (22.6 KB) by Steven Gregory
Computes y such that mod(a^y, p^N) == x

638 Downloads

Updated 23 Apr 2009

View License

Suppose
p is an odd prime,
ord(a) = p-1
GCD(x, p) = 1
N is an integer >= 2

Then
y = logmod(x, a, p, N)

Returns y such that a^y = x (mod p^N)

Example
Let x= vpi(154), a = vpi(7), p = vpi(17), N = vpi(37)
y = logmod(x, a, p, N)
returns
y = 2088349219044680767324467844670001776975183904

Cite As

Steven Gregory (2022). logmod (https://www.mathworks.com/matlabcentral/fileexchange/23803-logmod), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: nextperm, modinv(x, N)

Inspired: modinv(x, N), nextperm, egcd.m

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!