Post
Topic
Board Development & Technical Discussion
Merits 1 from 1 user
Re: sagemath script
by
witcher_sense
on 10/01/2023, 10:09:06 UTC
⭐ Merited by ETFbitcoin (1)

public x to Address convert compressed, uncompressed sagemath code please

Enter one point x a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd convert 02 and 03 >> uncompressed Address,compressed Address

02 a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd >> 1KAqCkyrNu5PmK6bwmg5h1VN8ags4iXxm4, 1K5kLbqNncT2oGbj8KNwkYi49es9CeEtnp
03 a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd >> 1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN, 1F3sAm6ZtwLAUnj7d38pGFxtP3RVEvtsbV

any one help me sagemath
Since you have tagged me again, I must ask. What are you trying to achieve exactly? I mean, if you're not very sure how to attain a given goal with a given tool, maybe you made a mistake when choosing a tool and should look for something more suitable and simpler. You have already been given good answers and even working scripts, but you still don't want to put in a little effort to transform them into something that you're looking for.

Here is another script, but I really doubt it is going to be useful to you:

Code:
#secp256k1
p = Integer(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F)

a = Integer(0x0000000000000000000000000000000000000000000000000000000000000000)
b = Integer(0x0000000000000000000000000000000000000000000000000000000000000007)

K = GF(p)
E = EllipticCurve(K,[a,b])

Gx = Integer(0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798)
Gy = Integer(0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8)
G = E(Gx, Gy)

privkey = Integer(0xA34B99F22C790C4E36B2B3C2C35A36DB06226E41C692FC82B8B56AC1C540C5BD)

pubkey = privkey * G
print('Uncomressed: ', '04' + hex(pubkey[0])[2:] + hex(pubkey[1])[2:])
if (Integer(pubkey[1]) % 2) == 0:
    print('Compressed: ', '02' + hex(pubkey[0])[2:])
else:
    print('Compressed: ', '03' + hex(pubkey[0])[2:])