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

DEV-1079: Split validation into basic and dynamic #285

Merged
merged 94 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
a5265f3
Minor improvements
askolesov Feb 18, 2022
0c11010
Implementation checkpoint
askolesov Feb 24, 2022
61fc7b6
Implementation
askolesov Feb 25, 2022
7f1d302
Types validation poc
askolesov Feb 25, 2022
bdf0300
Update basic validation for messages
askolesov Feb 25, 2022
41f8883
Validation implemetation
askolesov Feb 28, 2022
e90eeb5
Add `unique` helper
askolesov Feb 28, 2022
661b60d
Dynamic validaton implementation
askolesov Mar 1, 2022
7ee98ae
Add DID static validation without tests
Mar 2, 2022
00e222a
Merge pull request #291 from cheqd/DEV-705-did-validation
askolesov Mar 3, 2022
d868c87
Improve did validation primitives
askolesov Mar 3, 2022
bca70df
[DEV-705] Add DID and DIDURL validation with tests
Mar 5, 2022
4efacab
Switch to ozzo validation vramework
askolesov Mar 5, 2022
eb198b7
[DEV-705] make each test as independent
Mar 5, 2022
2208f67
[DEV-705] Add validation for VerificationDethod and Controller
Mar 5, 2022
acd0f39
[DEV-705] Add check that DID list is set
Mar 6, 2022
7b6b302
Verification method validation
askolesov Mar 7, 2022
9ba85d7
Finished static validation
askolesov Mar 8, 2022
4069187
Further improvements
askolesov Mar 8, 2022
14ed669
[DEV-705] Add JWK key verification
Mar 9, 2022
3cb95d8
Add todos
askolesov Mar 10, 2022
cfcfbab
Add ED25519 validation and tests
Mar 10, 2022
20bd72f
Implementation
askolesov Mar 11, 2022
826b00d
Minor edits
askolesov Mar 11, 2022
e05c3bc
For the previous commit
askolesov Mar 11, 2022
119d3db
Merge pull request #292 from cheqd/DEV-705-did-validation
askolesov Mar 11, 2022
c405c73
Fix did creation positive test
askolesov Mar 11, 2022
8496b8f
Add support for JWKs
askolesov Mar 11, 2022
56a5a4e
[DEV-705] change AlsoKnowAs field validation to just URI
Mar 11, 2022
9edb9f5
Tests for jwk signature verification
askolesov Mar 11, 2022
1d3f441
[DEV-705] Fix tests for MsgCreateDid
Mar 14, 2022
2cd08a0
UpdateDID implementation
askolesov Mar 14, 2022
b551fa9
Finish did update
askolesov Mar 15, 2022
ab5e6c0
Minor fixes
askolesov Mar 15, 2022
88a641d
Merge branch 'DEV-705-did-validation' into DEV-705
askolesov Mar 15, 2022
1af8f2d
Fix positive update test
askolesov Mar 15, 2022
a8b5c98
Improve comments
askolesov Mar 15, 2022
d48511f
Merge branch 'main' into DEV-705
askolesov Mar 15, 2022
ff054ae
Tidy go mods
askolesov Mar 15, 2022
ed1aa61
Merge branch 'main' into DEV-705
askolesov Mar 15, 2022
2fdc200
Fix go lint issues
askolesov Mar 15, 2022
1cee542
Merge branch 'DEV-705' of https://github.com/cheqd/cheqd-node into DE…
askolesov Mar 15, 2022
326ee65
Fix test workflow
askolesov Mar 15, 2022
dded348
Fix go lint issues
askolesov Mar 15, 2022
d14149f
Merge branch 'main' into DEV-705
askolesov Mar 15, 2022
2d00036
Revert unnecessary changes
askolesov Mar 15, 2022
467cad4
Improve eror messages on did update
askolesov Mar 16, 2022
7e70134
Rollback unnecessary change
askolesov Mar 16, 2022
1cd3e1d
Remove unused errors
askolesov Mar 16, 2022
90def38
Revert unnecessary chanes, add eof new lines
askolesov Mar 16, 2022
51be1c3
Make signature verification during creation similar to the verificati…
askolesov Mar 16, 2022
abb2d80
Revert "Make signature verification during creation similar to the ve…
askolesov Mar 16, 2022
9f65acf
[DEV-705] The latest changes around UpdateDid functionality
Mar 16, 2022
fdab46d
Make validation rules naming consistent
askolesov Mar 17, 2022
1c7df44
For the previous commit
askolesov Mar 17, 2022
74bbf1e
Bump module consensus version
askolesov Mar 17, 2022
9022554
Fix update logix where extra signatures were required
askolesov Mar 17, 2022
301c3ad
[DEV-705] Tests refactoring
Mar 17, 2022
452e8cb
Add fopport for multiple signaturess to cli
askolesov Mar 17, 2022
86b3bf7
Fix bash tests
askolesov Mar 17, 2022
c46af97
Fix go linter issues
askolesov Mar 17, 2022
76932bf
Pin go version in docker
askolesov Mar 17, 2022
1039d5a
Merge remote-tracking branch 'origin/DEV-705' into DEV-705-did-valida…
Mar 17, 2022
985349b
[DEV-705] Fix verification method tests
Mar 17, 2022
1aab462
Fix upgrade test
askolesov Mar 17, 2022
77d9c3e
Merge remote-tracking branch 'origin/DEV-705' into DEV-705-did-valida…
Mar 17, 2022
dfad749
[DEV-705] fix python-based tests
Mar 17, 2022
ede86b0
[DEV-705] Fix debian test
Mar 17, 2022
3166ec9
fix upgrade tests
Toktar Mar 17, 2022
adba304
fix upgrade tests
Toktar Mar 17, 2022
6383bf9
fix upgrade tests
Toktar Mar 17, 2022
b046ff1
Bump IBC version
askolesov Mar 17, 2022
2699959
Get rid of the odd library
askolesov Mar 17, 2022
d0d3c4e
[DEV-705] fix upgrade tests
Toktar Mar 17, 2022
25767c6
[DEV-705] fix upgrade tests
Toktar Mar 17, 2022
dabd9b1
[DEV-705] Add --home for new_docker
Mar 17, 2022
693eb13
Simplify grpc gateway path
askolesov Mar 17, 2022
194b6d7
Fix error message
askolesov Mar 17, 2022
c91ca1e
[DEV-705] fix upgrade tests
Mar 18, 2022
e06c6ff
[DEV-705] fix upgrade test
Mar 18, 2022
6784128
[DEV-705] Fix upgrade test
Mar 18, 2022
afea105
[DEV-705] fix upgrade test
Mar 18, 2022
60af20c
[DEV-705] Fix upgrade test
Mar 18, 2022
e85ae31
[DEV-705] Fix upgrade test again
Mar 18, 2022
4af599c
[DEV-705] get -d back
Mar 18, 2022
4916717
[DEV-705] Get rid of --ver-key
Mar 18, 2022
e41afb1
[DEV-705] Get local_tx_send back
Mar 18, 2022
b094a0b
Merge pull request #300 from cheqd/DEV-705-did-validation
askolesov Mar 18, 2022
3fc4544
Fix linter issues
askolesov Mar 18, 2022
33cf211
Merge branch 'DEV-705-did-validation' into DEV-705
askolesov Mar 18, 2022
6389eab
Changed user to cheqd
ankurdotb Mar 18, 2022
ab50855
Change user back to root
askolesov Mar 18, 2022
3e21a23
Revert "Change user back to root"
askolesov Mar 18, 2022
8d0d6f0
Revert "Changed user to cheqd"
askolesov Mar 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions x/cheqd/keeper/msg_server_did.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,39 @@ func (k msgServer) CreateDid(goCtx context.Context, msg *types.MsgCreateDid) (*t
ctx := sdk.UnwrapSDKContext(goCtx)
prefix := k.GetDidPrefix(ctx)

didMsg := msg.GetPayload()
if err := didMsg.Validate(prefix); err != nil {
payload := msg.GetPayload()
if err := payload.Validate(prefix); err != nil {
return nil, err
}

if err := k.ValidateDidControllers(&ctx, didMsg.Id, didMsg.Controller, didMsg.VerificationMethod); err != nil {
if err := k.ValidateDidControllers(&ctx, payload.Id, payload.Controller, payload.VerificationMethod); err != nil {
return nil, err
}

if err := k.VerifySignature(&ctx, didMsg, didMsg.GetSigners(), msg.GetSignatures()); err != nil {
if err := k.VerifySignature(&ctx, payload, payload.GetSigners(), msg.GetSignatures()); err != nil {
return nil, err
}

// Checks that the did doesn't exist
if k.HasDid(ctx, didMsg.Id) {
return nil, sdkerrors.Wrap(types.ErrDidDocExists, fmt.Sprintf("DID is already used by DIDDoc %s", didMsg.Id))
if k.HasDid(ctx, payload.Id) {
return nil, sdkerrors.Wrap(types.ErrDidDocExists, fmt.Sprintf("DID is already used by DIDDoc %s", payload.Id))
}

var did = types.Did{
Context: didMsg.Context,
Id: didMsg.Id,
Controller: didMsg.Controller,
VerificationMethod: didMsg.VerificationMethod,
Authentication: didMsg.Authentication,
AssertionMethod: didMsg.AssertionMethod,
CapabilityInvocation: didMsg.CapabilityInvocation,
CapabilityDelegation: didMsg.CapabilityDelegation,
KeyAgreement: didMsg.KeyAgreement,
AlsoKnownAs: didMsg.AlsoKnownAs,
Service: didMsg.Service,
}

metadata := types.NewMetadata(ctx)
Context: payload.Context,
Id: payload.Id,
Controller: payload.Controller,
VerificationMethod: payload.VerificationMethod,
Authentication: payload.Authentication,
AssertionMethod: payload.AssertionMethod,
CapabilityInvocation: payload.CapabilityInvocation,
CapabilityDelegation: payload.CapabilityDelegation,
KeyAgreement: payload.KeyAgreement,
AlsoKnownAs: payload.AlsoKnownAs,
Service: payload.Service,
}

metadata := types.NewMetadataFromContext(ctx)
id, err := k.AppendDid(ctx, did, &metadata)
if err != nil {
return nil, err
Expand Down Expand Up @@ -110,7 +110,7 @@ func (k msgServer) UpdateDid(goCtx context.Context, msg *types.MsgUpdateDid) (*t
Service: didMsg.Service,
}

metadata := types.NewMetadata(ctx)
metadata := types.NewMetadataFromContext(ctx)
metadata.Created = oldStateValue.Metadata.Created
metadata.Deactivated = oldStateValue.Metadata.Deactivated

Expand Down
9 changes: 0 additions & 9 deletions x/cheqd/types/messages.go

This file was deleted.

2 changes: 1 addition & 1 deletion x/cheqd/types/stateValue.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewStateValue(data StateValueData, metadata *Metadata) (*StateValue, error)
return &StateValue{Data: any, Metadata: metadata}, nil
}

func NewMetadata(ctx sdk.Context) Metadata {
func NewMetadataFromContext(ctx sdk.Context) Metadata {
ankurdotb marked this conversation as resolved.
Show resolved Hide resolved
created := ctx.BlockTime().String()
txHash := base64.StdEncoding.EncodeToString(tmhash.Sum(ctx.TxBytes()))

Expand Down
File renamed without changes.
File renamed without changes.