-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate go-dag-jose plugin (#8569)
* feat(dag-jose): integrate `go-dag-jose` plugin * test(dag-jose): sharness test for dag-jose plugin Co-authored-by: Eric Myhre <hash@exultant.us>
- Loading branch information
Showing
22 changed files
with
112 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package dagjose | ||
|
||
import ( | ||
"github.com/ipfs/go-ipfs/plugin" | ||
|
||
"github.com/ceramicnetwork/go-dag-jose/dagjose" | ||
"github.com/ipld/go-ipld-prime/multicodec" | ||
mc "github.com/multiformats/go-multicodec" | ||
) | ||
|
||
// Plugins is exported list of plugins that will be loaded | ||
var Plugins = []plugin.Plugin{ | ||
&dagjosePlugin{}, | ||
} | ||
|
||
type dagjosePlugin struct{} | ||
|
||
var _ plugin.PluginIPLD = (*dagjosePlugin)(nil) | ||
|
||
func (*dagjosePlugin) Name() string { | ||
return "ipld-codec-dagjose" | ||
} | ||
|
||
func (*dagjosePlugin) Version() string { | ||
return "0.0.1" | ||
} | ||
|
||
func (*dagjosePlugin) Init(_ *plugin.Environment) error { | ||
return nil | ||
} | ||
|
||
func (*dagjosePlugin) Register(reg multicodec.Registry) error { | ||
reg.RegisterEncoder(uint64(mc.DagJose), dagjose.Encode) | ||
reg.RegisterDecoder(uint64(mc.DagJose), dagjose.Decode) | ||
return nil | ||
} |
1 change: 1 addition & 0 deletions
1
...plugin-dag-jose-data/dag-cbor/bafyreicxyzuqbx5yb7ytkgkuofwksbal3ygtswxuri25crxdxms55m5fki
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
�bivpPSWIuAyO8CpevzCLctagvWZAMBblhzDCsQWOAKdlkSAiprotectedx'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4R0NNIn0jciphertextx 3XqLW28NHP-raqW8vMfIHOzko4N3IRaR |
Binary file added
BIN
+247 Bytes
...plugin-dag-jose-data/dag-cbor/bafyreihdfxoshbhowufyvjk7kq46dt6h7u6byejmlnifz34z7ocoq7ugk4
Binary file not shown.
1 change: 1 addition & 0 deletions
1
...plugin-dag-jose-data/dag-cbor/bafyreihkt4u6euddfhofkutfzxwet7w7zm5qrjpop655yhnb5dnzqw26lm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
�bivpQ8xpPt_zZrfvHgR-ctagvjxHjcVusu0yrOBzw-Ex5zAiprotectedx3eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0jciphertextx WTaw6WeqhaZDDhedzGYnsty4SMR-RzOwjrecipients��mencrypted_keyyVEqYaN4dFEH0vX4jU3d768hwOYSgZhElvVDzqdIKA6PFHsL4PPwJ7EIuebLrxwABJqXWBNG0kUBRjHuCv51VlxvX9WoH9ik7Qew0yROCGBj_AJef15PiZzUVUQwteHVDuSQs4OcsMfj18zc_ObskHvUMaN0PdCBA-G__7rGR2tcYSJOywbvxqqTENsCZNvasKxHSOuA_bjVsRmWloUMwLJkrbQxPAsVcwoPjAYF2agQ8D40AGFVEzGmhQDLI-OpXI-AfZYBurE7f_fU_NsYtqmFj5vZ9lvVCV1QsZa_HRhQlBBHxjTKyCBufY-0G4omt2nzYhyO-TaH44eUh81HFzww |
Binary file added
BIN
+267 Bytes
...ugin-dag-jose-data/dag-jose/bagcqcera542h3xc57nudkgjcceexyzyxrkwi4ikbn773ag6dqdcyjt6z6rga
Binary file not shown.
Binary file added
BIN
+562 Bytes
...ugin-dag-jose-data/dag-jose/bagcqcera5uvz2qai6l4vmqjigwpowluilxngz3dyjnva2s3uwbfb5u4ao4fa
Binary file not shown.
Binary file added
BIN
+350 Bytes
...ugin-dag-jose-data/dag-jose/bagcqcera7azagcqlpu4ivvh4xp4iv6psmb5d7eki6ln3fnfnsnbb2hzv4nxq
Binary file not shown.
1 change: 1 addition & 0 deletions
1
...ugin-dag-jose-data/dag-jose/bagcqcerakjv2mmdlbai3urym22bw5kaw7nqov73yaxf6xjnp7e56sclsrooa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
�bivX��;�J:�k5� Y���i�3��J�*�ctagP�2B]��A�k��<iprotectedX{"alg":"dir","enc":"XC20P"}jciphertextX$4*� �.�j�a�F���V��tb������9�ϐ� |
Binary file added
BIN
+411 Bytes
...ugin-dag-jose-data/dag-jose/bagcqceraqfknq7xaemcihmq2albau32ttrutxnco7xeoik6mlejismmvw5zq
Binary file not shown.
Binary file added
BIN
+163 Bytes
...ugin-dag-jose-data/dag-jose/bagcqcerauben4l6ee2wjf2fnkj7vaels4p7lnytenk35j3gl2lzcbtbgyoea
Binary file not shown.
1 change: 1 addition & 0 deletions
1
...ugin-dag-jose-data/dag-jose/bagcqceravvw4bx7jgkxxjwfuqo2yoja6w4cmvmu3gkew3s7yu3vt2ce7riwa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
�gpayloadX$p z�<�eD�*ok�9oi��|,�4���c1 +�jsignatures��iprotectedP{"alg":"ES256K"}isignatureX@C��LN@����KN�]S)��yR��}J-�"��1����C�$�J�$S����c�˃a��'���j^ |
1 change: 1 addition & 0 deletions
1
...ugin-dag-jose-data/dag-jose/bagcqceraxazmu67crshzqdeg3kwnfschs25epy5sbtqtjre2qw3d62kzplva
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
�bivL=%����*^�0�ctagPY��a�0�Ac�)�dHiprotectedX{"alg":"dir","enc":"A128GCM"}jciphertextX�z�[o��j������䣃w!� | ||
|
2 changes: 2 additions & 0 deletions
2
...ugin-dag-jose-data/dag-jose/bagcqceraxvt5izt4sz7kjfrm42dxrutp6ijywgsacllkznzekmfojypkvfea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
�gpayloadX$q �UeQÒfy�R�.*VjG'@��:&�Z�'��jsignatures��iprotectedO{"alg":"EdDSA"}isignatureX@��I��\��U�`#SI74����V�iݹ�P⇾7�� | ||
^{�9�H�fԽ[��醔疍U� |
1 change: 1 addition & 0 deletions
1
...ugin-dag-jose-data/dag-json/baguqeeraloya3qpa25kl5l4y3bzgl7rhyta2p7lwaocyxx4vpvdligb7mt2q
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"ciphertext":"WTaw6WeqhaZDDhedzGYnsty4SMR-RzOw","iv":"Q8xpPt_zZrfvHgR-","protected":"eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0","recipients":[{"encrypted_key":"EqYaN4dFEH0vX4jU3d768hwOYSgZhElvVDzqdIKA6PFHsL4PPwJ7EIuebLrxwABJqXWBNG0kUBRjHuCv51VlxvX9WoH9ik7Qew0yROCGBj_AJef15PiZzUVUQwteHVDuSQs4OcsMfj18zc_ObskHvUMaN0PdCBA-G__7rGR2tcYSJOywbvxqqTENsCZNvasKxHSOuA_bjVsRmWloUMwLJkrbQxPAsVcwoPjAYF2agQ8D40AGFVEzGmhQDLI-OpXI-AfZYBurE7f_fU_NsYtqmFj5vZ9lvVCV1QsZa_HRhQlBBHxjTKyCBufY-0G4omt2nzYhyO-TaH44eUh81HFzww"}],"tag":"jxHjcVusu0yrOBzw-Ex5zA"} |
1 change: 1 addition & 0 deletions
1
...ugin-dag-jose-data/dag-json/baguqeeraovfm3rr3pvmxm27zgvxp5wycbfih35xih2uznminpnds5esm4jlq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"ciphertext":"3XqLW28NHP-raqW8vMfIHOzko4N3IRaR","iv":"PSWIuAyO8CpevzCL","protected":"eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4R0NNIn0","tag":"WZAMBblhzDCsQWOAKdlkSA"} |
1 change: 1 addition & 0 deletions
1
...ugin-dag-jose-data/dag-json/baguqeeravexfd6qijjtnzxfqq6kgknnkncztgmvhjhxm6ih352qskolt2gxa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"link":{"/":"bafyreiejkvsvdq4smz44yuwhfymcuvqzavveoj2at3utujwqlllspsqr6q"},"payload":"AXESIIlVZVHDkmZ5zFLHLhgqVhkFakcnQJ7pOibQWtcnyhH0","signatures":[{"protected":"eyJhbGciOiJFZERTQSJ9","signature":"-_9J5OZcl5lVuRlgI1NJEzc0FqEb6_2yVskUaQPducRQ4oe-N5ynCl57wDm4SPtm1L1bltrphpQeBOeWjVW1BQ"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright (c) 2021 Mohsin Zaidi | ||
# MIT Licensed; see the LICENSE file in this repository. | ||
# | ||
|
||
test_description="Test dag-jose plugin" | ||
|
||
. lib/test-lib.sh | ||
|
||
test_init_ipfs | ||
|
||
test_dag_jose() { | ||
test_expect_success "encode as dag-jose, decode back to original, verify round-trip" $' | ||
find ../t0280-plugin-dag-jose-data -type f | xargs -I {} sh -c \' \ | ||
codec=$(basename $(dirname {})); \ | ||
joseHash=$(ipfs dag put --store-codec dag-jose --input-codec=$codec {}); \ | ||
ipfs dag get --output-codec $codec $joseHash > $(basename {}); \ | ||
diff {} $(basename {}) \' | ||
' | ||
|
||
test_expect_success "retrieve dag-jose in non-dag-jose encodings" $' | ||
find ../t0280-plugin-dag-jose-data -type f | xargs -I {} sh -c \' \ | ||
codec=$(basename $(dirname {})); \ | ||
joseHash=$(ipfs dag put --store-codec dag-jose --input-codec=$codec {}); \ | ||
ipfs dag get --output-codec dag-cbor $joseHash > /dev/null; \ | ||
ipfs dag get --output-codec dag-json $joseHash > /dev/null \' | ||
' | ||
} | ||
|
||
# should work offline | ||
test_dag_jose | ||
|
||
# should work online | ||
test_launch_ipfs_daemon | ||
test_dag_jose | ||
test_kill_ipfs_daemon | ||
|
||
test_done |