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

module for convert onchain verifiable credential on w3c verifiable cr… #83

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ issues:
linters:
- gosec
- dupl
- text: 'shadow: declaration of "(err|ctx)" shadows declaration at'
linters: [ govet ]
vmidyllic marked this conversation as resolved.
Show resolved Hide resolved
exclude-use-default: false
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module github.com/iden3/go-schema-processor/v2
go 1.18

require (
github.com/iden3/go-iden3-core/v2 v2.0.0-20230519124718-42b31ff46f37
github.com/google/uuid v1.3.0
github.com/iden3/go-iden3-core/v2 v2.0.3
github.com/iden3/go-iden3-crypto v0.0.15
github.com/iden3/go-merkletree-sql/v2 v2.0.4
github.com/ipfs/go-ipfs-api v0.6.0
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/iden3/go-iden3-core/v2 v2.0.0-20230519124718-42b31ff46f37 h1:JPH0tMr8geJO0vLhwTZkopHqm35ARCjCIKNab9rc6QI=
github.com/iden3/go-iden3-core/v2 v2.0.0-20230519124718-42b31ff46f37/go.mod h1:L9PxhWPvoS9qTb3inEkZBm1RpjHBt+VTwvxssdzbAdw=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/iden3/go-iden3-core/v2 v2.0.3 h1:ce9Jbw10zDsinWXFc05SiK2Hof/wu4zV4/ai5gQy29k=
github.com/iden3/go-iden3-core/v2 v2.0.3/go.mod h1:L9PxhWPvoS9qTb3inEkZBm1RpjHBt+VTwvxssdzbAdw=
github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4=
github.com/iden3/go-iden3-crypto v0.0.15/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E=
github.com/iden3/go-merkletree-sql/v2 v2.0.4 h1:Dp089P3YNX1BE8+T1tKQHWTtnk84Y/Kr7ZAGTqwscoY=
Expand Down
6 changes: 6 additions & 0 deletions verifiable/onchain/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package onchain

const (
BooleanHashTrue = "18586133768512220936620570745912940619677854269274689475585506675881198879027"
BooleanHashFalse = "19014214495641488759237505126948346942972912379615652741039992445865937985820"
Copy link
Contributor

Choose a reason for hiding this comment

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

You made those vars public deliberately? You are going to use it outside of this package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

)
61 changes: 61 additions & 0 deletions verifiable/onchain/credential.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package onchain

type CredentialSubjectField struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

give comments public to structures , not sure why linter didn't fail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Key string `json:"key"`
Value string `json:"value"`
RawValue string `json:"rawValue"` // hex representation of bytes
}

type State struct {
RootOfRoots string `json:"rootOfRoots"`
ClaimsTreeRoot string `json:"claimsTreeRoot"`
RevocationTreeRoot string `json:"revocationTreeRoot"`
Value string `json:"value"`
}

type IssuerData struct {
ID string `json:"id"`
State State `json:"state"`
}

type CredentialSchema struct {
ID string `json:"id"`
Type string `json:"_type"`
}

type MTP struct {
Root string `json:"root"`
Existence bool `json:"existence"`
Siblings []string `json:"siblings"`
Index string `json:"index"`
Value string `json:"value"`
AuxExistence bool `json:"auxExistence"`
AuxIndex string `json:"auxIndex"`
AuxValue string `json:"auxValue"`
}

type Proof struct {
Type string `json:"_type"`
CoreClaim []string `json:"coreClaim"`
IssuerData IssuerData `json:"issuerData"`
MTP MTP `json:"mtp"`
}

type CredentialStatus struct {
ID string `json:"id"`
Type string `json:"_type"`
RevocationNonce string `json:"revocationNonce"`
}

type Credential struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

is at a god idea to have such a structure public? Why we can't create some internal model and the W3C credential is the only credential that is public structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do it. But in this case function ConvertVerifiableCredential should accept []bytes instead of typed struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my opinion is okay to have offchain(w3c).VerifiableCredentials and onchain.Verifiable Credential. Since they are different a little bit.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm against this. Pretty sure it will confuse users of the library and ideologically I do not want to have a term onchain verifiable credential
@olomix @demonsh

ID string `json:"id"`
Context []string `json:"context"`
Type []string `json:"_type"`
Expiration string `json:"expirationDate"`
IssuanceDate string `json:"issuanceDate"`
Issuer string `json:"issuer"`
CredentialSubject []CredentialSubjectField `json:"credentialSubject"`
CredentialStatus CredentialStatus `json:"credentialStatus"`
CredentialSchema CredentialSchema `json:"credentialSchema"`
Proof []Proof `json:"proof"`
}
Loading