├── .gitignore ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── cmd └── blockchain │ └── main.go ├── configs ├── blockchain_master.hcl └── blockchain_user.hcl ├── go.mod ├── go.sum ├── images ├── workflow_01.png ├── workflow_02.png └── workflow_03.png ├── internal ├── backend │ ├── backend.go │ └── factory.go ├── model │ ├── account.go │ └── field_data_wrapper.go └── path │ ├── base.go │ ├── config.go │ ├── create_account.go │ ├── decrypt.go │ ├── encrypt.go │ ├── factory.go │ ├── sign.go │ ├── sign_besu_private_transaction.go │ └── sign_transaction.go ├── pkg └── utils │ └── utils.go └── scripts └── setup_plugin_local.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | plugins 8 | 9 | # Test binary, built with `go test -c` 10 | *.test 11 | 12 | # Output of the go coverage tool, specifically when used with LiteIDE 13 | *.out 14 | 15 | # Dependency directories (remove the comment below to include it) 16 | # vendor/ 17 | 18 | # macOS 19 | .DS_Store 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2020 Bsos Tech Co., Ltd. 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build-local 2 | .PHONY: lint install-lint-tools 3 | .PHONY: run-local setup-plugin-local 4 | 5 | ROOT_TOKEN ?= root 6 | VAULT_ADDR ?= http://localhost:8200 7 | 8 | build-local: 9 | CGO_ENABLED=1 go build \ 10 | -ldflags="-s -w" \ 11 | -o plugins/vault-blockchain cmd/blockchain/main.go 12 | 13 | install-lint-tools: 14 | GO111MODULE=off go get -u -d golang.org/x/lint/golint 15 | GO111MODULE=off go install golang.org/x/lint/golint 16 | curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.23.7 17 | 18 | lint: 19 | golint -set_exit_status ./... 20 | golangci-lint run ./... 21 | 22 | run-local: 23 | vault server -dev -dev-root-token-id=${ROOT_TOKEN} -dev-plugin-dir=./plugins 24 | 25 | setup-plugin-local: 26 | ROOT_TOKEN=${ROOT_TOKEN} VAULT_ADDR=${VAULT_ADDR} bash scripts/setup_plugin_local.sh 27 | 28 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Vault-BridgeX 2 | Copyright 2020 Bsos Tech Co., Ltd. 3 | 4 | This product includes software developed at 5 | Immutability, LLC (https://immutability.io). 6 | Licensed under the Apache License 2.0. 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vault-blockchain 2 | 3 | vault-blockchain is a vault plugin to generate and store Ethereum private keys. We can use it to sign transaction in Vault without revealing private keys. 4 | 5 | ## Workflow 6 | 7 | ![1. Register](/images/workflow_01.png) 8 | ![2. Login](/images/workflow_02.png) 9 | ![3. Sign Transaction](/images/workflow_03.png) 10 | 11 | ## HCL Policies 12 | 13 | There are two types of token in Vault-BX. One is master token. Another is user token. We use master token to register user accounts, but not retrieve any credentials in user account. Master token is only used for registration. 14 | 15 | ```hcl 16 | # bx_master.hcl 17 | path "auth/userpass/users/*" { 18 | capabilities = [ "create" ] 19 | } 20 | 21 | path "identity/entity-alias" { 22 | capabilities = [ "read", "update" ] 23 | } 24 | 25 | path "identity/entity" { 26 | capabilities = [ "read", "update" ] 27 | } 28 | 29 | path "blockchain/accounts/+/address" { 30 | capabilities = [ "create" ] 31 | } 32 | ``` 33 | 34 | Each of user token is corresponding to identity, so it can only operate private key under that identity. 35 | 36 | ```hcl 37 | # bx_user.hcl 38 | path "blockchain/accounts/{{identity.entity.name}}/*" { 39 | capabilities = [ "create" ] 40 | } 41 | ``` 42 | 43 | ## API 44 | 45 | ### Create account 46 | 47 | | Method | Path | 48 | | ------ | --------------------------- | 49 | | `POST` | `blockchain/accounts/:name/address` | 50 | 51 | #### Parameters 52 | 53 | * `name` `(string: )` - Name of user. You can also use UUID of user in your system. 54 | 55 | ### Sign transaction 56 | 57 | | Method | Path | 58 | | ------ | --------------------------- | 59 | | `POST` | `blockchain/accounts/:name/sign-tx` | 60 | 61 | #### Parameters 62 | 63 | * `name` `(string: )` - Name of user. You can also use UUID of user in your system. 64 | * `address_to` `(string: )` - A Hex string specifying the Ethereum address to send the transaction to. 65 | * `chainID` `(string: )` - The chain ID of the blockchain network. 66 | * `amount` `(string: )` - Amount of ETH (in wei). 67 | * `gas_price` `(string: )` - The gas price for the transaction in wei. 68 | * `gas_limit` `(string: )` - The gas limit for the transaction. 69 | * `nonce` `(string: )` - The transaction nonce. 70 | * `data` `(string: )` - The data to sign. 71 | * `is_private` `(bool: )` - Private transaction or not. 72 | 73 | ### Sign Besu Private Transaction 74 | 75 | | Method | Path | 76 | | ------ | ---------------------------------------- | 77 | | `POST` | `blockchain/accounts/:name/sign-besu-private-tx` | 78 | 79 | #### Parameters 80 | 81 | * `name` `(string: )` - Name of user. You can also use UUID of user in your system. 82 | * `address_to` `(string: )` - A Hex string specifying the Ethereum address to send the transaction to. 83 | * `chainID` `(string: )` - The chain ID of the blockchain network. 84 | * `amount` `(string: )` - Amount of ETH (in wei). 85 | * `gas_price` `(string: )` - The gas price for the transaction in wei. 86 | * `gas_limit` `(string: )` - The gas limit for the transaction. 87 | * `private_nonce` `(string: )` - The besu private transaction nonce. 88 | * `data` `(string: )` - The data to sign. 89 | * `is_private` `(bool: )` - Private transaction or not. 90 | * `private_from` `(string: )` - The Orion public key of the transaction sender. 91 | * `private_for` `(string: )` - The Orion public keys of the transaction recipients. 92 | 93 | ### Sign data 94 | 95 | | Method | Path | 96 | | ------ | ------------------------ | 97 | | `POST` | `blockchain/accounts/:name/sign` | 98 | 99 | #### Parameters 100 | 101 | * `name` `(string: )` - Name of user. You can also use UUID of user in your system. 102 | * `data` `(string: )` - The data to hash (keccak) and sign. 103 | 104 | ### Encrypt data 105 | 106 | | Method | Path | 107 | | ------ | --------------------------- | 108 | | `POST` | `blockchain/accounts/:name/encrypt` | 109 | 110 | #### Parameters 111 | 112 | * `name` `(string: )` - Name of user. You can also use UUID of user in your system. 113 | * `data` `(string: )` - The data to encrypt. 114 | 115 | ### Decrypt data 116 | 117 | | Method | Path | 118 | | ------ | --------------------------- | 119 | | `POST` | `blockchain/accounts/:name/decrypt` | 120 | 121 | #### Parameters 122 | 123 | * `name` `(string: )` - Name of user. You can also use UUID of user in your system. 124 | * `data` `(string: )` - The data to decrypt. 125 | 126 | -------------------------------------------------------------------------------- /cmd/blockchain/main.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package main 19 | 20 | import ( 21 | "log" 22 | "os" 23 | 24 | "github.com/hashicorp/vault/api" 25 | "github.com/hashicorp/vault/sdk/plugin" 26 | 27 | "github.com/bsostech/vault-blockchain/internal/backend" 28 | ) 29 | 30 | func main() { 31 | apiClientMeta := &api.PluginAPIClientMeta{} 32 | flags := apiClientMeta.FlagSet() 33 | err := flags.Parse(os.Args[1:]) // Ignore command, strictly parse flags 34 | if err != nil { 35 | log.Println(err) 36 | os.Exit(1) 37 | } 38 | 39 | tlsConfig := apiClientMeta.GetTLSConfig() 40 | tlsProviderFunc := api.VaultPluginTLSProvider(tlsConfig) 41 | 42 | err = plugin.Serve(&plugin.ServeOpts{ 43 | BackendFactoryFunc: backend.Factory, 44 | TLSProviderFunc: tlsProviderFunc, 45 | }) 46 | if err != nil { 47 | log.Println(err) 48 | os.Exit(1) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /configs/blockchain_master.hcl: -------------------------------------------------------------------------------- 1 | path "auth/userpass/users/*" { 2 | capabilities = [ "create" ] 3 | } 4 | 5 | path "identity/entity-alias" { 6 | capabilities = [ "read", "update" ] 7 | } 8 | 9 | path "identity/entity" { 10 | capabilities = [ "read", "update" ] 11 | } 12 | 13 | path "blockchain/accounts/+/address" { 14 | capabilities = [ "create" ] 15 | } 16 | 17 | -------------------------------------------------------------------------------- /configs/blockchain_user.hcl: -------------------------------------------------------------------------------- 1 | path "blockchain/accounts/{{identity.entity.name}}/*" { 2 | capabilities = [ "create" ] 3 | } 4 | 5 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bsostech/vault-blockchain 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/bsostech/go-besu v0.1.0 7 | github.com/ethereum/go-ethereum v1.9.13 8 | github.com/hashicorp/vault/api v1.0.4 9 | github.com/hashicorp/vault/sdk v0.1.13 10 | golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 11 | ) 12 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= 3 | github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= 4 | github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4= 5 | github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= 6 | github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= 7 | github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= 8 | github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= 9 | github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= 10 | github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= 11 | github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= 12 | github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= 13 | github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= 14 | github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= 15 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 16 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 17 | github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= 18 | github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= 19 | github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= 20 | github.com/VictoriaMetrics/fastcache v1.5.3 h1:2odJnXLbFZcoV9KYtQ+7TH1UOq3dn3AssMgieaezkR4= 21 | github.com/VictoriaMetrics/fastcache v1.5.3/go.mod h1:+jv9Ckb+za/P1ZRg/sulP5Ni1v49daAVERr0H3CuscE= 22 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 23 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 24 | github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= 25 | github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= 26 | github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847 h1:rtI0fD4oG/8eVokGVPYJEW1F88p1ZNgXiEIs9thEE4A= 27 | github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= 28 | github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= 29 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to= 30 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= 31 | github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= 32 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 33 | github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= 34 | github.com/bsostech/go-besu v0.1.0 h1:lVwjDMNH2zTIxZNd48kfxOCnD27Hacmiiu5qZ7D/WDM= 35 | github.com/bsostech/go-besu v0.1.0/go.mod h1:fAtsiMZii5e2Bcfi3c5epjr/foa3azJPzLWxQC43ucM= 36 | github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6 h1:Eey/GGQ/E5Xp1P2Lyx1qj007hLZfbi0+CoVeJruGCtI= 37 | github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= 38 | github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= 39 | github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= 40 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 41 | github.com/cespare/xxhash/v2 v2.0.1-0.20190104013014-3767db7a7e18/go.mod h1:HD5P3vAIAh+Y2GAxg0PrPN1P8WkepXGpjbUPDHJqqKM= 42 | github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= 43 | github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 44 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 45 | github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= 46 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 47 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 48 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 49 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 50 | github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea h1:j4317fAZh7X6GqbFowYdYdI0L9bwxL07jyPZIdepyZ0= 51 | github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= 52 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 53 | github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= 54 | github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= 55 | github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= 56 | github.com/dop251/goja v0.0.0-20200219165308-d1232e640a87/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= 57 | github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= 58 | github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa h1:XKAhUk/dtp+CV0VO6mhG2V7jA9vbcGcnYF/Ay9NjZrY= 59 | github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa/go.mod h1:cdorVVzy1fhmEqmtgqkoE3bYtCfSCkVyjTyCIo22xvs= 60 | github.com/ethereum/go-ethereum v1.9.13 h1:rOPqjSngvs1VSYH2H+PMPiWt4VEulvNRbFgqiGqJM3E= 61 | github.com/ethereum/go-ethereum v1.9.13/go.mod h1:qwN9d1GLyDh0N7Ab8bMGd0H9knaji2jOBm2RrMGjXls= 62 | github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= 63 | github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= 64 | github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= 65 | github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= 66 | github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= 67 | github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 68 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 69 | github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= 70 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 71 | github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= 72 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 73 | github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= 74 | github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= 75 | github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= 76 | github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= 77 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 78 | github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31 h1:28FVBuwkwowZMjbA7M0wXsI6t3PYulRTMio3SO+eKCM= 79 | github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= 80 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 81 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= 82 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 83 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 84 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 85 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 86 | github.com/golang/protobuf v1.3.2-0.20190517061210-b285ee9cfc6c h1:zqAKixg3cTcIasAMJV+EcfVbWwLpOZ7LeoWJvcuD/5Q= 87 | github.com/golang/protobuf v1.3.2-0.20190517061210-b285ee9cfc6c/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 88 | github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= 89 | github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 90 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 91 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 92 | github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989 h1:giknQ4mEuDFmmHSrGcbargOuLHQGtywqo4mheITex54= 93 | github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 94 | github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= 95 | github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= 96 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 97 | github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= 98 | github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= 99 | github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= 100 | github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= 101 | github.com/hashicorp/go-hclog v0.8.0 h1:z3ollgGRg8RjfJH6UVBaG54R70GFd++QOkvnJH3VSBY= 102 | github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= 103 | github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= 104 | github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= 105 | github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= 106 | github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= 107 | github.com/hashicorp/go-plugin v1.0.1 h1:4OtAfUGbnKC6yS48p0CtMX2oFYtzFZVv6rok3cRWgnE= 108 | github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= 109 | github.com/hashicorp/go-retryablehttp v0.5.4 h1:1BZvpawXoJCWX6pNtow9+rpEj+3itIlutiqnntI6jOE= 110 | github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= 111 | github.com/hashicorp/go-rootcerts v1.0.1 h1:DMo4fmknnz0E0evoNYnV48RjWndOsmd6OW+09R3cEP8= 112 | github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= 113 | github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= 114 | github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= 115 | github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 116 | github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= 117 | github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 118 | github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= 119 | github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 120 | github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 121 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 122 | github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= 123 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 124 | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= 125 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 126 | github.com/hashicorp/vault/api v1.0.4 h1:j08Or/wryXT4AcHj1oCbMd7IijXcKzYUGw59LGu9onU= 127 | github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= 128 | github.com/hashicorp/vault/sdk v0.1.13 h1:mOEPeOhT7jl0J4AMl1E705+BcmeRs1VmKNb9F0sMLy8= 129 | github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= 130 | github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= 131 | github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= 132 | github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= 133 | github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= 134 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 135 | github.com/huin/goupnp v0.0.0-20161224104101-679507af18f3/go.mod h1:MZ2ZmwcBpvOoJ22IJsc7va19ZwoheaBk43rKg12SKag= 136 | github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= 137 | github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= 138 | github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= 139 | github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 140 | github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= 141 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 142 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 143 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 144 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 145 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 146 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 147 | github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= 148 | github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 149 | github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 150 | github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= 151 | github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= 152 | github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 153 | github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 154 | github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= 155 | github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= 156 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 157 | github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= 158 | github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= 159 | github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= 160 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 161 | github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= 162 | github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= 163 | github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= 164 | github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= 165 | github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= 166 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 167 | github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= 168 | github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= 169 | github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= 170 | github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= 171 | github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= 172 | github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= 173 | github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= 174 | github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= 175 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 176 | github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= 177 | github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 178 | github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= 179 | github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 180 | github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 181 | github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= 182 | github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= 183 | github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= 184 | github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= 185 | github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= 186 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 187 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 188 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 189 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 190 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 191 | github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= 192 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 193 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 194 | github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 195 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 196 | github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= 197 | github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= 198 | github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= 199 | github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= 200 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 201 | github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= 202 | github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= 203 | github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= 204 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 205 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 206 | github.com/spaolacci/murmur3 v1.0.1-0.20190317074736-539464a789e9/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 207 | github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= 208 | github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570 h1:gIlAHnH1vJb5vwEjIp5kBj/eu99p/bl0Ay2goiPe5xE= 209 | github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw= 210 | github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3 h1:njlZPzLwU639dk2kqnCPPv+wNjq7Xb6EfUxe/oX0/NM= 211 | github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= 212 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 213 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 214 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 215 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 216 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 217 | github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d h1:gZZadD8H+fF+n9CmNhYL1Y0dJB+kLOmKd7FbPJLeGHs= 218 | github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= 219 | github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= 220 | github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= 221 | github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= 222 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 223 | golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 224 | golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 h1:cg5LA/zNPRzIXIWSCxQW10Rvpy94aQh3LT/ShoCpkHw= 225 | golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 226 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 227 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 228 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 229 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 230 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 231 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 232 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 233 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 234 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 235 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 236 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 237 | golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0= 238 | golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 239 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 240 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 241 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 242 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 243 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 244 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 245 | golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 246 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 247 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 248 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 249 | golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 250 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 251 | golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 252 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 253 | golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So= 254 | golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 255 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 256 | golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 257 | golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= 258 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 259 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= 260 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 261 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 262 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 263 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 264 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 265 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 266 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 267 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 268 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 269 | google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107 h1:xtNn7qFlagY2mQNFHMSRPjT2RkOV4OXM7P5TVy9xATo= 270 | google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 271 | google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= 272 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 273 | google.golang.org/grpc v1.22.0 h1:J0UbZOIrCAl+fpTOf8YLs4dJo8L/owV4LYVtAXQoPkw= 274 | google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 275 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 276 | gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= 277 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 278 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 279 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 280 | gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= 281 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 282 | gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= 283 | gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= 284 | gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200316214253-d7b0ff38cac9/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= 285 | gopkg.in/square/go-jose.v2 v2.3.1 h1:SK5KegNXmKmqE342YYN2qPHEnUYeoMiXXl1poUlI+o4= 286 | gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= 287 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= 288 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 289 | gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= 290 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 291 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 292 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 293 | gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= 294 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 295 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 296 | -------------------------------------------------------------------------------- /images/workflow_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsostech/vault-blockchain/68ae80441b510a415c4263ab696611814fd14637/images/workflow_01.png -------------------------------------------------------------------------------- /images/workflow_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsostech/vault-blockchain/68ae80441b510a415c4263ab696611814fd14637/images/workflow_02.png -------------------------------------------------------------------------------- /images/workflow_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsostech/vault-blockchain/68ae80441b510a415c4263ab696611814fd14637/images/workflow_03.png -------------------------------------------------------------------------------- /internal/backend/backend.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package backend 19 | 20 | import ( 21 | "github.com/hashicorp/vault/sdk/framework" 22 | "github.com/hashicorp/vault/sdk/logical" 23 | 24 | "github.com/bsostech/vault-blockchain/internal/path" 25 | ) 26 | 27 | // backend for this plugin 28 | type ethereumBackend struct { 29 | *framework.Backend 30 | } 31 | 32 | // returns ethereumBackend 33 | func newBackend(conf *logical.BackendConfig) (*ethereumBackend, error) { 34 | var b ethereumBackend 35 | b.Backend = &framework.Backend{ 36 | Help: "", 37 | Paths: framework.PathAppend( 38 | path.GetPaths(), 39 | ), 40 | PathsSpecial: &logical.Paths{ 41 | SealWrapStorage: []string{ 42 | "accounts/", 43 | }, 44 | }, 45 | Secrets: []*framework.Secret{}, 46 | BackendType: logical.TypeLogical, 47 | } 48 | return &b, nil 49 | } 50 | -------------------------------------------------------------------------------- /internal/backend/factory.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package backend 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/hashicorp/vault/sdk/logical" 24 | ) 25 | 26 | // Factory returns the backend 27 | func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) { 28 | b, err := newBackend(conf) 29 | if err != nil { 30 | return nil, err 31 | } 32 | if err := b.Setup(ctx, conf); err != nil { 33 | return nil, err 34 | } 35 | return b, nil 36 | } 37 | -------------------------------------------------------------------------------- /internal/model/account.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package model 19 | 20 | import ( 21 | "crypto/ecdsa" 22 | "fmt" 23 | 24 | "github.com/ethereum/go-ethereum/crypto" 25 | "github.com/ethereum/go-ethereum/crypto/ecies" 26 | 27 | "github.com/bsostech/vault-blockchain/pkg/utils" 28 | ) 29 | 30 | // Account is an Ethereum account 31 | type Account struct { 32 | AddressStr string `json:"address"` // Ethereum account address derived from the private key 33 | PrivateKeyStr string `json:"private_key"` 34 | PublicKeyStr string `json:"public_key"` // Ethereum public key derived from the private key 35 | } 36 | 37 | // NewAccount returns Account 38 | func NewAccount(addressStr string, privateKeyStr string, publicKeyStr string) *Account { 39 | return &Account{ 40 | AddressStr: addressStr, 41 | PrivateKeyStr: privateKeyStr, 42 | PublicKeyStr: publicKeyStr, 43 | } 44 | } 45 | 46 | // GetPrivateKeyECDSA key for signing data 47 | func (a *Account) GetPrivateKeyECDSA() (*ecdsa.PrivateKey, error) { 48 | // Get private key from account 49 | return crypto.HexToECDSA(a.PrivateKeyStr) 50 | } 51 | 52 | // GetPublicKeyECDSA key for validating signature 53 | func (a *Account) GetPublicKeyECDSA() (*ecdsa.PublicKey, error) { 54 | privateKeyECDSA, err := a.GetPrivateKeyECDSA() 55 | if err != nil { 56 | return nil, err 57 | } 58 | defer utils.ZeroKey(privateKeyECDSA) 59 | publicKey := privateKeyECDSA.Public() 60 | publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) 61 | if !ok { 62 | return nil, fmt.Errorf("error casting public key to ECDSA") 63 | } 64 | return publicKeyECDSA, nil 65 | } 66 | 67 | // GetPrivateKeyECIES key for encrypting data 68 | func (a *Account) GetPrivateKeyECIES() (*ecies.PrivateKey, error) { 69 | privateKeyECDSA, err := a.GetPrivateKeyECDSA() 70 | if err != nil { 71 | return nil, err 72 | } 73 | privateKeyECIES := ecies.ImportECDSA(privateKeyECDSA) 74 | return privateKeyECIES, nil 75 | } 76 | 77 | // GetPublicKeyECIES key for decrypting data 78 | func (a *Account) GetPublicKeyECIES() (*ecies.PublicKey, error) { 79 | publicKeyECDSA, err := a.GetPublicKeyECDSA() 80 | if err != nil { 81 | return nil, err 82 | } 83 | publicKeyECIES := ecies.ImportECDSAPublic(publicKeyECDSA) 84 | return publicKeyECIES, nil 85 | } 86 | -------------------------------------------------------------------------------- /internal/model/field_data_wrapper.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package model 19 | 20 | import ( 21 | "fmt" 22 | "math/big" 23 | 24 | "github.com/hashicorp/vault/sdk/framework" 25 | 26 | "github.com/bsostech/vault-blockchain/pkg/utils" 27 | ) 28 | 29 | // FieldDataWrapper used to processing data from framework.FieldData 30 | type FieldDataWrapper struct { 31 | *framework.FieldData 32 | } 33 | 34 | // NewFieldDataWrapper returns FieldDataWrapper 35 | func NewFieldDataWrapper(data *framework.FieldData) *FieldDataWrapper { 36 | return &FieldDataWrapper{ 37 | FieldData: data, 38 | } 39 | } 40 | 41 | // GetString get string value from framework.FieldData with specific key, 42 | // returns defaultValue when the key doesn't exist or the value of the key is not type of string. 43 | func (f *FieldDataWrapper) GetString(key string, defaultValue string) string { 44 | valueInterface := f.Get(key) 45 | if valueInterface == nil { 46 | return defaultValue 47 | } 48 | value, ok := valueInterface.(string) 49 | if !ok { 50 | return defaultValue 51 | } 52 | return value 53 | } 54 | 55 | // MustGetString get string value from framework.FieldData with specific key, 56 | // returns error when the key doesn't exist or the value of the key is not type of string. 57 | func (f *FieldDataWrapper) MustGetString(key string) (string, error) { 58 | valueInterface := f.Get(key) 59 | if valueInterface == nil { 60 | return "", f.errorResolve(key) 61 | } 62 | value, ok := valueInterface.(string) 63 | if !ok { 64 | return "", f.errorTypeMismatch(key) 65 | } 66 | return value, nil 67 | } 68 | 69 | // GetStringSlice get string slice value from framework.FieldData with specific key, 70 | // returns defaultValue when the key doesn't exist or the value of the key is not type of string slice. 71 | func (f *FieldDataWrapper) GetStringSlice(key string, defaultValue []string) []string { 72 | valueInterface := f.Get(key) 73 | if valueInterface == nil { 74 | return defaultValue 75 | } 76 | interfaceArray, ok := valueInterface.([]interface{}) 77 | if !ok { 78 | return defaultValue 79 | } 80 | var value []string 81 | for _, strInterface := range interfaceArray { 82 | str, ok := strInterface.(string) 83 | if !ok { 84 | return defaultValue 85 | } 86 | value = append(value, str) 87 | } 88 | return value 89 | } 90 | 91 | // MustGetStringSlice get string slice value from framework.FieldData with specific key, 92 | // returns error when the key doesn't exist or the value of the key is not type of string slice. 93 | func (f *FieldDataWrapper) MustGetStringSlice(key string) ([]string, error) { 94 | valueInterface := f.Get(key) 95 | if valueInterface == nil { 96 | return nil, f.errorResolve(key) 97 | } 98 | interfaceArray, ok := valueInterface.([]interface{}) 99 | if !ok { 100 | return nil, f.errorTypeMismatch(key) 101 | } 102 | var value []string 103 | for _, strInterface := range interfaceArray { 104 | str, ok := strInterface.(string) 105 | if !ok { 106 | return nil, f.errorTypeMismatch(key) 107 | } 108 | value = append(value, str) 109 | } 110 | return value, nil 111 | } 112 | 113 | // GetBool get bool value from framework.FieldData with specific key, 114 | // returns defaultValue when the key doesn't exist or the value of the key is not type of bool. 115 | func (f *FieldDataWrapper) GetBool(key string, defaultValue bool) bool { 116 | valueInterface := f.Get(key) 117 | if valueInterface == nil { 118 | return defaultValue 119 | } 120 | value, ok := valueInterface.(bool) 121 | if !ok { 122 | return defaultValue 123 | } 124 | return value 125 | } 126 | 127 | // MustGetBool get bool value from framework.FieldData with specific key, 128 | // returns error when the key doesn't exist or the value of the key is not type of bool. 129 | func (f *FieldDataWrapper) MustGetBool(key string) (bool, error) { 130 | valueInterface := f.Get(key) 131 | if valueInterface == nil { 132 | return false, f.errorResolve(key) 133 | } 134 | value, ok := valueInterface.(bool) 135 | if !ok { 136 | return false, f.errorTypeMismatch(key) 137 | } 138 | return value, nil 139 | } 140 | 141 | // GetBigInt get big.Int value from framework.FieldData with specific key, 142 | // returns defaultValue when the key doesn't exist or the value of the key is not type of big.Int. 143 | func (f *FieldDataWrapper) GetBigInt(key string, defaultValue *big.Int) *big.Int { 144 | valueInterface := f.Get(key) 145 | if valueInterface == nil { 146 | return defaultValue 147 | } 148 | value, ok := valueInterface.(string) 149 | if !ok { 150 | return defaultValue 151 | } 152 | return utils.ValidNumber(value) 153 | } 154 | 155 | // MustGetBigInt get big.Int value from framework.FieldData with specific key, 156 | // returns error when the key doesn't exist or the value of the key is not type of big.Int. 157 | func (f *FieldDataWrapper) MustGetBigInt(key string) (*big.Int, error) { 158 | valueInterface := f.Get(key) 159 | if valueInterface == nil { 160 | return nil, f.errorResolve(key) 161 | } 162 | value, ok := valueInterface.(string) 163 | if !ok { 164 | return nil, f.errorTypeMismatch(key) 165 | } 166 | return utils.ValidNumber(value), nil 167 | } 168 | 169 | // GetUint64 get unit64 value from framework.FieldData with specific key, 170 | // returns defaultValue when the key doesn't exist or the value of the key is not type of unit64. 171 | func (f *FieldDataWrapper) GetUint64(key string, defaultValue uint64) uint64 { 172 | bigInt, err := f.MustGetBigInt(key) 173 | if err != nil { 174 | return defaultValue 175 | } 176 | return bigInt.Uint64() 177 | } 178 | 179 | // MustGetUint64 get unit64 value from framework.FieldData with specific key, 180 | // returns error when the key doesn't exist or the value of the key is not type of unit64. 181 | func (f *FieldDataWrapper) MustGetUint64(key string) (uint64, error) { 182 | bigInt, err := f.MustGetBigInt(key) 183 | if err != nil { 184 | return 0, err 185 | } 186 | return bigInt.Uint64(), nil 187 | } 188 | 189 | func (f *FieldDataWrapper) errorResolve(key string) error { 190 | return fmt.Errorf("failed to resolve value with key %v", key) 191 | } 192 | 193 | func (f *FieldDataWrapper) errorTypeMismatch(key string) error { 194 | return fmt.Errorf("failed to resolve value with key %v, type mismatch", key) 195 | } 196 | -------------------------------------------------------------------------------- /internal/path/base.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package path 19 | 20 | import ( 21 | "context" 22 | "fmt" 23 | 24 | "github.com/hashicorp/vault/sdk/framework" 25 | "github.com/hashicorp/vault/sdk/logical" 26 | 27 | "github.com/bsostech/vault-blockchain/internal/model" 28 | ) 29 | 30 | type basePathConfig struct { 31 | config 32 | } 33 | 34 | func (b basePathConfig) getExistenceFunc() framework.ExistenceFunc { 35 | return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (bool, error) { 36 | entry, err := req.Storage.Get(ctx, req.Path) 37 | if err != nil { 38 | return false, fmt.Errorf("existence check failed, %v", err) 39 | } 40 | return entry != nil, nil 41 | } 42 | } 43 | 44 | func (b *basePathConfig) readAccount(ctx context.Context, req *logical.Request, name string) (*model.Account, error) { 45 | path := fmt.Sprintf("accounts/%s/address", name) 46 | entry, err := req.Storage.Get(ctx, path) 47 | if err != nil { 48 | return nil, err 49 | } 50 | if entry == nil { 51 | return nil, fmt.Errorf("entry not existed at %v", path) 52 | } 53 | var account *model.Account 54 | err = entry.DecodeJSON(&account) 55 | if err != nil { 56 | return nil, fmt.Errorf("failed to deserialize account at %s", path) 57 | } 58 | if account == nil { 59 | return nil, fmt.Errorf("account not existed at %s", path) 60 | } 61 | return account, nil 62 | } 63 | -------------------------------------------------------------------------------- /internal/path/config.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package path 19 | 20 | import ( 21 | "github.com/hashicorp/vault/sdk/framework" 22 | "github.com/hashicorp/vault/sdk/logical" 23 | ) 24 | 25 | type config interface { 26 | getPattern() string 27 | getHelpSynopsis() string 28 | getFields() map[string]*framework.FieldSchema 29 | getExistenceFunc() framework.ExistenceFunc 30 | getCallbacks() map[logical.Operation]framework.OperationFunc 31 | } 32 | -------------------------------------------------------------------------------- /internal/path/create_account.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package path 19 | 20 | import ( 21 | "context" 22 | "crypto/ecdsa" 23 | "fmt" 24 | 25 | "github.com/ethereum/go-ethereum/common/hexutil" 26 | "github.com/ethereum/go-ethereum/crypto" 27 | "github.com/hashicorp/vault/sdk/framework" 28 | "github.com/hashicorp/vault/sdk/logical" 29 | "golang.org/x/crypto/sha3" 30 | 31 | "github.com/bsostech/vault-blockchain/internal/model" 32 | "github.com/bsostech/vault-blockchain/pkg/utils" 33 | ) 34 | 35 | type createAccountPathConfig struct { 36 | basePathConfig 37 | } 38 | 39 | func (c *createAccountPathConfig) getPattern() string { 40 | name := framework.GenericNameRegex("name") 41 | fmt.Println("name: ", name) 42 | return "accounts/" + name + "/address" 43 | } 44 | 45 | func (c *createAccountPathConfig) getHelpSynopsis() string { 46 | return "Create an Ethereum account using a generated passphrase" 47 | } 48 | 49 | func (c *createAccountPathConfig) getFields() map[string]*framework.FieldSchema { 50 | return map[string]*framework.FieldSchema{ 51 | "name": { 52 | Type: framework.TypeString, 53 | }, 54 | } 55 | } 56 | 57 | func (c *createAccountPathConfig) getCallbacks() map[logical.Operation]framework.OperationFunc { 58 | return map[logical.Operation]framework.OperationFunc{ 59 | logical.CreateOperation: c.createAccount, 60 | } 61 | } 62 | 63 | func (c *createAccountPathConfig) createAccount(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { 64 | // create private key 65 | privateKey, err := crypto.GenerateKey() 66 | if err != nil { 67 | return nil, err 68 | } 69 | defer utils.ZeroKey(privateKey) 70 | privateKeyBytes := crypto.FromECDSA(privateKey) 71 | privateKeyString := hexutil.Encode(privateKeyBytes)[2:] 72 | // create public key 73 | publicKey := privateKey.Public() 74 | publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) 75 | if !ok { 76 | return nil, fmt.Errorf("error casting public key to ECDSA") 77 | } 78 | publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA) 79 | publicKeyString := hexutil.Encode(publicKeyBytes)[4:] 80 | // create address 81 | hash := sha3.NewLegacyKeccak256() 82 | _, err = hash.Write(publicKeyBytes[1:]) 83 | if err != nil { 84 | return nil, err 85 | } 86 | address := hexutil.Encode(hash.Sum(nil)[12:]) 87 | // store account info 88 | account := model.NewAccount(address, privateKeyString, publicKeyString) 89 | entry, err := logical.StorageEntryJSON(req.Path, account) 90 | if err != nil { 91 | return nil, err 92 | } 93 | err = req.Storage.Put(ctx, entry) 94 | if err != nil { 95 | return nil, err 96 | } 97 | return &logical.Response{ 98 | Data: map[string]interface{}{ 99 | "address": account.AddressStr, 100 | }, 101 | }, nil 102 | } 103 | -------------------------------------------------------------------------------- /internal/path/decrypt.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package path 19 | 20 | import ( 21 | "context" 22 | "fmt" 23 | 24 | "github.com/ethereum/go-ethereum/common/hexutil" 25 | "github.com/hashicorp/vault/sdk/framework" 26 | "github.com/hashicorp/vault/sdk/logical" 27 | 28 | "github.com/bsostech/vault-blockchain/internal/model" 29 | "github.com/bsostech/vault-blockchain/pkg/utils" 30 | ) 31 | 32 | type decryptPathConfig struct { 33 | basePathConfig 34 | } 35 | 36 | func (d *decryptPathConfig) getPattern() string { 37 | return "accounts/" + framework.GenericNameRegex("name") + "/decrypt" 38 | } 39 | 40 | func (d *decryptPathConfig) getHelpSynopsis() string { 41 | return "Decrypt data" 42 | } 43 | 44 | func (d *decryptPathConfig) getFields() map[string]*framework.FieldSchema { 45 | return map[string]*framework.FieldSchema{ 46 | "name": { 47 | Type: framework.TypeString, 48 | }, 49 | "data": { 50 | Type: framework.TypeString, 51 | Description: "The data to decrypt.", 52 | }, 53 | } 54 | } 55 | 56 | func (d *decryptPathConfig) getCallbacks() map[logical.Operation]framework.OperationFunc { 57 | return map[logical.Operation]framework.OperationFunc{ 58 | logical.CreateOperation: d.decrypt, 59 | } 60 | } 61 | 62 | func (d *decryptPathConfig) decrypt(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { 63 | dataWrapper := model.NewFieldDataWrapper(data) 64 | name, err := dataWrapper.MustGetString("name") 65 | if err != nil { 66 | return nil, err 67 | } 68 | account, err := d.readAccount(ctx, req, name) 69 | if err != nil { 70 | return nil, fmt.Errorf("error reading account, %v", err) 71 | } 72 | // get data to decrypt 73 | dataToDecrypt, err := dataWrapper.MustGetString("data") 74 | if err != nil { 75 | return nil, err 76 | } 77 | dataBytes, err := hexutil.Decode(dataToDecrypt) 78 | if err != nil { 79 | return nil, err 80 | } 81 | // get private ecies key for decrypting data 82 | privateKeyECIES, err := account.GetPrivateKeyECIES() 83 | if err != nil { 84 | return nil, fmt.Errorf("error reconstructing private key, %v", err) 85 | } 86 | defer utils.ZeroKey(privateKeyECIES.ExportECDSA()) 87 | // decrypt data 88 | plainText, err := privateKeyECIES.Decrypt(dataBytes, nil, nil) 89 | if err != nil { 90 | return nil, err 91 | } 92 | return &logical.Response{ 93 | Data: map[string]interface{}{ 94 | "plaintext": hexutil.Encode(plainText), 95 | }, 96 | }, nil 97 | } 98 | -------------------------------------------------------------------------------- /internal/path/encrypt.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package path 19 | 20 | import ( 21 | "context" 22 | "crypto/rand" 23 | "fmt" 24 | 25 | "github.com/ethereum/go-ethereum/common/hexutil" 26 | "github.com/ethereum/go-ethereum/crypto/ecies" 27 | "github.com/hashicorp/vault/sdk/framework" 28 | "github.com/hashicorp/vault/sdk/logical" 29 | 30 | "github.com/bsostech/vault-blockchain/internal/model" 31 | ) 32 | 33 | type encryptPathConfig struct { 34 | basePathConfig 35 | } 36 | 37 | func (e *encryptPathConfig) getPattern() string { 38 | return "accounts/" + framework.GenericNameRegex("name") + "/encrypt" 39 | } 40 | 41 | func (e *encryptPathConfig) getHelpSynopsis() string { 42 | return "Encrypt data" 43 | } 44 | 45 | func (e *encryptPathConfig) getFields() map[string]*framework.FieldSchema { 46 | return map[string]*framework.FieldSchema{ 47 | "name": { 48 | Type: framework.TypeString, 49 | }, 50 | "data": { 51 | Type: framework.TypeString, 52 | Description: "The data to encrypt.", 53 | }, 54 | } 55 | } 56 | 57 | func (e *encryptPathConfig) getCallbacks() map[logical.Operation]framework.OperationFunc { 58 | return map[logical.Operation]framework.OperationFunc{ 59 | logical.CreateOperation: e.encrypt, 60 | } 61 | } 62 | 63 | func (e *encryptPathConfig) encrypt(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { 64 | dataWrapper := model.NewFieldDataWrapper(data) 65 | name, err := dataWrapper.MustGetString("name") 66 | if err != nil { 67 | return nil, err 68 | } 69 | account, err := e.readAccount(ctx, req, name) 70 | if err != nil { 71 | return nil, fmt.Errorf("error reading account, %v", err) 72 | } 73 | // get data to encrypt 74 | dataToEncrypt, err := dataWrapper.MustGetString("data") 75 | if err != nil { 76 | return nil, err 77 | } 78 | dataBytes, err := hexutil.Decode(dataToEncrypt) 79 | if err != nil { 80 | return nil, err 81 | } 82 | // get ecies public key from account for encrypting data 83 | publicKeyECIES, err := account.GetPublicKeyECIES() 84 | if err != nil { 85 | return nil, err 86 | } 87 | // encrypt data 88 | cipherText, err := ecies.Encrypt(rand.Reader, publicKeyECIES, dataBytes, nil, nil) 89 | if err != nil { 90 | return nil, err 91 | } 92 | return &logical.Response{ 93 | Data: map[string]interface{}{ 94 | "ciphertext": hexutil.Encode(cipherText), 95 | }, 96 | }, nil 97 | } 98 | -------------------------------------------------------------------------------- /internal/path/factory.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package path 19 | 20 | import ( 21 | "github.com/hashicorp/vault/sdk/framework" 22 | ) 23 | 24 | // GetPaths return paths 25 | func GetPaths() []*framework.Path { 26 | return []*framework.Path{ 27 | getPath(&createAccountPathConfig{}), 28 | getPath(&signTransactionPathConfig{}), 29 | getPath(&signPathConfig{}), 30 | getPath(&signBesuPrivateTransactionPathConfig{}), 31 | getPath(&encryptPathConfig{}), 32 | getPath(&decryptPathConfig{}), 33 | } 34 | } 35 | 36 | func getPath(c config) *framework.Path { 37 | return &framework.Path{ 38 | Pattern: c.getPattern(), 39 | HelpSynopsis: c.getHelpSynopsis(), 40 | Fields: c.getFields(), 41 | ExistenceCheck: c.getExistenceFunc(), 42 | Callbacks: c.getCallbacks(), 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /internal/path/sign.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package path 19 | 20 | import ( 21 | "context" 22 | "fmt" 23 | 24 | "github.com/ethereum/go-ethereum/common/hexutil" 25 | "github.com/ethereum/go-ethereum/crypto" 26 | "github.com/hashicorp/vault/sdk/framework" 27 | "github.com/hashicorp/vault/sdk/logical" 28 | 29 | "github.com/bsostech/vault-blockchain/internal/model" 30 | "github.com/bsostech/vault-blockchain/pkg/utils" 31 | ) 32 | 33 | type signPathConfig struct { 34 | basePathConfig 35 | } 36 | 37 | func (s *signPathConfig) getPattern() string { 38 | return "accounts/" + framework.GenericNameRegex("name") + "/sign" 39 | } 40 | 41 | func (s *signPathConfig) getHelpSynopsis() string { 42 | return "Sign data" 43 | } 44 | 45 | func (s *signPathConfig) getFields() map[string]*framework.FieldSchema { 46 | return map[string]*framework.FieldSchema{ 47 | "name": { 48 | Type: framework.TypeString, 49 | }, 50 | "data": { 51 | Type: framework.TypeString, 52 | Description: "The data to hash (keccak) and sign.", 53 | }, 54 | } 55 | } 56 | 57 | func (s *signPathConfig) getCallbacks() map[logical.Operation]framework.OperationFunc { 58 | return map[logical.Operation]framework.OperationFunc{ 59 | logical.CreateOperation: s.sign, 60 | } 61 | } 62 | 63 | func (s *signPathConfig) sign(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { 64 | dataWrapper := model.NewFieldDataWrapper(data) 65 | name, err := dataWrapper.MustGetString("name") 66 | if err != nil { 67 | return nil, err 68 | } 69 | account, err := s.readAccount(ctx, req, name) 70 | if err != nil { 71 | return nil, fmt.Errorf("error reading account, %v", err) 72 | } 73 | // get data to sign 74 | dataToSign, err := dataWrapper.MustGetString("data") 75 | if err != nil { 76 | return nil, err 77 | } 78 | dataBytes, err := hexutil.Decode(dataToSign) 79 | if err != nil { 80 | return nil, err 81 | } 82 | hash := crypto.Keccak256Hash(dataBytes) 83 | // get private ecdsa key from account for signing data 84 | privateKey, err := account.GetPrivateKeyECDSA() 85 | if err != nil { 86 | return nil, fmt.Errorf("error reconstructing private key, %v", err) 87 | } 88 | defer utils.ZeroKey(privateKey) 89 | // sign data 90 | signature, err := crypto.Sign(hash.Bytes(), privateKey) 91 | if err != nil { 92 | return nil, err 93 | } 94 | return &logical.Response{ 95 | Data: map[string]interface{}{ 96 | "signature": hexutil.Encode(signature), 97 | "address": account.AddressStr, 98 | }, 99 | }, nil 100 | } 101 | -------------------------------------------------------------------------------- /internal/path/sign_besu_private_transaction.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package path 19 | 20 | import ( 21 | "context" 22 | "fmt" 23 | 24 | "github.com/bsostech/go-besu/privacy" 25 | "github.com/bsostech/go-besu/types" 26 | "github.com/ethereum/go-ethereum/common" 27 | "github.com/ethereum/go-ethereum/common/hexutil" 28 | "github.com/ethereum/go-ethereum/rlp" 29 | "github.com/hashicorp/vault/sdk/framework" 30 | "github.com/hashicorp/vault/sdk/logical" 31 | 32 | "github.com/bsostech/vault-blockchain/internal/model" 33 | "github.com/bsostech/vault-blockchain/pkg/utils" 34 | ) 35 | 36 | type signBesuPrivateTransactionPathConfig struct { 37 | basePathConfig 38 | } 39 | 40 | func (s *signBesuPrivateTransactionPathConfig) getPattern() string { 41 | return "accounts/" + framework.GenericNameRegex("name") + "/sign-besu-private-tx" 42 | } 43 | 44 | func (s *signBesuPrivateTransactionPathConfig) getHelpSynopsis() string { 45 | return "Sign a provided besu private transaction." 46 | } 47 | 48 | func (s *signBesuPrivateTransactionPathConfig) getFields() map[string]*framework.FieldSchema { 49 | return map[string]*framework.FieldSchema{ 50 | "name": { 51 | Type: framework.TypeString, 52 | }, 53 | "address_to": { 54 | Type: framework.TypeString, 55 | Description: "The address of the account to send tx to.", 56 | }, 57 | "chainID": { 58 | Type: framework.TypeString, 59 | Description: "The chain ID of the blockchain network.", 60 | }, 61 | "data": { 62 | Type: framework.TypeString, 63 | Description: "The data to sign.", 64 | }, 65 | "amount": { 66 | Type: framework.TypeString, 67 | Description: "Amount of ETH (in wei).", 68 | Default: "0", 69 | }, 70 | "private_nonce": { 71 | Type: framework.TypeString, 72 | Description: "The besu private transaction nonce.", 73 | }, 74 | "gas_limit": { 75 | Type: framework.TypeString, 76 | Description: "The gas limit for the transaction - defaults to 21000.", 77 | Default: "21000", 78 | }, 79 | "gas_price": { 80 | Type: framework.TypeString, 81 | Description: "The gas price for the transaction in wei.", 82 | Default: "0", 83 | }, 84 | "private_from": { 85 | Type: framework.TypeString, 86 | Description: "The privateFrom", 87 | }, 88 | "private_for": { 89 | Type: framework.TypeStringSlice, 90 | Description: "The privateFor", 91 | }, 92 | } 93 | } 94 | 95 | func (s *signBesuPrivateTransactionPathConfig) getCallbacks() map[logical.Operation]framework.OperationFunc { 96 | return map[logical.Operation]framework.OperationFunc{ 97 | logical.CreateOperation: s.signPrivateTransaction, 98 | } 99 | } 100 | 101 | func (s *signBesuPrivateTransactionPathConfig) signPrivateTransaction(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { 102 | dataWrapper := model.NewFieldDataWrapper(data) 103 | name, err := dataWrapper.MustGetString("name") 104 | if err != nil { 105 | return nil, err 106 | } 107 | account, err := s.readAccount(ctx, req, name) 108 | if err != nil { 109 | return nil, fmt.Errorf("error reading account, %v", err) 110 | } 111 | chainID, err := dataWrapper.MustGetBigInt("chainID") 112 | if err != nil { 113 | return nil, err 114 | } 115 | amount, err := dataWrapper.MustGetBigInt("amount") 116 | if err != nil { 117 | return nil, err 118 | } 119 | gasLimit, err := dataWrapper.MustGetUint64("gas_limit") 120 | if err != nil { 121 | return nil, err 122 | } 123 | gasPrice, err := dataWrapper.MustGetBigInt("gas_price") 124 | if err != nil { 125 | return nil, err 126 | } 127 | privateNonce := dataWrapper.GetUint64("private_nonce", 0) 128 | // parse private from 129 | privateFromString, err := dataWrapper.MustGetString("private_from") 130 | if err != nil { 131 | return nil, err 132 | } 133 | privateFromKey, err := privacy.ToPublicKey(privateFromString) 134 | if err != nil { 135 | return nil, fmt.Errorf("invalid privateFrom, %v", err) 136 | } 137 | privateFrom := []byte(privateFromKey) 138 | // parse private for 139 | privateForStringSlice := dataWrapper.GetStringSlice("private_for", []string{}) // empty for self transaction 140 | privateFor := make([][]byte, len(privateForStringSlice)) 141 | var publicKey privacy.PublicKey 142 | for _, s := range privateForStringSlice { 143 | publicKey, err = privacy.ToPublicKey(s) 144 | if err != nil { 145 | return nil, fmt.Errorf("invalid privateFor, %v", err) 146 | } 147 | privateFor = append(privateFor, publicKey) 148 | } 149 | // get data to sign 150 | inputData, err := dataWrapper.MustGetString("data") 151 | if err != nil { 152 | return nil, err 153 | } 154 | var txDataToSign []byte 155 | txDataToSign, err = hexutil.Decode(inputData) 156 | if err != nil { 157 | return nil, err 158 | } 159 | // get transaction to sign 160 | address := dataWrapper.GetString("address_to", "") 161 | var besuTx *types.PrivateTransaction 162 | if address == "" { 163 | besuTx = types.NewContractCreation(privateNonce, amount, gasLimit, gasPrice, txDataToSign, privateFrom, privateFor) 164 | } else { 165 | contractAddress := common.HexToAddress(address) 166 | besuTx = types.NewTransaction(privateNonce, &contractAddress, amount, gasLimit, gasPrice, txDataToSign, privateFrom, privateFor) 167 | } 168 | // get private ecdsa key from account for signing data 169 | privateKeyECDSA, err := account.GetPrivateKeyECDSA() 170 | if err != nil { 171 | return nil, fmt.Errorf("error reconstructing private key, %v", err) 172 | } 173 | defer utils.ZeroKey(privateKeyECDSA) 174 | // Sign Tx 175 | besuSignedTx, err := besuTx.SignTx(chainID, privateKeyECDSA) 176 | if err != nil { 177 | return nil, err 178 | } 179 | besuRawTxData, err := rlp.EncodeToBytes(besuSignedTx) 180 | if err != nil { 181 | return nil, err 182 | } 183 | for i := range besuRawTxData { 184 | tmp, _ := rlp.EncodeToBytes(besuSignedTx) 185 | tmp = append(tmp[:1], tmp[i:]...) 186 | var txSlice []interface{} 187 | err = rlp.DecodeBytes(tmp, &txSlice) 188 | if err != nil { 189 | continue 190 | } 191 | if len(txSlice) == 12 { // 12 args in private transaction 192 | besuRawTxData = tmp 193 | break 194 | } 195 | } 196 | return &logical.Response{ 197 | Data: map[string]interface{}{ 198 | // "transaction_hash": signedTx.Hash().Hex(), 199 | "signed_transaction": hexutil.Encode(besuRawTxData), 200 | "address_from": account.AddressStr, 201 | "address_to": address, 202 | "amount": amount.String(), 203 | "gas_price": gasPrice.String(), 204 | "gas_limit": gasLimit, 205 | }, 206 | }, nil 207 | } 208 | -------------------------------------------------------------------------------- /internal/path/sign_transaction.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package path 19 | 20 | import ( 21 | "bytes" 22 | "context" 23 | "fmt" 24 | 25 | "github.com/ethereum/go-ethereum/common" 26 | "github.com/ethereum/go-ethereum/common/hexutil" 27 | "github.com/ethereum/go-ethereum/core/types" 28 | "github.com/hashicorp/vault/sdk/framework" 29 | "github.com/hashicorp/vault/sdk/logical" 30 | 31 | "github.com/bsostech/vault-blockchain/internal/model" 32 | "github.com/bsostech/vault-blockchain/pkg/utils" 33 | ) 34 | 35 | type signTransactionPathConfig struct { 36 | basePathConfig 37 | } 38 | 39 | func (s *signTransactionPathConfig) getPattern() string { 40 | return "accounts/" + framework.GenericNameRegex("name") + "/sign-tx" 41 | } 42 | 43 | func (s *signTransactionPathConfig) getHelpSynopsis() string { 44 | return "Sign a provided transaction." 45 | } 46 | 47 | func (s *signTransactionPathConfig) getFields() map[string]*framework.FieldSchema { 48 | return map[string]*framework.FieldSchema{ 49 | "name": { 50 | Type: framework.TypeString, 51 | }, 52 | "address_to": { 53 | Type: framework.TypeString, 54 | Description: "The address of the account to send tx to.", 55 | }, 56 | "chainID": { 57 | Type: framework.TypeString, 58 | Description: "The chain ID of the blockchain network.", 59 | }, 60 | "data": { 61 | Type: framework.TypeString, 62 | Description: "The data to sign.", 63 | }, 64 | "is_private": { 65 | Type: framework.TypeBool, 66 | Default: false, 67 | Description: "Private for column is null or not", 68 | }, 69 | "amount": { 70 | Type: framework.TypeString, 71 | Description: "Amount of ETH (in wei).", 72 | }, 73 | "nonce": { 74 | Type: framework.TypeString, 75 | Description: "The transaction nonce.", 76 | }, 77 | "gas_limit": { 78 | Type: framework.TypeString, 79 | Description: "The gas limit for the transaction - defaults to 21000.", 80 | Default: "21000", 81 | }, 82 | "gas_price": { 83 | Type: framework.TypeString, 84 | Description: "The gas price for the transaction in wei.", 85 | Default: "0", 86 | }, 87 | } 88 | } 89 | 90 | func (s *signTransactionPathConfig) getCallbacks() map[logical.Operation]framework.OperationFunc { 91 | return map[logical.Operation]framework.OperationFunc{ 92 | logical.CreateOperation: s.signTransaction, 93 | } 94 | } 95 | 96 | func (s *signTransactionPathConfig) signTransaction(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { 97 | dataWrapper := model.NewFieldDataWrapper(data) 98 | name, err := dataWrapper.MustGetString("name") 99 | if err != nil { 100 | return nil, err 101 | } 102 | account, err := s.readAccount(ctx, req, name) 103 | if err != nil { 104 | return nil, fmt.Errorf("error reading account, %v", err) 105 | } 106 | chainID, err := dataWrapper.MustGetBigInt("chainID") 107 | if err != nil { 108 | return nil, err 109 | } 110 | amount, err := dataWrapper.MustGetBigInt("amount") 111 | if err != nil { 112 | return nil, err 113 | } 114 | gasLimit, err := dataWrapper.MustGetUint64("gas_limit") 115 | if err != nil { 116 | return nil, err 117 | } 118 | gasPrice, err := dataWrapper.MustGetBigInt("gas_price") 119 | if err != nil { 120 | return nil, err 121 | } 122 | nonce := dataWrapper.GetUint64("nonce", 0) 123 | inputData, err := dataWrapper.MustGetString("data") 124 | if err != nil { 125 | return nil, err 126 | } 127 | var txDataToSign []byte 128 | txDataToSign, err = hexutil.Decode(inputData) 129 | if err != nil { 130 | return nil, err 131 | } 132 | // get transaction to sign 133 | address := dataWrapper.GetString("address_to", "") 134 | var tx *types.Transaction 135 | if address == "" { 136 | tx = types.NewContractCreation(nonce, amount, gasLimit, gasPrice, txDataToSign) 137 | } else { 138 | tx = types.NewTransaction(nonce, common.HexToAddress(address), amount, gasLimit, gasPrice, txDataToSign) 139 | } 140 | // get signer 141 | isPrivate := dataWrapper.GetBool("is_private", false) 142 | var signer types.Signer 143 | if isPrivate { 144 | signer = types.HomesteadSigner{} 145 | } else { 146 | signer = types.NewEIP155Signer(chainID) 147 | } 148 | // get private ecdsa key from account for signing data 149 | privateKey, err := account.GetPrivateKeyECDSA() 150 | if err != nil { 151 | return nil, fmt.Errorf("error reconstructing private key, %v", err) 152 | } 153 | defer utils.ZeroKey(privateKey) 154 | // Sign Tx 155 | signedTx, err := types.SignTx(tx, signer, privateKey) 156 | if err != nil { 157 | return nil, err 158 | } 159 | var signedTxBuff bytes.Buffer 160 | err = signedTx.EncodeRLP(&signedTxBuff) 161 | if err != nil { 162 | return nil, err 163 | } 164 | return &logical.Response{ 165 | Data: map[string]interface{}{ 166 | "transaction_hash": signedTx.Hash().Hex(), 167 | "signed_transaction": hexutil.Encode(signedTxBuff.Bytes()), 168 | "address_from": account.AddressStr, 169 | "address_to": address, 170 | "amount": amount.String(), 171 | "gas_price": gasPrice.String(), 172 | "gas_limit": gasLimit, 173 | }, 174 | }, nil 175 | } 176 | -------------------------------------------------------------------------------- /pkg/utils/utils.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package utils 19 | 20 | import ( 21 | "crypto/ecdsa" 22 | "math/big" 23 | "regexp" 24 | 25 | "github.com/ethereum/go-ethereum/common/math" 26 | ) 27 | 28 | // ZeroKey removes the key from memory 29 | func ZeroKey(k *ecdsa.PrivateKey) { 30 | b := k.D.Bits() 31 | for i := range b { 32 | b[i] = 0 33 | } 34 | } 35 | 36 | // ValidNumber returns a valid positive integer 37 | func ValidNumber(input string) *big.Int { 38 | if input == "" { 39 | return big.NewInt(0) 40 | } 41 | matched, err := regexp.MatchString("([0-9])", input) 42 | if !matched || err != nil { 43 | return nil 44 | } 45 | amount := math.MustParseBig256(input) 46 | return amount.Abs(amount) 47 | } 48 | -------------------------------------------------------------------------------- /scripts/setup_plugin_local.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function install_plugin { 4 | make build-local 5 | export SHASUM256=$(shasum -a 256 "./plugins/vault-blockchain" | cut -d' ' -f1) 6 | vault write sys/plugins/catalog/blockchain-plugin \ 7 | sha_256="${SHASUM256}" \ 8 | command="vault-blockchain --tls-skip-verify=true" 9 | vault secrets enable -path=blockchain -description="BSOS Wallet" -plugin-name=blockchain-plugin plugin 10 | } 11 | 12 | function create_policy { 13 | vault policy write blockchain_user ./configs/blockchain_user.hcl 14 | vault policy write blockchain_master ./configs/blockchain_master.hcl 15 | } 16 | 17 | function enable_userpass { 18 | vault auth enable userpass 19 | export GET_ACCESSOR=$(vault auth list -format=json) 20 | export ACCESSOR=$(echo $GET_ACCESSOR | jq -r '.["userpass/"].accessor') 21 | unset GET_ACCESSOR 22 | } 23 | 24 | vault login $ROOT_TOKEN 25 | install_plugin 26 | create_policy 27 | enable_userpass 28 | 29 | echo 'UserPass Accessor: '$ACCESSOR 30 | echo 'Root Token: '$ROOT_TOKEN 31 | 32 | --------------------------------------------------------------------------------