FEIP32V1_HAT(zh-CN)
-
FEIP32: HAT Version: 1 Language: en-US Author: C_armX, Deisler-JJ_Sboy, master_wang Status: draft Created date: 2021-06-12 Last modified date:2022-04-05 PID: "" TXID:
FEIP32V1_HAT(zh-CN)
Contents
General rules of FEIP type protocols
Rules specific to this protocol
Introduction
Protocol type: FEIP Serial number: 32 Protocol name: HAT Version: 1 Description : 基于数据哈希对数据进行描述、识别、索引、组织和定位的共识。 Author: C_armX, Deisler-JJ_Sboy,master_wang Language: en-US Previous version PID:""
General consensus of FEIP type protocols
-
Write important data in OP_RETURN for public witness under FEIP type protocols.
-
The SIGHASH flag of all transaction inputs is ‘ALL’ (value 0x01).
-
The max size of OP_RETURN : 4096 bytes.
-
The format of the data in op_return: JSON.
-
Encoding : utf-8.
Consensus of this protocol
-
本协议以数据(或文件)的哈希作为文件身份(fid)描述该数据(或文件)的主要属性,作为自由共识生态的文件管理共识。
-
哈希属性(HA):指一项数据(或文件)的17项属性描述值,用于识别、索引、组织和定位特定数据。参见哈希属性。
-
哈希属性表(HAT):指存放多个数据(或文件)的哈希属性的列表。
-
哈希属性表文件(HAT file):指专门用于保存哈希属性表的文件。
-
编码:哈希属性的值的编码为utf-8
哈希属性
数据(或文件)的哈希属性(HA)是对数据的全面描述,分为6类20项属性,除了fid之外,其他均可为空。
分类 序号 字段名 中文名 类型 值的说明 长度 basic 1 fid 文件身份 string 文件的Sha256值 32 2 name 文件名 string 文件全名,含后缀 0~256 3 type 类型 string 应用自定义,兼容传统后缀 0~8 4 aid 应用id string 文件归属的应用的aid 0~32 5 pid 协议id string 文件遵循的协议的pid 0~32 extend 6 description 描述 string 用户自定义 0~256 7 size 文件大小 Int32 文件实际大小byte 0~5 8 firstTime 首获时间 time stamp 绝对时间 0~4 9 lastTime 最后修改属性时间 time stamp 绝对时间,哈希修改视为新文件 0~4 version 10 srcFid 源哈希 string Sha256 0~32 11 preVerFid 前版哈希 string Sha256 0~32 slice 12 firstPartFid 首片哈希 string sha256 0~32 13 prePartFid 前片哈希 string sha256 0~32 14 total 分片总数 Int16 2~65535 0~2 crypto 15 encryptionAlgorithm 加密算法 string 空为未加密 0~32 16 pubKey 加密公钥 string hex 0~66 17 symKeyEncrypted 加密的对称密钥 string 0~512 manage 18 rank 重要性 int 1~5 0~1 19 Status 状态 int 0删除,1活跃,2归档 0~1 20 location 存放位置 string array url 0~4096
哈希属性表
当管理多个数据或文件时,这些数据的哈希属性集合为一个列表,即哈希属性表(Hash Attributes Table)。
哈希属性表采用Hpack Json的方式保存和解析。
哈希属性表文件
由多个数据的哈希属性组成的哈希属性表(HAT)可以保存在文件中,称为HAT文件,该文件按以下方式组织:
1. 以"FC:"开始,string,3字节 2. 文件描述的Json,参见下表 3. 哈希属性表(HAT),Hpack Json格式 4. 文件结束标志:EOF
field number field name type length content required 1 type String 4 Fixed: "FEIP"<br>Case insensitive Y 2 sn int 2 Serial number<br>Fixed: 32 Y 3 ver int 1 Fixed: 1 Y 4 name String 3 Fixed: "HAT"<br>Case insensitive N 5 pid hex 32 Sha256 value of this protocol file N Example of the content of a HAT file my.hat
FC: { "type": "FEIP", "sn": 30, "ver": 1, "name": "HAT", "pid": "" } [ ["fid", "name", "type", "description", "size", "firstTime", "lastTime", "sourceHash", "previousVersionHash", "previousPartHash", "tatol", "encryptionAlgorithm","publickey", "rank", "status", "location"], ["00000000000000000000000000000000000000000000000000000000000000”, “my.hat”, “hat”, “示例文件", , ”1622265045“, "1622265200", ,,,"ECC256k1-AES256CBC", "0323156856677ab2b1308fa1ede716a06ff03fd50aad338396d1b6ea8fa46a59ac", "5", "1", ["https://bbs.cash/topic/558/","fd://filedrive"]], ["03a7f8988aac6d6cd3015144667a9ba943e18b58f6a900fa57651fd391d83b9d”, “FEIP12V2_通讯簿(zh-CN).pdf”, “PDF”, “协议文本:FEIP12V2_通讯簿(zh-CN)”] ] EOF
哈希属性表文件链上索引
Hat文件的哈希属性上链,成为一个cid的文件管理入口
上链信息
field number field name type length content required 1 type String 4 Fixed: "FEIP"<br>Case insensitive Y 2 sn int 2 Serial number<br>Fixed: 32 Y 3 ver int 1 Fixed: 1 Y 4 name String 3 Fixed: "HAT"<br>Case insensitive N 5 pid hex 32 Sha256 value of this protocol file N 6 data.fid string 32 文件身份,文件的双Sha256值 Y 7 data.srcFid string 0~32 源版本哈希,双Sha256,自身为源版本则等于data.fid N 8 data.preVerFid string 0~32 前版哈希,双Sha256 N 9 data.firstPartFid string 0~32 首片哈希,双sha256,无分片为空 N 10 data.prePartFid string 0~32 前片哈希,双sha256,无分片为空 N 11 data.algo string 0~32 加密算法,空为未加密,建议"ECC256k1-AES256CBC" N 12 data.pubKey string 0~66 加密公钥,空为上链签名者公钥 N 13 data.symKeyEncrypted string 0~512 加密后的对称密钥 N 14 data.loca string array 0~2048 存放位置,url N 15 data.aid string 0~32 上链HAT文件归属的应用的aid,aid of the app N 16 data.pid string 0~32 上链HAT文件归属的协议的pid,pid of the protocol N Example of add a HAT on Chain
{ "type": "FEIP", "sn": 32, "ver": 1, "name": "HAT", "pid": "", "data":{ "fid": "113334433335252533322334353232332223", "srcFid": "3335535334343535353535535335353535", "preVerFid": "11111111111224444445555555555666666", "firstPartFid": "", "prePartFid": "", "algo": "ECC256k1-AES256CBC", "pubKey": "", "symKeyEncrypted": "", "loca": ["https://bbs.cash/topic/558/"], "aid": "33442224342134121344443443333333", "pid": "88888888888888888833333333333333" } }
删除系列HAT文件信息
指定源哈希,将以此为源头的系列链上HAT文件信息标注为删除。
field number field name type length content required 1 type String 4 Fixed: "FEIP"<br>Case insensitive Y 2 sn int 2 Serial number<br>Fixed: 32 Y 3 ver int 1 Fixed: 1 Y 4 name String 3 Fixed: "HAT"<br>Case insensitive N 5 pid hex 32 Sha256 value of this protocol file N 6 data.op string array 3 操作:"del" Y 7 data.srcFid string 32 源哈希,Sha256 Y Example to delete a HAT series
{ "type": "FEIP", "sn": 32, "ver": 1, "name": "HAT", "pid": "", "data":{ "op": "del", "srcFid": "3335535334343535353535535335353535" } }
使用逻辑
- 运行:App在运行时,HAT在内存中;
- 保存:App非运行期间,HAT在设备本地保存;
- 备份:App根据用户设定,定期或不定期将HAT文件加密备份到分布式存储系统;
- 上链:HAT文件的关键哈希属性保存在链上,成为获得和管理数据的入口。
-