syhue

20 Reputation

3 Badges

5 years, 360 days

MaplePrimes Activity


These are replies submitted by syhue

@vv 

 

Thank you for your reply. 

 

May I know how can I randomly select one of these combinations and proceed with x+y?

@Carl Love 

 

Hi, May I know do this algorithm suitable for 3-dimensional data? 

@Carl Love 

 

Hi, Thank you so much for your guiding. This way works! However, I do not really understand the steps as following:

Why 2^8? why ilog2(n)? ilog2(bby)?  Could you please explain this to me?

 

Thank you so much!

@Carl Love 

OK noted. 

Do you know anyways can convert a message of letters to number? 

I am using read to number, but it does not work. Thank you

@Carl Love 


How about this? I am using Generate(choose(W)). Would it biased? 

 

Thank you. 

@tomleslie 

 

Thank you so much for your explanation. 

@Carl Love 
 

NULL

NULL

with(RandomTools)

p := nextprime((rand(`&^`(2, 50) .. `&^`(2, 51)))()); q := nextprime((rand(`&^`(2, 50) .. `&^`(2, 51)))())

Error, invalid input: rand expects its 1st argument, r, to be of type {posint, numeric .. numeric}, but received `&^`(2, 50) .. `&^`(2, 51)

 

1136382443429747

(1)

n := p*q

2070964599677222252476217270989

(2)

a := (p-1)/(q-1)

911209343144543/568191221714873

(3)

r := numer(a); s := denom(a)

911209343144543

 

568191221714873

(4)

w := s*(p-1)

1035482299838609646837543776078

(5)

NULL

W := ifactor(w)

``(2)*``(124576018793)*``(38928371)*``(2777)*``(8429)*``(4561)

(6)

u := Generate(choose({W}))

``(2)*``(124576018793)*``(38928371)*``(2777)*``(8429)*``(4561)

(7)

``


 

Download ESF_Digi_1.mw

 

Thank you for your reply. May I ask two more questions?

 

1. Why the &^ is not applicable in this situation?

 

2. Do you know any ways can choose an element from a list? Like in my steps 6 and 7. I would like to choose only one factor from a number. (Choose randomly one element from the elements of ifactor)

 

Thank you and looking forward to your reply. 

@Carl Love 

Thank you for replying the message. Could you elaborate more in dividing out the 2s before doing chrem? If I have to fix the gcd of each of that equal to 2. 

@syhue  @Carl Love

 

"ady" is the short form of already. Yes, it is work, thanks. Apologise for replying late, I didn't receive the email regrading any new commands

 

May I ask you about one more question related to Chinese Remainder Theorem, commands "chrem"? 

I am facing this problem as attached. 
 

p1 := 1367; p2 := 1259; p3 := nextprime(1234)

1367

 

1259

 

1237

(1)

gcd(p1-1, p2-1); gcd(p1-1, p3-1); gcd(p2-1, p3-1)

2

 

2

 

2

(2)

N := p1*p2*p3

2128942561

(3)

phi := (p1-1)*(p2-1)*(p3-1)

2123977008

(4)

dp1 := nextprime(213); dp2 := 1481; dp3 := 1459

223

 

1481

 

1459

(5)

gcd(dp1, p1-1); gcd(dp2, p2-1); gcd(dp3, p3-1)

1

 

1

 

1

(6)

`mod`(dp1, 2); `mod`(dp2, 2); `mod`(dp3, 2)

1

 

1

 

1

(7)

d := chrem([dp1, dp2, dp3], [p1-1, p2-1, p3-1])

Error, (in chrem) the moduli must be pairwise relatively prime

 

e := `mod`(1/d, phi)

1/chrem[223, 1481, 1459, 1366, 1258, 1236]

(8)

M := 123

123

(9)

C := `mod`(M^e, N)

123^(1/chrem[223, 1481, 1459, 1366, 1258, 1236])

(10)

st := time()

M1 := `mod`(C^dp1, p1); M2 := `mod`(C^dp2, p2); M3 := `mod`(C^dp3, p3)

(123^(1/chrem[223, 1481, 1459, 1366, 1258, 1236]))^223

 

