Bitcoin Forum
June 30, 2022, 07:04:59 PM *
News: Latest Bitcoin Core release: 23.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to get in Python, result same in cpp ?  (Read 139 times)
COBRAS
Member
**
Offline Offline

Activity: 560
Merit: 15

phemex.com - SCAM !!! FRAUD !!! DON'T USE THIS SHI


View Profile
May 10, 2022, 04:16:27 PM
 #1

Hello

Then I divide in modmath I get:

./modmath  0x60f4d11574f5deee49961d9609ac / 2                                 

Result: 307a688aba7aef7724cb0ecb04d6

in Python:

He =0x60f4d11574f5deee49961d9609ac

h2 = int(He / 2) % n

print(hex(h2))

result

0x307a688aba7af000000000000000

[Program finished]



HOW TO GET IN PYTHON result = af55fc59c335c8ec67ed24827 ?
------


/modmath 0x60f4d11574f5deee49961d9609ac / 8                                 

 Result: 7fffffffffffffffffffffffffffffff5d577a91f1c6febc9bc6f8792bcde1d6

python:

n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141



He =0x60f4d11574f5deee49961d9609ac

h2 = int(He / 8 ) % n

print(hex(h2))


0xc1e9a22ae9ebc00000000000000

[Program finished

HOW TO GET IN PYTHON result = 7fffffffffffffffffffffffffffffff5d577a91f1c6febc9bc6f8792bcde1d6 Huh

thanks !!!

ASAP PLEASE

God is Great.
1656615899
Hero Member
*
Offline Offline

Posts: 1656615899

View Profile Personal Message (Offline)

Ignore
1656615899
Reply with quote  #2

1656615899
Report to moderator
1656615899
Hero Member
*
Offline Offline

Posts: 1656615899

View Profile Personal Message (Offline)

Ignore
1656615899
Reply with quote  #2

1656615899
Report to moderator
1656615899
Hero Member
*
Offline Offline

Posts: 1656615899

View Profile Personal Message (Offline)

Ignore
1656615899
Reply with quote  #2

1656615899
Report to moderator
icon
Your favorite trading tools in one place. Lightning fast execution.
Start trading
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
n0nce
Sr. Member
****
Offline Offline

Activity: 322
Merit: 2756


Ubi concordia, ibi victoria!


View Profile WWW
May 10, 2022, 07:55:46 PM
 #2

This happens because the division operator gives you a float which can only have so many bits of accuracy. You circumvent it by using //.

Example:
Code:
>>> 1966507701910865760267104647776684/2
9.832538509554329e+32
>>> hex(int(1966507701910865760267104647776684/2))
'0x307a688aba7af000000000000000'

As you correctly noticed, all those trailing zeroes are wrong and due to the rounding done by Python floats.

By dividing with //, you force it to stay in the integer realm and you get the correct result.
Code:
>>> 1966507701910865760267104647776684//2
983253850955432880133552323888342
>>> hex(int(1966507701910865760267104647776684//2))
'0x307a688aba7aef7724cb0ecb04d6'

The second division is mathematically wrong (the modmath output, that is), it seems to have overflown. I don't know how many bits a modmath number has, so I can't tell you how to replicate the result in Python. But the method from above (with double //) will give you mathematically correct results no matter what.

NotATether
Legendary
*
Offline Offline

Activity: 924
Merit: 3103


It's like Lightning, but in 3D


View Profile WWW
May 11, 2022, 04:09:27 AM
 #3

./modmath  0x60f4d11574f5deee49961d9609ac / 2                                 
...
h2 = int(He / 2) % n
...
HOW TO GET IN PYTHON result = af55fc59c335c8ec67ed24827 ?

[I have trimmed your code and cmdline above]

Apparently, the first line is for a c++ program (did you write it?), the other is for a custom script that you made.

If you did not write the modmath program then you ought to take a look at its code on Github to see how it's getting the correct results. Maybe there are some ANDs being done there which you thought weren't necessary in Python because of its lack of overflow. (and while you're at the codebase, drop us a link to it please).

iceland2k14
Newbie
*
Offline Offline

Activity: 9
Merit: 20


View Profile
May 11, 2022, 04:51:27 AM
 #4

If you did not write the modmath program then you ought to take a look at its code on Github to see how it's getting the correct results. Maybe there are some ANDs being done there which you thought weren't necessary in Python because of its lack of overflow. (and while you're at the codebase, drop us a link to it please).

He is Talking about https://github.com/albertobsd/ecctools  I think.
mausuv
Newbie
*
Offline Offline

Activity: 49
Merit: 0


View Profile
May 11, 2022, 06:12:11 AM
Last edit: May 11, 2022, 06:25:38 AM by mausuv
 #5

Hello

Then I divide in modmath I get:

./modmath  0x60f4d11574f5deee49961d9609ac / 2                                  

Result: 307a688aba7aef7724cb0ecb04d6

@COBRAS
you need this ( 0x60f4d11574f5deee49961d9609ac / 2 =  307a688aba7aef7724cb0ecb04d6) result run python2, its working
Code:
user@0d3aad1851b1:~/Downloads$ python2 1.py
0x307a688aba7aef7724cb0ecb04d6L
you need this ( 0x60f4d11574f5deee49961d9609ac /8 = 7fffffffffffffffffffffffffffffff5d577a91f1c6febc9bc6f8792bcde1d6) result , wrong
Code:
user@0d3aad1851b1:~/Downloads$ python2 1.py
0xc1e9a22ae9ebbddc932c3b2c135L
your need python from ./modmath   Roll Eyes #its easy but some result wrong output print

edit:
@COBRAS share your ./modemath ideas thinkeasy123@protonmail.com
answer me https://bitcointalk.org/index.php?topic=5395858.msg60039035#msg60039035
fxsniper
Member
**
Offline Offline

Activity: 336
Merit: 24


View Profile
May 11, 2022, 07:54:20 AM
 #6

I think modmath.c it is not a division number by simple math
but modmath.c it is division by use function Elliptic curve  point division


Code:
case '/':
mpz_invert(inversemultiplier,B,EC.n);
mpz_mul(C,A,inversemultiplier);
mpz_mod(C,C,EC.n);

Code:
def ECdiv(Qx,Qy,Scalar): # EC point division
    A = (N-1)/Scalar
    Px,Py = ECmul(Qx,Qy,A)
    Py = P-Py
    return Px,Py

try to use Elliptic curve  point division function on python
I am not sure I am correct, wait programmer/expert coder to help confirm
COBRAS
Member
**
Offline Offline

Activity: 560
Merit: 15

phemex.com - SCAM !!! FRAUD !!! DON'T USE THIS SHI


View Profile
May 11, 2022, 01:32:21 PM
 #7

Hello

Then I divide in modmath I get:

./modmath  0x60f4d11574f5deee49961d9609ac / 2                                  

Result: 307a688aba7aef7724cb0ecb04d6

@COBRAS
you need this ( 0x60f4d11574f5deee49961d9609ac / 2 =  307a688aba7aef7724cb0ecb04d6) result run python2, its working
Code:
user@0d3aad1851b1:~/Downloads$ python2 1.py
0x307a688aba7aef7724cb0ecb04d6L
you need this ( 0x60f4d11574f5deee49961d9609ac /8 = 7fffffffffffffffffffffffffffffff5d577a91f1c6febc9bc6f8792bcde1d6) result , wrong
Code:
user@0d3aad1851b1:~/Downloads$ python2 1.py
0xc1e9a22ae9ebbddc932c3b2c135L
your need python from ./modmath   Roll Eyes #its easy but some result wrong output print

edit:
@COBRAS share your ./modemath ideas thinkeasy123@protonmail.com
answer me https://bitcointalk.org/index.php?topic=5395858.msg60039035#msg60039035

Hi Bro. Yes, I need this.

pm me we are talk.

I not agree what 0xfffff... is wrang. because then I div for ex 10 to 9 (10 / 9) 0xfff.......  is ok, result without floating part not good for dividing...

God is Great.
COBRAS
Member
**
Offline Offline

Activity: 560
Merit: 15

phemex.com - SCAM !!! FRAUD !!! DON'T USE THIS SHI


View Profile
May 11, 2022, 01:33:32 PM
 #8

If you did not write the modmath program then you ought to take a look at its code on Github to see how it's getting the correct results. Maybe there are some ANDs being done there which you thought weren't necessary in Python because of its lack of overflow. (and while you're at the codebase, drop us a link to it please).

He is Talking about https://github.com/albertobsd/ecctools  I think.

yes

God is Great.
COBRAS
Member
**
Offline Offline

Activity: 560
Merit: 15

phemex.com - SCAM !!! FRAUD !!! DON'T USE THIS SHI


View Profile
May 12, 2022, 04:08:59 PM
Last edit: May 12, 2022, 10:42:01 PM by COBRAS
 #9

example of dividing

./md 1 / 3             Result: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9d1c9e899ca306ad27fe1945de0242b81 (let it be 1/3)

10000 x 1/3:

./md 10000 x 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9d1c9e899ca306ad27fe1945de0242b81                                            Result: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9d1c9e899ca306ad27fe1945de0243886

1000*1/3 - 1/3=3333:

./md 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9d1c9e899ca306ad27fe1945de0243886 - 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9d1c9e899ca306ad27fe1945de0242b81                                 Result: d05

search range:

1/3 to 1/3*10000

0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9d1c9e899ca306ad27fe1945de0242b81

:

0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9d1c9e899ca306ad27fe1945de0243886

= 3333

3 times smale then 10000.You can play with ecctools for making your methods based on this example.


Use pubkeys from start privkeys and you get pubkey in range 3 time smaler too !!!


I looking for python programmer who know good simplest math operation in python for work on code for dividing pubksys.

ASAP.

YOU MAST KNOW HOW TO GET THIS RESULT, IF YOU CAN MESSAGE ME
 YOUR TELEGRAMM FOR TALK:

Hello

Then I divide in modmath I get:

./modmath  0x60f4d11574f5deee49961d9609ac / 2                                  

Result: 307a688aba7aef7724cb0ecb04d6

@COBRAS
you need this ( 0x60f4d11574f5deee49961d9609ac / 2 =  307a688aba7aef7724cb0ecb04d6) result run python2, its working
Code:
user@0d3aad1851b1:~/Downloads$ python2 1.py
0x307a688aba7aef7724cb0ecb04d6L
you need this ( 0x60f4d11574f5deee49961d9609ac /8 = 7fffffffffffffffffffffffffffffff5d577a91f1c6febc9bc6f8792bcde1d6) result , wrong
Code:
user@0d3aad1851b1:~/Downloads$ python2 1.py
0xc1e9a22ae9ebbddc932c3b2c135L
your need python from ./modmath   Roll Eyes #its easy but some result wrong output print

edit:








God is Great.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!