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

Upgrade github.com/iden3/go-iden3-core to v2 and bump self version to v2 #29

Merged
merged 18 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
18 changes: 7 additions & 11 deletions .github/workflows/ci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v1
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: 1.20.4
- name: Checkout code
uses: actions/checkout@v2
- name: install golangci-lint
run:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $GITHUB_WORKSPACE v1.52.2
- name: lint
run: |
go version
$GITHUB_WORKSPACE/golangci-lint version
$GITHUB_WORKSPACE/golangci-lint --config .golangci.yml run
uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.52.2
8 changes: 4 additions & 4 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
test:
strategy:
matrix:
containers: [ 1.19, 1.18 ]
containers: [ 1.20.4, 1.19, 1.18 ]
runs-on: ubuntu-latest
container: golang:${{ matrix.containers }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
Expand All @@ -30,4 +30,4 @@ jobs:
- name: Update go modules
run: go mod tidy
- name: Unit Tests
run: make test
run: go test -v -race -timeout=60s ./...
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module github.com/iden3/iden3comm
module github.com/iden3/iden3comm/v2

go 1.18

require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/gofrs/uuid v3.3.0+incompatible
github.com/iden3/go-circuits v1.0.3
github.com/iden3/go-iden3-core v1.0.2
github.com/iden3/go-circuits/v2 v2.0.0-20230509163947-35d52ef4e2b8
github.com/iden3/go-iden3-core/v2 v2.0.0-20230505110120-f4681972ad45
github.com/iden3/go-iden3-crypto v0.0.15
github.com/iden3/go-jwz v1.0.0
github.com/iden3/go-jwz/v2 v2.0.0-20230509174319-3791b6c3e946
github.com/iden3/go-rapidsnark/types v0.0.3
github.com/iden3/go-schema-processor v1.1.6-0.20230503142726-f93681ed1b6b
github.com/iden3/go-schema-processor/v2 v2.0.0-20230509182548-f9ee518c3f71
github.com/lestrrat-go/jwx/v2 v2.0.9-0.20230429214153-5090ec1bd2cd
github.com/mr-tron/base58 v1.2.0
github.com/pkg/errors v0.9.1
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/iden3/go-circuits v1.0.3 h1:mZqHvuXIAjCQdwRFiq2472KYfKHtzomYoKu0BtF3+5c=
github.com/iden3/go-circuits v1.0.3/go.mod h1:YbuzfvSyr8BwNHnjRJEvnRQ2lJKzVQ9Sgz3OAdqv5Is=
github.com/iden3/go-iden3-core v1.0.2 h1:HwNDFeqcUv4ybZj5tH+58JKWKarn/qqBpNCqTLxGP0Y=
github.com/iden3/go-iden3-core v1.0.2/go.mod h1:X4PjlJG8OsEQEsSbzzYqqAk2olYGZ2nuGqiUPyEYjOo=
github.com/iden3/go-circuits/v2 v2.0.0-20230509163947-35d52ef4e2b8 h1:zuPYYua9lyD5uyOsNLPdA9v16Id44PbpnC2BYldfDXU=
github.com/iden3/go-circuits/v2 v2.0.0-20230509163947-35d52ef4e2b8/go.mod h1:xqXarAGueeu+75Z/f/liAq2DYmQJQ6PrQbgVqdTxPyQ=
github.com/iden3/go-iden3-core/v2 v2.0.0-20230505110120-f4681972ad45 h1:0XwrQksyOrKz86bDZSuYbGGJLIvGQyTHGEhFP4QWqq4=
github.com/iden3/go-iden3-core/v2 v2.0.0-20230505110120-f4681972ad45/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-jwz v1.0.0 h1:tRyAMK9unf21z8uNvJ8V2LFvXdlYZe7pgRE7V19Q/vs=
github.com/iden3/go-jwz v1.0.0/go.mod h1:vX0kANbDvoNUAevlWyU1UDVQ0PWgplOK0YK1+8BaOz4=
github.com/iden3/go-jwz/v2 v2.0.0-20230509174319-3791b6c3e946 h1:F9oOe1ZMlJ8rZ/1kraznp714T4DBY5dRiFCkhgDFZgo=
github.com/iden3/go-jwz/v2 v2.0.0-20230509174319-3791b6c3e946/go.mod h1:XSQlWuAYnFmp7LVeTC4T+airr8ccEPuaF4pUh0A9sLE=
github.com/iden3/go-merkletree-sql/v2 v2.0.4 h1:Dp089P3YNX1BE8+T1tKQHWTtnk84Y/Kr7ZAGTqwscoY=
github.com/iden3/go-merkletree-sql/v2 v2.0.4/go.mod h1:kRhHKYpui5DUsry5RpveP6IC4XMe6iApdV9VChRYuEk=
github.com/iden3/go-rapidsnark/prover v0.0.10 h1:NvOfRPpex/k646UsqOcUy7a7uVl17t4ok9kWvpQg4+k=
Expand All @@ -30,8 +30,8 @@ github.com/iden3/go-rapidsnark/verifier v0.0.5 h1:J7y0ovrEjDQoWtZmlrp4tgGng1A9fa
github.com/iden3/go-rapidsnark/verifier v0.0.5/go.mod h1:KgL3Yr9NehlFDI4EIWVLE3UDUi8ulyjbp7HcXSBfiGI=
github.com/iden3/go-rapidsnark/witness v0.0.6 h1:p+6QBymSV3XWm1kB2PL2vlXxKXJN8GyWuqNJv/0PGGU=
github.com/iden3/go-rapidsnark/witness v0.0.6/go.mod h1:57IHQpnvx0CeS6cAT07oN/lqwT5LRc4zicYoZ1cnAPE=
github.com/iden3/go-schema-processor v1.1.6-0.20230503142726-f93681ed1b6b h1:JaGm7iDCsPSbgoYFxcZuZ1YiutZarbQm1UyIu2pV4Zc=
github.com/iden3/go-schema-processor v1.1.6-0.20230503142726-f93681ed1b6b/go.mod h1:OoxGutmHbpU42/mYCkzYSf4nhsEZ0Ws0ouBpWxcjp0w=
github.com/iden3/go-schema-processor/v2 v2.0.0-20230509182548-f9ee518c3f71 h1:Tix/kH7NWOXjzZgS7TTwNaAjvWNHFx4RAVqeYTXXsSY=
github.com/iden3/go-schema-processor/v2 v2.0.0-20230509182548-f9ee518c3f71/go.mod h1:NVz+rOZjWWH6rySnjJ4kzlyGiKXwkpUyXK1Kgbw7Yzc=
github.com/iden3/wasmer-go v0.0.1 h1:TZKh8Se8B/73PvWrcu+FTU9L1k5XYAmtFbioj7l0Uog=
github.com/iden3/wasmer-go v0.0.1/go.mod h1:ZnZBAO012M7o+Q1INXLRIxKQgEcH2FuwL0Iga8A4ufg=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
Expand Down
12 changes: 7 additions & 5 deletions mock/proving.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"encoding/json"
"math/big"

"github.com/iden3/go-circuits"
core "github.com/iden3/go-iden3-core"
"github.com/iden3/go-circuits/v2"
did "github.com/iden3/go-iden3-core/v2/did"
"github.com/iden3/go-iden3-crypto/babyjub"
"github.com/iden3/go-jwz"
"github.com/iden3/go-jwz/v2"
"github.com/iden3/go-rapidsnark/types"
"gopkg.in/go-jose/go-jose.v2"
)
Expand Down Expand Up @@ -46,12 +46,14 @@ func (m *ProvingMethodGroth16AuthV2) Prove(_, _, _ []byte) (*types.ZKProof, erro
C: nil,
Protocol: "groth16",
},
PubSignals: []string{"19229084873704550357232887142774605442297337229176579229011342091594174977", "6110517768249559238193477435454792024732173865488900270849624328650765691494", "1243904711429961858774220647610724273798918457991486031567244100767259239747"},
PubSignals: []string{"19229084873704550357232887142774605442297337229176579229011342091594174977",
"6110517768249559238193477435454792024732173865488900270849624328650765691494",
"1243904711429961858774220647610724273798918457991486031567244100767259239747"},
}, nil
}

