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

feat: Ability to generate a new identity #2760

Merged

Conversation

shahzadlone
Copy link
Member

Relevant issue(s)

Resolves #2554

Description

Now that the core_acp work is merged the identity generation becomes much more simple, with a did instead of source address. This util command can be handy to quickly generate new identity pairs with their did.

Demo

Issue the command:

$ defradb identity new

Output:

{
  "PrivateKey": "8wsOdJZCg06ISJxBqUyrD1ovDF5WgJJrSup2i4avnuU=",
  "PublicKey": "BG6dw3UW3rv+IiTXfL0LXvACw7Qz3DSBy1KmS/eSNrsrRkToBsize7zp+xwFrelPylOPgZguG7ZmirAtTaY89ow=",
  "DID": "did:key:z7r8oqgz72xy7Z7V5WGF21iWc7EY8vCpjZA1nGugoKjGeppeMkqeD7FV5AxEQAnciBz5vk5c2zrTZytofJNM8ZxyBzSpT"
}

How has this been tested?

  • cli test
  • unit tests

Specify the platform(s) on which this was tested:

  • WSL2

@shahzadlone shahzadlone added feature New feature or request area/acp Related to the acp (access control) system labels Jun 24, 2024
@shahzadlone shahzadlone added this to the DefraDB v0.12 milestone Jun 24, 2024
@shahzadlone shahzadlone requested a review from a team June 24, 2024 17:01
@shahzadlone shahzadlone self-assigned this Jun 24, 2024
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 78.21%. Comparing base (281aa77) to head (1af8970).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2760      +/-   ##
===========================================
+ Coverage    78.18%   78.21%   +0.03%     
===========================================
  Files          310      313       +3     
  Lines        23071    23111      +40     
===========================================
+ Hits         18038    18076      +38     
- Misses        3663     3664       +1     
- Partials      1370     1371       +1     
Flag Coverage Δ
all-tests 78.21% <80.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
acp/identity/errors.go 100.00% <ø> (ø)
cli/cli.go 100.00% <100.00%> (ø)
cli/identity.go 100.00% <100.00%> (ø)
cli/identity_new.go 85.71% <85.71%> (ø)
acp/identity/generate.go 60.00% <60.00%> (ø)

... and 12 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 281aa77...1af8970. Read the comment docs.

Copy link
Contributor

@islamaliev islamaliev left a comment

Choose a reason for hiding this comment

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

LGTM! I just have few minor suggestions.

var cmd = &cobra.Command{
Use: "new",
Short: "Generate a new identity",
Long: `Generate a new identity
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: would be useful for users to have more detailed documentation on why it's needed and how to use it or something like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Happy to take suggestions on what I should add. As for why it's needed (it's not) it's just a key pair + did generation utility command incase users ever want to generate a new identity using defradb rather than another key pair generation tool.

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

LGTM

@shahzadlone shahzadlone merged commit f627448 into sourcenetwork:develop Jun 25, 2024
38 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/acp Related to the acp (access control) system feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ACP - Generate Source Identity
3 participants