oxen-io / oxen-core

Oxen core repository, containing oxend and oxen cli wallets
https://oxen.io
Other
317 stars 120 forks source link

Add BLS signature debug tool #1752

Closed jagerman closed 1 week ago

jagerman commented 1 week ago

This adds a command-line tool oxen-bls (require -DBUILD_BLOCKCHAIN_UTILS=ON to build) that allows for command-line pubkey and/or signature aggregation and/or verification.

Usage info:

./bin/oxen-bls -- BLS pubkey/signature aggregator and verifier

Usage:

pubkey addition/subtraction:

    ./bin/oxen-bls BLSPK +BLSPK [+BLSPK ...] # aggregates 2 or more pubkey, prints the aggregate
    ./bin/oxen-bls BLSPK -BLSPK [-BLSPK ...] # subtracts 1 or more pubkeys from another pubkey
    ./bin/oxen-bls BLSPK -BLSPK +BLSPK +BLSPK -BLSPK ... # combined addition/subtraction
    ./bin/oxen-bls -BLSPK # negation
    ./bin/oxen-bls +BLSPK # same as just BLSPK

signature addition/subtraction:

    ./bin/oxen-bls BLSSIG +BLSSIG [+BLSSIG ...] # aggregates signatures
    ./bin/oxen-bls BLSSIG -BLSSIG [-BLSSIG ...] # subtracts signatures
    ./bin/oxen-bls BLSSIG +BLSSIG -BLSSIG +BLSSIG ... # combined addition/subtraction
    ./bin/oxen-bls -BLSSIG # negation
    ./bin/oxen-bls +BLSSIG # same as just BLSSIG

signature verification (with optional aggregation):

    ./bin/oxen-bls NETWORK MSG BLSPK BLSSIG
    ./bin/oxen-bls NETWORK MSG BLSPK [{+|-}BLSPK ...] BLSSIG [{+|-}BLSSIG ...]

NETWORK must be mainnet, stagenet, devnet, etc.

MSG is the message that was allegedly signed, either with auto-detected hex or plaintext (but can be
prefixed with 0x or _ to force hex or plaintext interpretation).

For example:

./bin/oxen-bls stagenet 64466f433a3b15f92c623486b57e4de42e127f39eab13285715a5984c2de089d0726c8f9b5637bb0df1eb321c838781e9bc1195dd30724146ae0445a52a6cd3b0b01358ae53f412608e3427ae5214415caeb265a536f350da80c33e5103ce73f00000000000000000000000000000000000000000000000000000000672c2b64 019bcbb260cc91be4c76c8d82a1349f0783048a8830374425ac1995c9e161ae327cb2342ee796d4f617d0df2409fed68ef8e14cfa4d790636ed9763298b3a0f2 2ff8d31fa5b70759083181cf1dbb0a91b75fc02f6fd4b1fb11df529586b8b7a4109e44dcacae1b8f2e2a7745f0ac2c560a7af1770f092c6e1cfedb45f62e330e1aa0f1c5f02db6e2e05c84fb4e15d4ae1ca24ae8c2eef359e614ced6b14ddcef21a7d03524f7c9ff098d9c29429b0982e2048253a90a1787e9baf4d3e2c40572

Pubkey: 019bcbb260cc91be4c76c8d82a1349f0783048a8830374425ac1995c9e161ae327cb2342ee796d4f617d0df2409fed68ef8e14cfa4d790636ed9763298b3a0f2

Signature: 2ff8d31fa5b70759083181cf1dbb0a91b75fc02f6fd4b1fb11df529586b8b7a4109e44dcacae1b8f2e2a7745f0ac2c560a7af1770f092c6e1cfedb45f62e330e1aa0f1c5f02db6e2e05c84fb4e15d4ae1ca24ae8c2eef359e614ced6b14ddcef21a7d03524f7c9ff098d9c29429b0982e2048253a90a1787e9baf4d3e2c40572

Signature verified!