// PrepareAuthInputs returns mocked inputs for auth circuit
func PrepareAuthInputs(hash []byte, _ *core.DID, _ circuits.CircuitID) ([]byte, error) {
func PrepareAuthInputs(hash []byte, _ *did.DID, _ circuits.CircuitID) ([]byte, error) {
challenge := new(big.Int).SetBytes(hash)

userMockedPK := "28156abe7fe2fd433dc9df969286b96666489bac508612d0e16593e944c4f69e"
Expand Down
44 changes: 24 additions & 20 deletions packager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"testing"

"github.com/gofrs/uuid"
core "github.com/iden3/go-iden3-core"
"github.com/iden3/go-jwz"
"github.com/iden3/iden3comm"
"github.com/iden3/iden3comm/mock"
"github.com/iden3/iden3comm/packers"
"github.com/iden3/iden3comm/protocol"
"github.com/iden3/go-iden3-core/v2/did"
"github.com/iden3/go-jwz/v2"
"github.com/iden3/iden3comm/v2"
"github.com/iden3/iden3comm/v2/mock"
"github.com/iden3/iden3comm/v2/packers"
"github.com/iden3/iden3comm/v2/protocol"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -22,12 +22,12 @@ func TestPackagerPlainPacker(t *testing.T) {

identifier := "did:iden3:polygon:mumbai:x4jcHP4XHTK3vX58AHZPyHE8kYjneyE6FZRfz7K29"

senderDID, err := core.ParseDID(identifier)
senderDID, err := did.Parse(identifier)
assert.NoError(t, err)

targetIdentifier := "did:iden3:polygon:mumbai:wzWeGdtjvKtUP1oTxQP5t5iZGDX3HNfEU5xR8MZAt"

targetID, err := core.ParseDID(targetIdentifier)
targetID, err := did.Parse(targetIdentifier)
assert.NoError(t, err)

marshalledMsg, err := createFetchCredentialMessage(packers.MediaTypePlainMessage, senderDID, targetID)
Expand Down Expand Up @@ -58,12 +58,12 @@ func TestPackagerZKPPacker(t *testing.T) {

identifier := "did:iden3:polygon:mumbai:x4jcHP4XHTK3vX58AHZPyHE8kYjneyE6FZRfz7K29"

senderDID, err := core.ParseDID(identifier)
senderDID, err := did.Parse(identifier)
assert.NoError(t, err)

targetIdentifier := "did:iden3:polygon:mumbai:wzWeGdtjvKtUP1oTxQP5t5iZGDX3HNfEU5xR8MZAt"

targetID, err := core.ParseDID(targetIdentifier)
targetID, err := did.Parse(targetIdentifier)
assert.NoError(t, err)

marshalledMsg, err := createFetchCredentialMessage(packers.MediaTypeZKPMessage, senderDID, targetID)
Expand All @@ -88,20 +88,21 @@ func TestPackagerAnonryptPacker(t *testing.T) {

identifier := "did:iden3:polygon:mumbai:x4jcHP4XHTK3vX58AHZPyHE8kYjneyE6FZRfz7K29"

senderDID, err := core.ParseDID(identifier)
senderDID, err := did.Parse(identifier)
assert.NoError(t, err)

targetIdentifier := "did:iden3:polygon:mumbai:wzWeGdtjvKtUP1oTxQP5t5iZGDX3HNfEU5xR8MZAt"

targetID, err := core.ParseDID(targetIdentifier)
targetID, err := did.Parse(targetIdentifier)
assert.NoError(t, err)

marshalledMsg, err := createFetchCredentialMessage(packers.MediaTypeEncryptedMessage, senderDID, targetID)
assert.NoError(t, err)

key, err := mock.ResolveKeyID(mock.MockRecipientKeyID)
require.NoError(t, err)
envelope, err := pm.Pack(packers.MediaTypeEncryptedMessage, marshalledMsg, packers.AnoncryptPackerParams{RecipientKey: &key})
envelope, err := pm.Pack(packers.MediaTypeEncryptedMessage, marshalledMsg,
packers.AnoncryptPackerParams{RecipientKey: &key})
assert.NoError(t, err)

unpackedMsg, unpackerType, err := pm.Unpack(envelope)
Expand All @@ -122,12 +123,12 @@ func TestPackagerZKPPacker_OtherMessageTypeInBody(t *testing.T) {

identifier := "did:iden3:polygon:mumbai:x4jcHP4XHTK3vX58AHZPyHE8kYjneyE6FZRfz7K29"

senderDID, err := core.ParseDID(identifier)
senderDID, err := did.Parse(identifier)
assert.NoError(t, err)

targetIdentifier := "did:iden3:polygon:mumbai:wzWeGdtjvKtUP1oTxQP5t5iZGDX3HNfEU5xR8MZAt"

targetID, err := core.ParseDID(targetIdentifier)
targetID, err := did.Parse(targetIdentifier)
assert.NoError(t, err)

marshalledMsg, err := createFetchCredentialMessage(packers.MediaTypePlainMessage, senderDID, targetID)
Expand All @@ -153,7 +154,7 @@ func TestUnpackWithType(t *testing.T) {

identifier := "did:iden3:polygon:mumbai:x4jcHP4XHTK3vX58AHZPyHE8kYjneyE6FZRfz7K29"

senderDID, err := core.ParseDID(identifier)
senderDID, err := did.Parse(identifier)
assert.NoError(t, err)

var msg protocol.CredentialFetchRequestMessage
Expand Down Expand Up @@ -182,7 +183,7 @@ func TestUnpackWithType(t *testing.T) {
assert.Equal(t, unpackedMsg.Typ, packers.MediaTypeZKPMessage)
}

func createFetchCredentialMessage(typ iden3comm.MediaType, from, to *core.DID) ([]byte, error) {
func createFetchCredentialMessage(typ iden3comm.MediaType, from, to *did.DID) ([]byte, error) {

var msg protocol.CredentialFetchRequestMessage
msg.From = from.String()
Expand All @@ -205,17 +206,20 @@ func initPackageManager(t *testing.T) *iden3comm.PackageManager {
pm := iden3comm.NewPackageManager()
err := pm.RegisterPackers(&packers.PlainMessagePacker{})
require.NoError(t, err)
mockedProvingMethod := &mock.ProvingMethodGroth16AuthV2{ProvingMethodAlg: jwz.ProvingMethodAlg{Alg: "groth16-mock", CircuitID: "authV2"}}
mockedProvingMethod := &mock.ProvingMethodGroth16AuthV2{ProvingMethodAlg: jwz.ProvingMethodAlg{Alg: "groth16-mock",
CircuitID: "authV2"}}

jwz.RegisterProvingMethod(mockedProvingMethod.ProvingMethodAlg, func() jwz.ProvingMethod {
return mockedProvingMethod
})

mockVerificationParam := make(map[jwz.ProvingMethodAlg]packers.VerificationParams)
mockVerificationParam[mockedProvingMethod.ProvingMethodAlg] = packers.NewVerificationParams([]byte(""), mock.VerifyState)
mockVerificationParam[mockedProvingMethod.ProvingMethodAlg] = packers.NewVerificationParams([]byte(""),
mock.VerifyState)

mockProvingParamMap := make(map[jwz.ProvingMethodAlg]packers.ProvingParams)
mockProvingParamMap[mockedProvingMethod.ProvingMethodAlg] = packers.NewProvingParams(mock.PrepareAuthInputs, []byte{}, []byte{})
mockProvingParamMap[mockedProvingMethod.ProvingMethodAlg] = packers.NewProvingParams(mock.PrepareAuthInputs,
[]byte{}, []byte{})

err = pm.RegisterPackers(packers.NewZKPPacker(mockProvingParamMap, mockVerificationParam))
require.NoError(t, err)
Expand Down
5 changes: 2 additions & 3 deletions packers/anoncrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ package packers
import (
"encoding/json"

"github.com/iden3/iden3comm"
"github.com/iden3/iden3comm/v2"
"github.com/pkg/errors"

jose "gopkg.in/go-jose/go-jose.v2"
"gopkg.in/go-jose/go-jose.v2"
)

// MediaTypeEncryptedMessage is media type for ecnrypted message
Expand Down
3 changes: 1 addition & 2 deletions packers/anoncrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/iden3/iden3comm/mock"

"github.com/iden3/iden3comm/v2/mock"
"github.com/stretchr/testify/require"
"gopkg.in/go-jose/go-jose.v2"
)
Expand Down
11 changes: 6 additions & 5 deletions packers/jws.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"encoding/hex"
"encoding/json"

"github.com/iden3/go-schema-processor/verifiable"
"github.com/iden3/iden3comm"
"github.com/iden3/iden3comm/packers/providers/bjj"
"github.com/iden3/iden3comm/packers/providers/es256k"
"github.com/iden3/go-schema-processor/v2/verifiable"
"github.com/iden3/iden3comm/v2"
"github.com/iden3/iden3comm/v2/packers/providers/bjj"
"github.com/iden3/iden3comm/v2/packers/providers/es256k"
"github.com/lestrrat-go/jwx/v2/jwa"
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/lestrrat-go/jwx/v2/jws"
Expand Down Expand Up @@ -306,7 +306,8 @@ func resolveAuthToVM(
return verifiable.CommonVerificationMethod{}, errors.New("not found")
}

func extractVerificationKey(alg jwa.SignatureAlgorithm, vm verifiable.CommonVerificationMethod) (jws.VerifyOption, error) {
func extractVerificationKey(alg jwa.SignatureAlgorithm, vm verifiable.CommonVerificationMethod) (jws.VerifyOption,
error) {
supportedAlg, ok := supportedAlgorithms[alg]
if !ok {
return nil, errors.Errorf("unsupported algorithm: '%s'", alg)
Expand Down
6 changes: 3 additions & 3 deletions packers/jws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"os"
"testing"

"github.com/iden3/go-schema-processor/verifiable"
"github.com/iden3/iden3comm/packers/providers/bjj"
"github.com/iden3/iden3comm/packers/providers/es256k"
"github.com/iden3/go-schema-processor/v2/verifiable"
"github.com/iden3/iden3comm/v2/packers/providers/bjj"
"github.com/iden3/iden3comm/v2/packers/providers/es256k"
"github.com/lestrrat-go/jwx/v2/jwa"
"github.com/stretchr/testify/require"
)
Expand Down
2 changes: 1 addition & 1 deletion packers/plain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package packers
import (
"encoding/json"

"github.com/iden3/iden3comm"
"github.com/iden3/iden3comm/v2"
"github.com/pkg/errors"
)

Expand Down
Loading