(123^(1/chrem[223, 1481, 1459, 1366, 1258, 1236]))^1481

 

(123^(1/chrem[223, 1481, 1459, 1366, 1258, 1236]))^1459

(11)

N1 := N/p1; N2 := N/p2; N3 := N/p3

1557383

 

1690979

 

1721053

(12)

y1 := `mod`(1/N1, p1); y2 := `mod`(1/N2, p2); y3 := `mod`(1/N3, p3)

617

 

133

 

548

(13)

M := `mod`(M1*N1*y1+M2*N2*y2+M3*N3*y3, N)

960905311*(123^(1/chrem[223, 1481, 1459, 1366, 1258, 1236]))^223+224900207*(123^(1/chrem[223, 1481, 1459, 1366, 1258, 1236]))^1481+943137044*(123^(1/chrem[223, 1481, 1459, 1366, 1258, 1236]))^1459

(14)

elapsed_time := (time()-st)*sec

.157*sec

(15)

NULL


 

Download R-Prime_RSA.mw


 

NULL

p := nextprime(2^1999); q := prevprime(2^2000)

57406534763712726211641660058884099201115885104434760023882136841288313069618515692832974315825313495922298231949373138672355948043152766571296567808332659269564994572656140000344389574120022435714463495031743122390807731823194181973658513020233176985452498279081199404472314802811655824768082110985166340672084454492229252801189742403957029450467388250214501358353312915261004066118140645880633941658603299497698209063510889929202021079926591625770444716951045960277478891794836019580040978608315291377690212791863007764174393209716027254457637891941312587717764400411421385408982726881092425574515033

 

114813069527425452423283320117768198402231770208869520047764273682576626139237031385665948631650626991844596463898746277344711896086305533142593135616665318539129989145312280000688779148240044871428926990063486244781615463646388363947317026040466353970904996558162398808944629605623311649536164221970332681344168908984458505602379484807914058900934776500429002716706625830522008132236281291761267883317206598995396418127021779858404042159853183251540889433902091920554957783589672039160081957216630582755380425583726015528348786419432054508915275783882625175435528800822842770817965453762184851149027159

(1)

n := p*q

6591020467154715500519448971182956815920095805466363845464017251208784640564172275539876061586061016570470378240358411519223408847120290640865531226256092019272337222193444478164485321385996965018293276462124757244416091694707916187810004642461304473055519289377038956632720459291562793025215823642301818245411925003913405836234450105344552244044742673596076354410059882503062972429198880937334650639372616752398293497257027217608526901866351620141700407963084674182399736358047288447003621584331284443301532916243415303062508821678234866203626437283608866847412118337661670877840919610977346910227948350348357996280488245614408181086957465826739250816477539351031259731816749911756668461564068310910703714877734244447580177282584435025535299277246231039735988636968154375958960677204765724527840878070086012863655635721356815518112572903736564753125600454085606051741565356081373910033931011036777138637340770831639850142730849076394606810704860808170348066965318974537835918445653635223028091909691623380187484898216402676407179053500331116289254243644587843107231717334697867128552533791940732819885877773569813810777443873577841450137200885294681359451586213482868149072258194057413824154001170781247

(2)

phi := (p-1)*(q-1)

6591020467154715500519448971182956815920095805466363845464017251208784640564172275539876061586061016570470378240358411519223408847120290640865531226256092019272337222193444478164485321385996965018293276462124757244416091694707916187810004642461304473055519289377038956632720459291562793025215823642301818245411925003913405836234450105344552244044742673596076354410059882503062972429198880937334650639372616752398293497257027217608526901866351620141700407963084674182399736358047288447003621584331284443301532916243415303062508821678234866203626437283608866847412118337661670877840919610977346910227948178128753705142309610689428004434659862479083937512197467704620735866877541056209589962641120834970215947983038396328164160214740305567235585387542806041758179941984436407538959644036043364460533734679600917634288463298161345935566651928197504053594644096590768808143351939136965475066456706790444183138318754578276373454972445507167394939616509406005597423461243914599090135433455280801090450007866647570288991803589212143737391447437091336514376932310436989969350884898022482620493793669004907874011744702931438221754151350398212302055437512381005535513823060189666914808101967109233180876724447239056

