Skip to content

Commit

Permalink
migrate to jose v4; draft authcrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-korotya committed Dec 10, 2024
1 parent d0efbb8 commit 05b3ec6
Show file tree
Hide file tree
Showing 7 changed files with 556 additions and 22 deletions.
16 changes: 9 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
module github.com/iden3/iden3comm/v2

go 1.18
go 1.21

toolchain go1.22.5

require (
github.com/ProtonMail/go-crypto v1.1.3
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564
github.com/go-jose/go-jose/v4 v4.0.4
github.com/google/uuid v1.6.0
github.com/iden3/driver-did-iden3 v0.0.5
github.com/iden3/go-circuits/v2 v2.4.0
Expand All @@ -16,7 +20,7 @@ require (
github.com/mr-tron/base58 v1.2.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
gopkg.in/go-jose/go-jose.v2 v2.6.1
golang.org/x/crypto v0.25.0
)

require (
Expand All @@ -31,7 +35,6 @@ require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/holiman/uint256 v1.2.0 // indirect
github.com/iden3/contracts-abi/state/go/abi v1.0.1 // indirect
Expand All @@ -55,10 +58,9 @@ require (
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
78 changes: 68 additions & 10 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mock/proving.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"encoding/json"
"math/big"

"github.com/go-jose/go-jose/v4"
"github.com/iden3/go-circuits/v2"
"github.com/iden3/go-iden3-core/v2/w3c"
"github.com/iden3/go-iden3-crypto/babyjub"
"github.com/iden3/go-jwz/v2"
"github.com/iden3/go-rapidsnark/types"
"gopkg.in/go-jose/go-jose.v2"
)

// ProvingMethodGroth16AuthV2 proving method to avoid using of proving key and wasm files
Expand Down
5 changes: 3 additions & 2 deletions packers/anoncrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package packers
import (
"encoding/json"

"github.com/go-jose/go-jose/v4"
"github.com/iden3/iden3comm/v2"
"github.com/pkg/errors"
"gopkg.in/go-jose/go-jose.v2"
)

// MediaTypeEncryptedMessage is media type for ecnrypted message
Expand Down Expand Up @@ -67,7 +67,8 @@ func (p *AnoncryptPacker) Pack(payload []byte, params iden3comm.PackerParams) ([
// Unpack returns unpacked message from transport envelope
func (p *AnoncryptPacker) Unpack(envelope []byte) (*iden3comm.BasicMessage, error) {

jwe, err := jose.ParseEncrypted(string(envelope))
jwe, err := jose.ParseEncrypted(
string(envelope), []jose.KeyAlgorithm{jose.ECDH_ES_A256KW}, []jose.ContentEncryption{jose.A256CBC_HS512})
if err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions packers/anoncrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"encoding/json"
"testing"

"github.com/go-jose/go-jose/v4"
"github.com/iden3/iden3comm/v2/mock"
"github.com/stretchr/testify/require"
"gopkg.in/go-jose/go-jose.v2"
)

func TestAnoncryptPacker_Pack(t *testing.T) {
Expand All @@ -26,7 +26,8 @@ func TestAnoncryptPacker_Pack(t *testing.T) {
require.NotEqual(t, 0, len(ciphertext))

// decrypt in user side.
jwe, err := jose.ParseEncrypted(string(ciphertext))
jwe, err := jose.ParseEncrypted(
string(ciphertext), []jose.KeyAlgorithm{jose.ECDH_ES_A256KW}, []jose.ContentEncryption{jose.A256CBC_HS512})
require.NoError(t, err)
require.EqualValues(t, jwe.Header.ExtraHeaders[jose.HeaderType], MediaTypeEncryptedMessage)

Expand Down
Loading

0 comments on commit 05b3ec6

Please sign in to comment.