Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IF: Generate bls key pair #1594

Merged
merged 7 commits into from
Sep 6, 2023
Merged

Conversation

linh2931
Copy link
Member

@linh2931 linh2931 commented Sep 5, 2023

Resolves #1525

Add leap-util subcommands to create key pairs and pop (proof of possession), and tests.

Help looks like

./leap-util bls create --help-all
Create various items
Usage: bin/leap-util bls create [OPTIONS] SUBCOMMAND

Options:
  -h,--help              Print this help message and exit
  --help-all             Show all help


Subcommands:
├  key                    Create a new keypair and print the public and private keys
│
└  pop                    Create proof of possession for the corresponding public key of a given private key

./leap-util bls create key --help-all
Create a new keypair and print the public and private keys
Usage: bin/leap-util bls create key [OPTIONS]

Options:
  -h,--help              Print this help message and exit
  --help-all             Show all help
  -f,--file TEXT         Name of file to write private/public key output to. (Must be set, unless "--to-console" is passed
  --to-console           Print private/public keys to console.

./leap-util bls create pop --help-all
Create proof of possession for the corresponding public key of a given private key
Usage: bin/leap-util bls create pop [OPTIONS]

Options:
  -h,--help              Print this help message and exit
  --help-all             Show all help
  -f,--file TEXT         Name of file storing the private key. (one and only one of "-f,--file" and "--private-key" must be set)
  --private-key TEXT     The private key. (one and only one of "-f,--file" and "--private-key" must be set)

Create key pair looks like

./leap-util bls create key --to-console
Private key: PVT_BLS_qTV8Td/8NUuPzBvEkO3ofEA5nCyFdBHxv50H9GACHUCY6hXw
Public key: PUB_BLS_laqiihyNRuivOF5QLo6lC20nKm5XdC87gEOtvsAnPtDd4TeaOHqF3hqPa0XOUFg+/BfRNg==
Proof of Possession: SIG_BLS_lrd6xlmZFPdBcx6sEAErBeivkDTrxdiwyeCUbiU/q8JMVErkCSCNBbW5YCJnkblwEWAklvYHbVoZ0OUHpB8jkkYz35qoe1+rvjsvNAv9nS2tQqmhtBXOWsyLPNL7RLPO2gDojw==

Create pop looks like

./leap-util bls create pop --private-key PVT_BLS_qTV8Td/8NUuPzBvEkO3ofEA5nCyFdBHxv50H9GACHUCY6hXw
Proof of Possession: SIG_BLS_lrd6xlmZFPdBcx6sEAErBeivkDTrxdiwyeCUbiU/q8JMVErkCSCNBbW5YCJnkblwEWAklvYHbVoZ0OUHpB8jkkYz35qoe1+rvjsvNAv9nS2tQqmhtBXOWsyLPNL7RLPO2gDojw==
Public key: PUB_BLS_laqiihyNRuivOF5QLo6lC20nKm5XdC87gEOtvsAnPtDd4TeaOHqF3hqPa0XOUFg+/BfRNg==

programs/leap-util/actions/bls.cpp Outdated Show resolved Hide resolved
programs/leap-util/actions/bls.cpp Outdated Show resolved Hide resolved
programs/leap-util/actions/bls.cpp Outdated Show resolved Hide resolved
programs/leap-util/actions/bls.cpp Outdated Show resolved Hide resolved
programs/leap-util/actions/bls.cpp Outdated Show resolved Hide resolved
programs/leap-util/actions/bls.cpp Outdated Show resolved Hide resolved
programs/leap-util/actions/bls.cpp Show resolved Hide resolved
programs/leap-util/actions/bls.hpp Outdated Show resolved Hide resolved
tests/leap_util_bls_test.py Outdated Show resolved Hide resolved
tests/leap_util_bls_test.py Outdated Show resolved Hide resolved
@arhag arhag linked an issue Sep 5, 2023 that may be closed by this pull request
@heifner heifner changed the title Generate bls key pair IF: Generate bls key pair Sep 5, 2023

int bls_actions::create_key() {
if (opt->key_file.empty() && !opt->print_console) {
std::cerr << "ERROR: Either indicate a file using \"--file\" or pass \"--to-console\"" << std::endl;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\"-f, --file\" (add -f to the message)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

std::cerr << "ERROR: Either indicate a file using \"--file\" or pass \"--to-console\"" << std::endl;
return -1;
} else if (!opt->key_file.empty() && opt->print_console) {
std::cerr << "ERROR: Only one of \"--file\" or pass \"--to-console\" can be provided" << std::endl;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\"-f, --file\" (add -f to the message)

@linh2931 linh2931 merged commit 64f7f89 into hotstuff_integration Sep 6, 2023
@linh2931 linh2931 deleted the generate_bls_key_pair branch September 6, 2023 19:04
@ericpassmore
Copy link
Contributor

Note:start
group: IF
category: CRYPTO
summary: ./leap-util bls create pop new leap util command to generate proof of possession keys. Generated keys are BLS keys in raw, affine form.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IF: Generate BLS key pairs in leap-util
5 participants