(3)

e := 2467

2467

(4)

gcd(e, phi)

1

(5)

d := `mod`(1/e, phi)

2327028304374445561796692360721668174570897221954277628455273216782671837021237961895108248739951011525285650363742268517731491327864520935627838548062041406074667904552286234487744918900366176137386884393397107239516179921398700851067091221558085203093375476711552870379853879222923061501809072716840244706831693019217096264029268764392016621225363140941298137288675378054385021883191011469971009609604195051211558020312472925227817969811752031270134193488385387601487705864555812013514452533422192440257655115544391864194343406437674328521831628242409129721968364439441960005917892574447210846699855234353524311787171329919129222481795192630434580289065259169324953765727741491673511494714396533141085565745126243697539920367668749959084797273023828156615879501203260685434306384254314459037342879167382407482555837670327739079804845492282134588845129715496781366798889152407092391075348111720501371509313188179034747174414673707637941221080656543425567635117447689345686059166007113732367159285306789636693032777027241093309796494007988064087564778290389387216580713719569348343109077537780005982271678004156174580927387850100057930721640078347732396202894157043048189216804545339336076426277662563931

(6)

M := 123

123

(7)

``

C := `mod`(M^e, n)

3848512548572894673448970233735260294394542611094720580505529561238029979538621481732278762259199156485542445190389177670664389046650556619987970801177915158343932868532235478681492465815608802925238186119456457327406459561076592324163176718026378601964148250627422048975330853560784959338645305512655386075765428248382035360966868763229559391028171991070718586871137060661979059379213070809479246130626775555389113401858853729247985392818341875153987387111451672456611203169725867427529468376999503875469060173889793017447609358516522671519000463338858387429793443071775689284794449552415500742213566330189554626816411836556037719140595211491077946759722965699167164754993278692925746442553094648716145480558954662747388810206467015347942827812488596421082645595323311312791344430453192188307244370944959931668634341076535207135205220114509417685929322129688068878731950455706232370823149668179342239099236108918969842267920342570306465876404351095447192852128781155932195931241834229273499385877214971700927766648641630653167909581068465080637601909419864272750562784880532190583749816663184386224858981685698954589135273045450625938679054292152669975546339606997605711108262411433092747165174577644123

(8)

st := time()

M := `mod`(C^d, n)

Error, numeric exception: overflow

 

elapsed_time := (time()-st)*sec

0.31e-1*sec

(9)

NULL

NULL


The red colour sentence. 


 

NULL

p := nextprime(2^1999); q := prevprime(2^2000)

57406534763712726211641660058884099201115885104434760023882136841288313069618515692832974315825313495922298231949373138672355948043152766571296567808332659269564994572656140000344389574120022435714463495031743122390807731823194181973658513020233176985452498279081199404472314802811655824768082110985166340672084454492229252801189742403957029450467388250214501358353312915261004066118140645880633941658603299497698209063510889929202021079926591625770444716951045960277478891794836019580040978608315291377690212791863007764174393209716027254457637891941312587717764400411421385408982726881092425574515033

 

114813069527425452423283320117768198402231770208869520047764273682576626139237031385665948631650626991844596463898746277344711896086305533142593135616665318539129989145312280000688779148240044871428926990063486244781615463646388363947317026040466353970904996558162398808944629605623311649536164221970332681344168908984458505602379484807914058900934776500429002716706625830522008132236281291761267883317206598995396418127021779858404042159853183251540889433902091920554957783589672039160081957216630582755380425583726015528348786419432054508915275783882625175435528800822842770817965453762184851149027159

(1)

n := p*q

6591020467154715500519448971182956815920095805466363845464017251208784640564172275539876061586061016570470378240358411519223408847120290640865531226256092019272337222193444478164485321385996965018293276462124757244416091694707916187810004642461304473055519289377038956632720459291562793025215823642301818245411925003913405836234450105344552244044742673596076354410059882503062972429198880937334650639372616752398293497257027217608526901866351620141700407963084674182399736358047288447003621584331284443301532916243415303062508821678234866203626437283608866847412118337661670877840919610977346910227948350348357996280488245614408181086957465826739250816477539351031259731816749911756668461564068310910703714877734244447580177282584435025535299277246231039735988636968154375958960677204765724527840878070086012863655635721356815518112572903736564753125600454085606051741565356081373910033931011036777138637340770831639850142730849076394606810704860808170348066965318974537835918445653635223028091909691623380187484898216402676407179053500331116289254243644587843107231717334697867128552533791940732819885877773569813810777443873577841450137200885294681359451586213482868149072258194057413824154001170781247

