Bitcoin Forum
May 17, 2024, 06:40:01 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Public Key  (Read 959 times)
hack_ (OP)
Hero Member
*****
Offline Offline

Activity: 501
Merit: 503


View Profile
December 15, 2014, 02:57:03 PM
 #1

It seems the client only gives out compressed public keys, how can i get the uncompressed one?
dabura667
Sr. Member
****
Offline Offline

Activity: 475
Merit: 252


View Profile
December 15, 2014, 03:14:34 PM
 #2

Go here

http://www.tutorialspoint.com/execute_python3_online.php

Copy this into the middle window that has the code for hello world, delete all code and paste this code
replace the xxxxxxxxxxxx with your compressed pubkey.

Then click execute and the uncompressed pubkey will show up in the console.

Code:
###############
compressed_key = 'xxxxxxxxxxxx'
###############

def pow_mod(x, y, z):
    "Calculate (x ** y) % z efficiently."
    number = 1
    while y:
        if y & 1:
            number = number * x % z
        y >>= 1
        x = x * x % z
    return number

p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
y_parity = int(compressed_key[:2]) - 2
x = int(compressed_key[2:], 16)
a = (pow_mod(x, 3, p) + 7) % p
y = pow_mod(a, (p+1)//4, p)
if y % 2 != y_parity:
    y = -y % p
uncompressed_key = '04{:x}{:x}'.format(x, y)
print()
print()
print(uncompressed_key)
print()
print()

My Tip Address:
1DXcHTJS2DJ3xDoxw22wCt11FeAsgfzdBU
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1078


Ian Knowles - CIYAM Lead Developer


View Profile WWW
December 15, 2014, 03:19:14 PM
 #3

It seems the client only gives out compressed public keys, how can i get the uncompressed one?

Why exactly would you want to get uncompressed ones?

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
hack_ (OP)
Hero Member
*****
Offline Offline

Activity: 501
Merit: 503


View Profile
December 15, 2014, 04:49:20 PM
 #4

Go here

http://www.tutorialspoint.com/execute_python3_online.php

Copy this into the middle window that has the code for hello world, delete all code and paste this code
replace the xxxxxxxxxxxx with your compressed pubkey.

Then click execute and the uncompressed pubkey will show up in the console.

Code:
###############
compressed_key = 'xxxxxxxxxxxx'
###############

def pow_mod(x, y, z):
    "Calculate (x ** y) % z efficiently."
    number = 1
    while y:
        if y & 1:
            number = number * x % z
        y >>= 1
        x = x * x % z
    return number

p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
y_parity = int(compressed_key[:2]) - 2
x = int(compressed_key[2:], 16)
a = (pow_mod(x, 3, p) + 7) % p
y = pow_mod(a, (p+1)//4, p)
if y % 2 != y_parity:
    y = -y % p
uncompressed_key = '04{:x}{:x}'.format(x, y)
print()
print()
print(uncompressed_key)
print()
print()


thanks, gonna try it out now. 

It seems the client only gives out compressed public keys, how can i get the uncompressed one?

Why exactly would you want to get uncompressed ones?


I am working on a set of tools and guides to create a sort of guideline.
hack_ (OP)
Hero Member
*****
Offline Offline

Activity: 501
Merit: 503


View Profile
December 15, 2014, 04:57:39 PM
 #5

Go here

http://www.tutorialspoint.com/execute_python3_online.php

Copy this into the middle window that has the code for hello world, delete all code and paste this code
replace the xxxxxxxxxxxx with your compressed pubkey.

Then click execute and the uncompressed pubkey will show up in the console.

Code:
###############
compressed_key = 'xxxxxxxxxxxx'
###############

def pow_mod(x, y, z):
    "Calculate (x ** y) % z efficiently."
    number = 1
    while y:
        if y & 1:
            number = number * x % z
        y >>= 1
        x = x * x % z
    return number

p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
y_parity = int(compressed_key[:2]) - 2
x = int(compressed_key[2:], 16)
a = (pow_mod(x, 3, p) + 7) % p
y = pow_mod(a, (p+1)//4, p)
if y % 2 != y_parity:
    y = -y % p
uncompressed_key = '04{:x}{:x}'.format(x, y)
print()
print()
print(uncompressed_key)
print()
print()


Worked like a charm, thank you
hexafraction
Sr. Member
****
Offline Offline

Activity: 392
Merit: 259

Tips welcomed: 1CF4GhXX1RhCaGzWztgE1YZZUcSpoqTbsJ


View Profile
December 15, 2014, 05:11:42 PM
 #6

Go here

http[Suspicious link removed]cute_python3_online.php

Copy this into the middle window that has the code for hello world, delete all code and paste this code
replace the xxxxxxxxxxxx with your compressed pubkey.

Then click execute and the uncompressed pubkey will show up in the console.


Why not just use a standard python interpreter? Why use a webservice?

I have recently become active again after a long period of inactivity. Cryptographic proof that my account has not been compromised is available.
doof
Hero Member
*****
Offline Offline

Activity: 765
Merit: 503


View Profile WWW
December 15, 2014, 11:13:57 PM
 #7

Go here

http[Suspicious link removed]cute_python3_online.php

Copy this into the middle window that has the code for hello world, delete all code and paste this code
replace the xxxxxxxxxxxx with your compressed pubkey.

Then click execute and the uncompressed pubkey will show up in the console.


Why not just use a standard python interpreter? Why use a webservice?
Not everyone knows python.
hexafraction
Sr. Member
****
Offline Offline

Activity: 392
Merit: 259

Tips welcomed: 1CF4GhXX1RhCaGzWztgE1YZZUcSpoqTbsJ


View Profile
December 15, 2014, 11:18:25 PM
 #8

Go here

http[Suspicious link removed]cute_python3_online.php

Copy this into the middle window that has the code for hello world, delete all code and paste this code
replace the xxxxxxxxxxxx with your compressed pubkey.

Then click execute and the uncompressed pubkey will show up in the console.


Why not just use a standard python interpreter? Why use a webservice?
Not everyone knows python.
Doesn't mean copy-pasting into a python prompt is necessarily out-of-reach. I did a double-take at first since I thought it took private keys. Still sketchy when a decent solution exists.

I have recently become active again after a long period of inactivity. Cryptographic proof that my account has not been compromised is available.
gmaxwell
Staff
Legendary
*
Offline Offline

Activity: 4172
Merit: 8421



View Profile WWW
December 15, 2014, 11:21:40 PM
 #9

I am working on a set of tools and guides to create a sort of guideline.
Presumably your guideline will recommend users _never_ use uncompressed public keys?
hack_ (OP)
Hero Member
*****
Offline Offline

Activity: 501
Merit: 503


View Profile
December 16, 2014, 02:16:50 AM
 #10

I am working on a set of tools and guides to create a sort of guideline.
Presumably your guideline will recommend users _never_ use uncompressed public keys?

The tools and guides will be open but i will try to use red extra large letters detailing why they should not. I became interested when i saw this part of the bitcoin code:-

Quote
txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3 8c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
       

I hope i'm right that it actually is an uncompressed pub key. The idea is in the same direction as a question on this board about dealing with blockchain bloat.
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!