Package: py-ecc
py_eccElliptic curve crypto in python including secp256k1, alt_bn128, and bls12_381.Warning: This library contains some experimental codes that haveNOTbeen audited.Read more in the documentation below.View the change logQuickstartpython-mpipinstallpy_eccBLS Signaturespy_eccimplements theIETF BLS draft standard v4as per the inter-blockchain standardization agreement. The BLS standards specifydifferent ciphersuiteswhich each have different functionality to accommodate various use cases. The following ciphersuites are available from this library:G2Basicalso known asBLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_G2MessageAugmentationalso known asBLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_AUG_G2ProofOfPossessionalso known asBLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_Basic Usagefrompy_ecc.blsimportG2ProofOfPossessionasbls_popprivate_key=5566public_key=bls_pop.SkToPk(private_key)message=b'\xab'*32# The message to be signed# Signingsignature=bls_pop.Sign(private_key,message)# Verifyingassertbls_pop.Verify(public_key,message,signature)Aggregating Signaturesprivate_keys=[3,14,159]public_keys=[bls_pop.SkToPk(key)forkeyinprivate_keys]signatures=[bls_pop.Sign(key,message)forkeyinprivate_keys]# Aggregatingagg_sig=bls_pop.Aggregate(signatures)# Verifying signatures over the same message.# Note this is only safe if Proofs of Possession have been verified for each of the public keys beforehand.# See the BLS standards for why this is the case.assertbls_pop.FastAggregateVerify(public_keys,message,agg_sig)Multiple Aggregationmessages=[b'\xaa'*42,b'\xbb'*32,b'\xcc'*64]signatures=[bls_pop.Sign(key,message)forkey,messageinzip(private_keys,messages)]agg_sig=bls_pop.Aggregate(signatures)# Verify aggregate signature with different messagesassertbls_pop.AggregateVerify(public_keys,messages,agg_sig)Developer SetupIf you would like to hack on py_ecc, please check out theSnake Charmers
Tactical Manualfor information on how we do:TestingPull RequestsDocumentationWe usepre-committo maintain consistent code style. Once
installed, it will run automatically with every commit. You can also run it manually
withmake lint. If you need to make a commit that skips thepre-commitchecks, you
can do so withgit commit --no-verify.Development Environment SetupYou can set up your dev environment with:gitclonegit@github.com:ethereum/py_ecc.gitcdpy_ecc
virtualenv-ppython3venv
.venv/bin/activate
python-mpipinstall-e".[dev]"pre-commitinstallRelease setupTo release a new version:makereleasebump=$$VERSION_PART_TO_BUMP$$How to bumpversionThe version format for this repo is{major}.{minor}.{patch}for stable, and{major}.{minor}.{patch}-{stage}.{devnum}for unstable (stagecan be alpha or beta).To issue the next version in line, specify which part to bump,
likemake release bump=minorormake release bump=devnum. This is typically done from the
main branch, except when releasing a beta (in which case the beta is released from main,
and the previous stable branch is released from said branch).If you are in a beta version,make release bump=stagewill switch to a stable.To issue an unstable version when the current version is stable, specify the
new version explicitly, likemake release bump="--new-version 4.0.0-alpha.1 devnum"