4 Star 10 Fork 1

连琪/CRBBV1.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

项目介绍

CRBB(Copyright Register Based on Blockchain),即基于区块链的版权登记应用。

本项目的目标,是构建基于RepChain区块链网络系统的图片版权登记保护应用。即实现不受特定中心化服务管理机构控制,由联盟共同建设、共同维护,能提供在线图片版权登记保护服务的应用。本应用,主要由应用客户端, 应用服务端和RepChain区块链网络服务端三部分构成,其核心功能是利用RepChain区块链作为可信见证方,为用户提供图片版权操作服务,包括图片版权登记申请、图片版权登记审核、图片版权登记信息浏览等。

申明:

  1. 本应用目前仅作为RepChain区块链应用的开发示例
  2. 本应用所使用的相关演示图片来自于免费图片网站pexels(遵循其许可协议)

技术组件

本项目所使用的主要开源技术组件包括:

  • RepChain:轻量易用的区块链基础组件,可方便地建立许可链/联盟链网络环境;
  • BAR(Base App of RepChain): RepChain基础应用,提供了区块链应用所需的基础功能,包括用户密钥对管理、公钥证书管理、交易数据同步与检索、区块数据同步与检索以及交易数据构建、交易提交等。本应用基于BAR的源码进行开发;
  • RCJS(RepChain Client for JavaScript),能与RepChain交互的开发包,兼容Browser和Node环境;
  • repchain-synchronizer,RepChain区块链数据同步工具;
  • react-admin:基于ES6、React以及Material Design实现的前端框架;
  • Express: NodeJS Web应用框架;
  • Prisma1:基于GraphQL的数据库访问管理中间件,可替代传统ORMs,并使得底层数据库对开发者透明;
  • Docker:本项目使用了Docker来管理运行Prisma1 Server以及应用服务端本地数据库(默认为MySQL)

应用运行

快速体验

无需手动安装各种依赖以及搭建RepChain网络,可以基于已编写好的docker-compose.yml文件,在Docker容器中运行及体验本应用:

进入docker目录:

cd docker

运行容器服务(需事先安装好Git V2+、dockerdocker-compose):

sudo docker-compose -p crbb up -d

上述命令将在本地构建名为crbb与repchain的docker镜像(若网络环境不理想,构建时间会较长)并自动运行相应容器服务(默认运行4个容器服务:crbb_repchain,crbb_app,crbb_prisma,crbb_mysql)。先等待2-5分钟待各个容器服务能正常相互访问,再打开浏览器访问地址http://localhost:3000 即可体验本应用。

若需要自行搭建环境并安装运行本应用,可参考以下内容:

环境准备

  1. 安装Git(V2+)
  2. 安装JDK(V1.8 or V13)
  3. 安装node,推荐使用nvm安装管理node

    推荐node版本为10.23.0

  4. 安装yarn
    npm i -g yarn

    建议将npm库地址换为阿里地址:

    yarn config set registry https://registry.npm.taobao.org
  5. 安装node-gyp
yarn global add node-gyp
  1. 安装编译工具make和g++
  2. 安装docker(可参考这里)以及docker-compose(可参考这里)
  3. 搭建RepChain网络,可参考以下文档

运行

Note: 目前只支持在Linux或Mac OS环境下运行

安装依赖包并部署prisma

使用git工具将本项目clone到本地之后,进入项目根目录, 运行以下命令:

  • 安装依赖(同时安装前端以及后端各自的依赖包)
    yarn install-all
  • 为后端创建运行prisma以及数据库的docker容器,并部署prisma
    yarn deploy

    Note: 若当前用户没有运行docker命令的权限,则需要赋予其相应的权限,如在上述命令前使用sudo或将当前用户加入docker用户组

后端配置

进入目录: server/config, 可通过json格式的配置文件进行配置:

  • default.json: 正式运行环境下的配置内容
  • test.json: 开发测试环境下的配置内容