(2)

phi := (p-1)*(q-1)

6591020467154715500519448971182956815920095805466363845464017251208784640564172275539876061586061016570470378240358411519223408847120290640865531226256092019272337222193444478164485321385996965018293276462124757244416091694707916187810004642461304473055519289377038956632720459291562793025215823642301818245411925003913405836234450105344552244044742673596076354410059882503062972429198880937334650639372616752398293497257027217608526901866351620141700407963084674182399736358047288447003621584331284443301532916243415303062508821678234866203626437283608866847412118337661670877840919610977346910227948178128753705142309610689428004434659862479083937512197467704620735866877541056209589962641120834970215947983038396328164160214740305567235585387542806041758179941984436407538959644036043364460533734679600917634288463298161345935566651928197504053594644096590768808143351939136965475066456706790444183138318754578276373454972445507167394939616509406005597423461243914599090135433455280801090450007866647570288991803589212143737391447437091336514376932310436989969350884898022482620493793669004907874011744702931438221754151350398212302055437512381005535513823060189666914808101967109233180876724447239056

(3)

e := 2467

2467

(4)

gcd(e, phi)

1

(5)

d := `mod`(1/e, phi)

2327028304374445561796692360721668174570897221954277628455273216782671837021237961895108248739951011525285650363742268517731491327864520935627838548062041406074667904552286234487744918900366176137386884393397107239516179921398700851067091221558085203093375476711552870379853879222923061501809072716840244706831693019217096264029268764392016621225363140941298137288675378054385021883191011469971009609604195051211558020312472925227817969811752031270134193488385387601487705864555812013514452533422192440257655115544391864194343406437674328521831628242409129721968364439441960005917892574447210846699855234353524311787171329919129222481795192630434580289065259169324953765727741491673511494714396533141085565745126243697539920367668749959084797273023828156615879501203260685434306384254314459037342879167382407482555837670327739079804845492282134588845129715496781366798889152407092391075348111720501371509313188179034747174414673707637941221080656543425567635117447689345686059166007113732367159285306789636693032777027241093309796494007988064087564778290389387216580713719569348343109077537780005982271678004156174580927387850100057930721640078347732396202894157043048189216804545339336076426277662563931

(6)

M := 123

123

(7)

NULL

C := `mod`(M^e, n)

3848512548572894673448970233735260294394542611094720580505529561238029979538621481732278762259199156485542445190389177670664389046650556619987970801177915158343932868532235478681492465815608802925238186119456457327406459561076592324163176718026378601964148250627422048975330853560784959338645305512655386075765428248382035360966868763229559391028171991070718586871137060661979059379213070809479246130626775555389113401858853729247985392818341875153987387111451672456611203169725867427529468376999503875469060173889793017447609358516522671519000463338858387429793443071775689284794449552415500742213566330189554626816411836556037719140595211491077946759722965699167164754993278692925746442553094648716145480558954662747388810206467015347942827812488596421082645595323311312791344430453192188307244370944959931668634341076535207135205220114509417685929322129688068878731950455706232370823149668179342239099236108918969842267920342570306465876404351095447192852128781155932195931241834229273499385877214971700927766648641630653167909581068465080637601909419864272750562784880532190583749816663184386224858981685698954589135273045450625938679054292152669975546339606997605711108262411433092747165174577644123

(8)

st := time()

"M:=C^()(&)^(d) mod n"

Error, invalid base

"M:=C(&)^d mod n"

 

elapsed_time := (time()-st)*sec

0.31e-1*sec

(9)

``

``


 

Download R.mw

Download R.mw

@Carl Love 

@Carl Love

 

Yes. Then the following steps came out an error. It stated numeric exception--overflow 

Page 1 of 1