Signature creation in Python3: Difference between revisions

From mojo_puzzler
Jump to navigation Jump to search
(Created page with "==== Return to: Insightful_Comments ==== Russw_ on 20211029 @01:00am EST said: ----------------------- GOT IT! This works for me: <code> basicSpendBundle = await alice.spend_coin(testcoin, pushtx = False, args = spendArgs) // assemble the aggregated BLS signatures on their own... // - in this case there is only 1 sig, so `aggSig == sig1`, and `AugScheme.MPL.aggregate` is // not actually needed here... but just add more to sigs when needed privateKey = alice....")
 
No edit summary
 
Line 4: Line 4:
GOT IT! This works for me:
GOT IT! This works for me:


<code>
basicSpendBundle = await alice.spend_coin(testcoin, pushtx = False, args = spendArgs)


// assemble the aggregated BLS signatures on their own...
basicSpendBundle = await alice.spend_coin(testcoin, pushtx = False, args = spendArgs)


// - in this case there is only 1 sig, so `aggSig == sig1`, and `AugScheme.MPL.aggregate` is
// assemble the aggregated BLS signatures on their own...


//   not actually needed here... but just add more to sigs when needed
// - in this case there is only 1 sig, so `aggSig == sig1`, and `AugScheme.MPL.aggregate` is


privateKey = alice.sk()
//    not actually needed here... but just add more to sigs when needed


messageToSign = clvm.casts.int_to_bytes(msg_id)
privateKey = alice.sk()


sig1 = blspy.AugSchemeMPL.sign(privateKey, messageToSign)
messageToSign = clvm.casts.int_to_bytes(msg_id)


sigs = [sig1]                                # not actually needed with a single sig
sig1 = blspy.AugSchemeMPL.sign(privateKey, messageToSign)


aggSig = blspy.AugSchemeMPL.aggregate(sigs)  # not actually needed with a single sig
sigs = [sig1]                                # not actually needed with a single sig


//This is the way to make the combined spend...
aggSig = blspy.AugSchemeMPL.aggregate(sigs)  # not actually needed with a single sig


// - clean separation between assembling the Coin spends and the agg sigs works well
//This is the way to make the combined spend...


combinedSpend = cdv.test.SpendBundle(coinSpends, aggSig) # in this single sig case, sig1 would be fine here
  // - clean separation between assembling the Coin spends and the agg sigs works well


//verify both (even though sig1 and combinedSpend.aggregated_signature are the same in this case)
combinedSpend = cdv.test.SpendBundle(coinSpends, aggSig)  # in this single sig case, sig1 would be fine here


assert blspy.AugSchemeMPL.verify(alice.pk_, messageToSign, sig1)
//verify both (even though sig1 and combinedSpend.aggregated_signature are the same in this case)


assert blspy.AugSchemeMPL.verify(alice.pk_, messageToSign, combinedSpend.aggregated_signature)
assert blspy.AugSchemeMPL.verify(alice.pk_, messageToSign, sig1)


result = await network.push_tx(combinedSpend)</code>
assert blspy.AugSchemeMPL.verify(alice.pk_, messageToSign, combinedSpend.aggregated_signature)
 
result = await network.push_tx(combinedSpend)

Latest revision as of 02:00, 18 November 2023

Return to: Insightful_Comments

Russw_ on 20211029 @01:00am EST said:


GOT IT! This works for me:


basicSpendBundle = await alice.spend_coin(testcoin, pushtx = False, args = spendArgs)
// assemble the aggregated BLS signatures on their own...
//  - in this case there is only 1 sig, so `aggSig == sig1`, and `AugScheme.MPL.aggregate` is
//    not actually needed here... but just add more to sigs when needed
privateKey = alice.sk()
messageToSign = clvm.casts.int_to_bytes(msg_id)
sig1 = blspy.AugSchemeMPL.sign(privateKey, messageToSign)
sigs = [sig1]                                # not actually needed with a single sig
aggSig = blspy.AugSchemeMPL.aggregate(sigs)  # not actually needed with a single sig
//This is the way to make the combined spend...
// - clean separation between assembling the Coin spends and the agg sigs works well
combinedSpend = cdv.test.SpendBundle(coinSpends, aggSig)  # in this single sig case, sig1 would be fine here
//verify both (even though sig1 and combinedSpend.aggregated_signature are the same in this case)
assert blspy.AugSchemeMPL.verify(alice.pk_, messageToSign, sig1)
assert blspy.AugSchemeMPL.verify(alice.pk_, messageToSign, combinedSpend.aggregated_signature)
result = await network.push_tx(combinedSpend)