主要配置项包括:

  • File.fileUploadDir: 文件上传时的暂存目录

  • File.fileStorageDir: 文件被正式存储的目录

  • File.uploadLimits.fields: 上传文件时multipart/form-data的最大项目数

  • File.uploadLimits.fileSize: 上传文件时每个文件的最大限制(字节数)

  • File.uploadLimits.files: 单次上传文件时允许的最多文件数

  • Log.api: 后端对Restful api调用情况的日志记录管理

  • Log.serverInner: 后端对功能逻辑运行情况的日志记录管理

  • ServerCrypto.prvKeyFilePath: 后端使用的私钥文件的存储路径,该私钥将被用于区块链交易的构建

  • ServerCrypto.prvKeyPassword: 后端所使用私钥的解密密码(若该私钥已被加密,需要提供该密码以解密使用)

  • ServerCrypto.pubKeyFilePath: 后端所使用的公钥证书文件的存储路径,该公钥将被用于区块链交易的构建

  • ServerCrypto.alg: 后端构建签名交易所使用的算法

  • ServerCrypto.creditCode: 后端所使用的RepChain账户唯一标识

  • ServerCrypto.certName: 后端所使用的RepChain账户证书名称

  • ServerCrypto.jwtSignAlg: 后端生成Json Web Token时使用的签名算法

  • ServerCrypto.jwtSecrect: 后端上传Json Web Token时使用的密钥

  • RepChain.default.url_subscribe: RepChain节点的Websocket API地址,用于同步RepChain区块链数据时的实时推送同步

  • RepChain.default.url_api: RepChain节点的Restful API地址,用于同步RepChain区块链数据时的主动获取同步

  • RepChain.server: RepChain代理节点的地址,用于提交区块链交易

  • RepChain.port: RepChain代理节点的服务端口,用于提交区块链交易

  • RepChain.chaincodeName: 图片版权登记智能合约名称

  • RepChain.chaincodeVersion: 图片版权登记智能合约版本号

Note: 上述配置中涉及文件路径的配置项,对各文件路径需有相应的读写权限

前端配置

在项目根目录下进入目录: src, 可编辑配置文件settings.js。 主要配置项目包括:

  • RepChain.default.url_api: RepChain代理节点的Restful API地址,用于前端提交区块链交易

  • Repchain.chaincodeName: 前端所构建交易调用的链码名称

  • Repchain.chaincodeVersion: 前端所构建交易调用链码的版本号

  • Prisma.endpoint: prisma server http服务地址

  • Prisma.url_subscribe: prisma server websocket服务地址

  • Server.wsBaseUrl: 后端websocket服务地址

启动应用

  1. 确认RepChain已正常运行;
  2. 确认prisma和database的docker容器已正常运行;
  3. 确认上述配置已完成;
  4. 启动应用:
  • yarn start 启动应用(同时启动前端和后端服务)

Note: 在这里提供前端资源的服务只是ReactJS的开发服务

使用

注册

机构用户已经在RepChain联盟链初始化时生成了,我们只可以注册普通用户。

注册

注册账户成功后,将在本地生成密钥对并使用用户输入的密码对其中的私钥进行加密后持久化于浏览器中,我们可以在登录后,对当前账户的密钥对进行导出备份保护。

登录

对已注册的普通用户,若本地浏览器已有对应的密钥对,可以直接登录。

登录-已有密钥对

若本地浏览器无该账户的密钥对,则在登录时,需要导入密钥对文件。比如,在首次登录机构账户时,由于浏览器中还没有机构账户的密钥对,因此,需要导入才能登录。而机构账户的密钥对,是在构建RepChain联盟链时,就生成的,我们需要预先得到某个机构用户的密钥对文件,比如RepChain的源码中包含了示例联盟链组网中的某个组织机构的密钥信息:jks/121000005l35120456.node1.jks。如下图所示,使用工具keystore-explore可以从该jks文件中获得密钥对文件(解密密码为:123)。

keystore导出密钥对

当得到组织机构的密钥对文件后,便可以组织机构用户身份登录应用。

机构用户首次登录

图片版权登记申请

我们以之前新注册的普通用户身份登录应用,然后转到“图片版权登记”功能页,可以进行版权登记申请,操作如下图所示。

图片版权登记申请

图片版权登记信息浏览

用户可以对图片版权登记信息进行浏览查看,可以查看“公示图片”和“我的图片”版权登记信息,前者是应用系统中所有用户的图片版权登记信息,后者只显示当前用户的图片版权登记信息。

用户通过浏览查看版权登记信息,可以知晓图片版权登记的状态以及与之相关的区块链交易等信息。

图片版权登记信息浏览

图片版权登记审核

机构用户登录应用之后,可以对普通用户的版权登记申请进行审核,进行确认登记或拒绝登记操作。

图片版权登记审核

密钥对导出

用户可对浏览器中持久化的密钥对进行导出保存,以防浏览器故障等导致密钥丢失或需要更换设备时登录应用。

密钥对导出

自动化测试

后端测试:

  • 在项目根目录下,进入server目录后运行: yarn test

应用开发教程

作为RepChain区块链应用的开发示例,我们提供了本应用的详细开发过程,请参考Tutorial

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2018 Linkel Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

RepChain区块链示例应用,基于区块链的图片版权存证应用 展开 收起
JavaScript 等 5 种语言
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/linkel/CRBBV1.0.git
git@gitee.com:linkel/CRBBV1.0.git
linkel
CRBBV1.0
CRBBV1.0
master

搜索帮助

Cb406eda 1850385 E526c682 1850385