Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Mobile wrapper test #184

Closed
wants to merge 2 commits into from
Closed

Mobile wrapper test #184

wants to merge 2 commits into from

Conversation

decentralgabe
Copy link
Member

No description provided.

@codecov-commenter
Copy link

Codecov Report

Merging #184 (f16ac53) into main (c8caffd) will decrease coverage by 0.05%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
- Coverage   55.16%   55.11%   -0.06%     
==========================================
  Files          40       40              
  Lines        4374     4378       +4     
==========================================
  Hits         2413     2413              
- Misses       1565     1569       +4     
  Partials      396      396              
Impacted Files Coverage Δ
crypto/models.go 9.09% <0.00%> (-2.03%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

return false
}

func GetSupportedSignatureAlgs() []string {
Copy link
Contributor

@nrobi144 nrobi144 Sep 7, 2022

Choose a reason for hiding this comment

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

@decentralgabe seems like arrays aren't yet supported golang/go#14332

I took stab at this without any success:

package util

type StringArray interface {
	Add(s string) StringArray
	Get(i int) string
	Size() int
}

type StringArrayImpl struct {
	items []string
}

func (stringArray StringArrayImpl) Add(s string) StringArray{
	stringArray.items = append(stringArray.items, s)
	return stringArray
}

func (stringArray StringArrayImpl) Get(i int) string {
	return stringArray.items[i]
}

func (stringArray StringArrayImpl) Size() int {
	return len(stringArray.items)
}

func ToStringArray(s []string) StringArray {
	return StringArrayImpl{items: s}
}

where

func GetSupportedKeyTypes() util.StringArray {
	return util.ToStringArray([]string{keyTypeToString(ssi.Ed25519), keyTypeToString(ssi.X25519), keyTypeToString(ssi.Secp256k1), keyTypeToString(ssi.P224), keyTypeToString(ssi.P256), keyTypeToString(ssi.P384), keyTypeToString(ssi.P521), keyTypeToString(ssi.RSA)})
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Still investigating why the GenerateXYKey() functions are failing, I can see both ECDSAKeyPair and CryptoKeyPair

Screenshot 2022-09-07 at 13 28 55

Copy link
Contributor

Choose a reason for hiding this comment

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

Something's up with struct types.

Changing func GenerateX25519Key() (CryptoKeyPair, error) to func GenerateX25519Key() (string, error) works.

Even though gomobile has these rules:

  • Any function type all of whose parameters and results have supported types. Functions must return either no results, one result, or two results where the type of the second is the built-in 'error' type.
  • Any struct type, all of whose exported methods have supported function types and all of whose exported fields have supported types.

Copy link
Contributor

Choose a reason for hiding this comment

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

Update: using pointers for structs works:
For ex:

func GenerateEd25519Key() (*CryptoKeyPair, error) {
	privKey, pubKey, err := ssi.GenerateEd25519Key()
	return &CryptoKeyPair{
		PrivKey: privKey,
		PubKey:  pubKey,
	}, err
}

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 @nrobi144 I'm going to close this PR in favor of your projects.

let me know if I can help with more go-specific stuff

@decentralgabe decentralgabe deleted the mobile-wrapper-test branch September 7, 2022 15:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants