Signature creation in Python3
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)