Skip to content

Tech: proof of ownership implementation #80

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

Closed
iltoga opened this issue Jul 19, 2019 · 0 comments · Fixed by #90
Closed

Tech: proof of ownership implementation #80

iltoga opened this issue Jul 19, 2019 · 0 comments · Fixed by #90
Assignees
Labels
CORE core functionalities FEATURE New feature or request
Milestone

Comments

@iltoga
Copy link
Contributor

iltoga commented Jul 19, 2019

Description

Proof of ownership is a message, signed by the node, that can be used by a client to prove node ownership. For instance can be used as a way to authenticate to the node and perform administrative tasks, such as requesting a change of the node private/public key.
This message is returned by an api call consumed by the client (/noderegistration/getproofofownership).

See https://docs.google.com/document/d/118CdR0WOIpZx4C9Hnx-JsrHz3vXn9OZ6eMokk9y71hk/edit#bookmark=id.f379wvfhj4m5 for details

Breakdown

  • implement Generate Proof of Ownership function:
    • lookup latest block height+hash in the db
    • lookup owner account address from config
    • sign these data with its node private key
  • implement Validate Proof of Ownership function:
    • validate that signature on the proof is valid for the provided node public key
    • validate that the height is not more than X blocks older than the current block height
    • look up block in the db where height = the height in the proof of ownership message, and verify the block hash in the proof also matches
  • implement grpc api for the client to consume the proof of ownership request:
    • api endpoint: /nodeadmin/getProofOfOwnership
    • request body:
      • signature ([]byte)
    • response data
      • accountType (uint32): account type
      • accountAddress (string): account address
      • blockHash ([]byte): last block hash
      • blockHeight (uint32): height of last block hash
      • signature ([]bytes): signature of all the above fields (with node's private key)
    • business logic:
      • validate request by verifying the 'signature' field is been signed using the node owner's account address (for now we don't have it and this data can be mocked just not to break the data flow. in future the node, after installation, should already contain a owner's account address, together with a default node private key)
      • if request is valid:
        • call Generate Proof of Ownership function, that should return the message described above as 'response data'
        • return that message to the client

Additional Diagram / File

See https://docs.google.com/document/d/118CdR0WOIpZx4C9Hnx-JsrHz3vXn9OZ6eMokk9y71hk/edit#bookmark=id.f379wvfhj4m5 for details

References

#68

@iltoga iltoga added the FEATURE New feature or request label Jul 19, 2019
@iltoga iltoga added this to the Sprint 2 milestone Jul 19, 2019
komodo2662 added a commit that referenced this issue Jul 22, 2019
@andy-shi88 andy-shi88 modified the milestones: Sprint 2, Sprint 3 Aug 1, 2019
@andy-shi88 andy-shi88 added the CORE core functionalities label Aug 2, 2019
astaphobia pushed a commit that referenced this issue Aug 5, 2019
* #80 add core node admin services

* improve generate proof of ownership function

* on progress proof of ownership validation

* node message conversion from byte

* add nodeAdminCoreService test

* add config owner acc address

* recompiled schema after refactoring ProofOfOwnership protobuf
Refactored signature.go: changed method name from SignBlock  to SignByNode (to generalise message that are signed using node pri key)
Added GetBlockHash to blockUtil.go
Refactored nodeAdminCoreService.GenerateProofOfOwnership: now reusing methods from other service and packages to reduce duplication of business logic
added helpers interface and injected into NodeAdmin stuct to make its methods mockable
refactored unit test for GenerateProofOfOwnership

* added GetBlockByHeight to blockService and creted unit test
refactored ValidateProofOfOwnership method to reuse already (previously) implemented methods

* finished refactoring ValidateProofOfOwnership
moved all helper (mockable) methods to NodeAdminServiceHelpersInterface
fixed bug in GetSize for accountType (min size in bytes for an integer in protobuf v3 is 4, so we cannot have 2 or 1 byte fields)

* fixed loading config params: using configuration already loaded in main.go
fixed relative unit tests

* injected BlockService into NodeAdminService to make it mockable and refactored relative code/tests

* simplified unit tests by removing unecessary mocked queries (since now we mock direclty the blockservice, which is the one where queries needed to be mocked)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CORE core functionalities FEATURE New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants