python – Musig Key Technology – Taproot Workshop – 1.2 Musig: 1.2.1 Programming Train: Compute 3-of-3 MuSig public key

on

|

views

and

comments


I’m discovering it troublesome to determine methods to correctly multiply the key-pairs with the challenges.

privkey1, pubkey1 = generate_key_pair(sha256(b'key0'))
privkey2, pubkey2 = generate_key_pair(sha256(b'key1'))
privkey3, pubkey3 = generate_key_pair(sha256(b'key2'))
pubkeys = [pubkey1, pubkey2, pubkey3]

# Compute key challenges
# Methodology: use generate_musig_key() on the checklist of pubkeys.
# generate_musig_key() returns a problem map and the mixture public key.
c_map, pubkey_agg =  generate_musig_key(pubkeys)# TODO: implement
print("Aggregated Public Secret's {}n".format(pubkey_agg.get_bytes().hex()))

# Multiply key pairs by problem issue

The diagram reveals that tweaked personal key di' = ci * di

musig keygen

This made me assume to do one thing like:

privkey1_c = int.from_bytes(c_map[pubkey1], "huge") * int.from_bytes(privkey1.get_bytes(), "huge")

(cant multiply bytes immediately)
However this ends in a quantity far too giant and since SECP256K1_ORDER was not imported (for modulo operations) I figured that may be a mistake on my half. I additionally tried to only set it like this:

privkey1_c = ECKey().set(c_map[pubkey1])

Which leads to a sound key however will not be the anticipated values which are checked on the assertions on the backside of the code:

assert privkey1_c.secret == 104717570570407299858230629579807834166658508605015363884161538594382975780625
assert privkey2_c.secret == 65554880484297966965546994775376394861215085064604177497808278620612854069980
assert privkey3_c.secret == 106998690642216524894360365246223287721822845133760006050846956016514597569168

I really feel like I am misunderstanding how the problem map pertains to the problem issue within the diagram. I assume it outputs ci for every pubkey but when that is the case, multiplying that quantity by the unique privkey will end in a price too giant for SECP256K1_ORDER.

There’s additionally this half:

# Decide if the personal and public keys must be negated. 
# Trace: The combination public secret is the one which must be legitimate.
if pubkey_agg.get_y() % 2 != 0:
    pubkey_agg.negate()
    # TODO: implement

Because the key technology will not be random this has the identical consequence each time which is that the if assertion returns false (even worth) and won’t get used, so until I’m misunderstanding that this half appears to be a purple herring (irrelevant to the problem).

Share this
Tags

Must-read

UK startup Wayve begins testing self-driving tech in Nissan vehicles on Tokyo’s streets | Self-driving vehicles

British startup Wayve has begun testing self-driving vehicles with Nissan in Japan forward of a 2027 launch to customers, as the corporate stated...

Rebeca Delgado Joins Torc As Vice President, Engineering – Autonomy Functions

BLACKSBURG, Va – September 16, 2025 – Torc Robotics, an unbiased subsidiary of Daimler Truck AG and a pioneer in commercializing self-driving automobile...

‘Excessive nausea’: Are EVs inflicting automobile illness – and what might be performed? | Electrical, hybrid and low-emission automobiles

It was a 12 months in to driving his daughter to high school in his new electrical automobile that Phil Bellamy found she...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here