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

ION SDK #307

Merged
merged 41 commits into from
Mar 21, 2023
Merged

ION SDK #307

merged 41 commits into from
Mar 21, 2023

Conversation

decentralgabe
Copy link
Member

@decentralgabe decentralgabe commented Mar 17, 2023

Add feature parity to the following repos:

@decentralgabe decentralgabe changed the title Ion sdk tools ION SDK & Tools Mar 17, 2023
@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2023

Codecov Report

Merging #307 (2477b7d) into main (a243dcc) will increase coverage by 0.23%.
The diff coverage is 61.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #307      +/-   ##
==========================================
+ Coverage   58.68%   58.91%   +0.23%     
==========================================
  Files          42       45       +3     
  Lines        4717     5125     +408     
==========================================
+ Hits         2768     3019     +251     
- Misses       1462     1568     +106     
- Partials      487      538      +51     
Impacted Files Coverage Δ
credential/status/statuslist2021.go 64.65% <ø> (ø)
did/did.go 100.00% <ø> (ø)
did/peer.go 65.58% <ø> (ø)
did/web.go 67.80% <ø> (ø)
did/ion/did.go 46.00% <46.00%> (ø)
did/ion/crypto.go 62.88% <62.88%> (ø)
did/ion/request.go 64.16% <64.16%> (ø)

@decentralgabe decentralgabe changed the title ION SDK & Tools ION SDK Mar 17, 2023
@decentralgabe
Copy link
Member Author

depends on #308

* main:
  Bump github.com/goccy/go-json from 0.10.0 to 0.10.2 (#310)
  Bump golang.org/x/term from 0.5.0 to 0.6.0 (#299)
  Update JWX lib to use v2 (#308)

# Conflicts:
#	credential/signing/jws.go
#	credential/signing/jwt.go
#	crypto/jwk_test.go
#	crypto/jwt.go
#	go.mod
#	go.sum
#	wasm/static/main.wasm
@decentralgabe decentralgabe marked this pull request as ready for review March 20, 2023 20:13
privateKey *btcec.PrivateKey
}

// NewBTCSignerVerifier creates a new signer/verifier for signatures suited for the BTC blockchain
Copy link
Contributor

Choose a reason for hiding this comment

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

Is a signer/verifier meant to implement a specific interface? There exists cryptosuite.Signer, but it's unclear to me what they should represent.

Copy link
Member Author

Choose a reason for hiding this comment

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

not a specific interface, just a utility to wrap the key

did/ion/crypto_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

There are a lot of methods above that aren't tested. What's the rationale for not doing so?

Copy link
Member Author

Choose a reason for hiding this comment

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

they are all tested through the test vectors, though not directly

did/ion/did.go Show resolved Hide resolved
did/ion/did.go Show resolved Hide resolved
did/ion/request.go Outdated Show resolved Hide resolved
publicKeys := make(map[string]PublicKey)
for _, publicKey := range s.PublicKeysToAdd {
if _, ok := publicKeys[publicKey.ID]; ok {
return fmt.Errorf("public key<%s> is duplicated", publicKey.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and elsewhere. If you want stack traces, use errors.Errorf. See https://stackoverflow.com/questions/61933650/whats-the-difference-between-errors-wrapf-errors-errorf-and-fmt-errorf for more details. (make sure it's not the native "errors" library).

Copy link
Member Author

Choose a reason for hiding this comment

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

good to know this, will update

did/ion/request.go Outdated Show resolved Hide resolved
Comment on lines 284 to 287
toBeSigned := struct {
UpdateKey crypto.PublicKeyJWK `json:"updateKey"`
DeltaHash string `json:"deltaHash"`
}{
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why an anonymous struct here vs defining it in model.go ?

Copy link
Member Author

Choose a reason for hiding this comment

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

ah was all anonymous first, forgot to update this

// NewUpdateRequest creates a new update request https://identity.foundation/sidetree/spec/#update
func NewUpdateRequest(didSuffix string, updateKey, nextUpdateKey crypto.PublicKeyJWK, signer BTCSignerVerifier, stateChange StateChange) (*UpdateRequest, error) {
if err := stateChange.IsValid(); err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and elsewhere in this func. I recommend chaining errors with either Wrap or using : and Errorf. See https://github.com/uber-go/guide/blob/master/style.md#error-wrapping for more details.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

decentralgabe and others added 9 commits March 20, 2023 15:32
Co-authored-by: Andres Uribe <auribe@tbd.email>
Co-authored-by: Andres Uribe <auribe@tbd.email>
Co-authored-by: Andres Uribe <auribe@tbd.email>
* origin/main:
  Bump github.com/multiformats/go-multibase from 0.1.1 to 0.2.0 (#313)
  Bump github.com/go-playground/validator/v10 from 10.11.2 to 10.12.0 (#311)

# Conflicts:
#	go.mod
#	go.sum
Copy link
Contributor

@andresuribe87 andresuribe87 left a comment

Choose a reason for hiding this comment

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

Not blocking, but part of an important convo.

did/ion/model.go Outdated
}

type Delta struct {
Patches []any `json:"patches,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

It's the classic oneof problem with golang, which has no great support :(

We could use the protobuf approach. It's a bit of additional work, but I think it's worth it. What are your thoughts?

@decentralgabe
Copy link
Member Author

@andresuribe87 I agree protobufs would work. I think JSON schemas would be a simpler solution.

since the source of truth is going to be an ion node (which will reject an invalid request) I think we are OK for now, but should think about it as an improvement

@decentralgabe decentralgabe merged commit 9ef2f8d into main Mar 21, 2023
@decentralgabe decentralgabe deleted the ion-sdk-tools branch March 21, 2023 19:30
decentralgabe added a commit that referenced this pull request Mar 22, 2023
* origin/main:
  ION SDK (#307)

# Conflicts:
#	wasm/static/main.wasm
decentralgabe added a commit that referenced this pull request Mar 22, 2023
* origin/main:
  make target optional (#316)
  ION SDK (#307)

# Conflicts:
#	go.mod
#	go.sum
#	wasm/static/main.wasm
This was referenced Mar 24, 2023
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.

None yet

3 participants