首页 > 编程知识 正文

有人登上火星吗(火星登陆过吗)

时间:2023-05-05 08:14:50 阅读:93998 作者:4966

免责声明:本文旨在传达更多的市场信息,不构成投资提案。 文章只是代表者的观点,不代表火星财经的官方立场。

编辑:要注意啊

区块链投资,猛攻:火星财经APP下载

来源: Hyperledger实践

结构1.3的新id混合器(identity mixer )以前是零知识证明)不太清楚,本来以为基于PKI的MSP是比较普通稳健的方式,所以新

最近有时间整理了一下,发现零知识的证明也真的是黑科技。

1 .知识零证明入门

1.1 零知识证明例子

网上的这篇文章好厉害3358 www.elecfans.com/block chain/1015964.html

在此,结构示例:假设您需要在光线明亮的夜晚向Bob (店铺职员)证明DMV )颁发的合法驾照。 在这个场景中,明亮的夜晚是下图中的user/用户,DMV车管所是issuer/证书颁发者,Bob是验证者。

明亮的夜晚为了证明自己是合法的司机,她经常把自己的驾照交给鲍勃进行检查和验证,但是这样鲍勃就能知道明亮的夜晚许多额外的隐私信息,例如姓名、地址、年龄等。

如果使用idemixer和零正式证明方式,鲍勃现在只能知道这个女用户是合法司机,其他信息是保密的。 下一个明亮的夜晚再来店里,也要在明亮的夜晚向Bob提供不同的证书,保证Bob不知道这个证书是同一个用户。

也就是说,零知识证明可以提供匿名性和不相关性。

1.2知识零证明的有用性

elecfans的文章总结得很好。 常见的有以下两点。

- -数据隐私保护和认证,如明亮的夜晚和鲍勃的示例所示

- -减少计算和扩展,用同样的几次计算可以用零知识证明压缩和削减。 最新的以太坊大力推荐

2. 如果使用Fabric的idemixer

2.1 测试开发环境使用idemixgen命令行

具体请参照3359 Hyperledger-Fabric.readthedocs.io/en/latest/idemixgen.html

2.2 生产环境使用Fabric CA 1.3以上版本

(1)光纤通道结构光纤通道服务器单元

生成两个文件:用户公共密钥和IssuerRevocationPublicKey

)2) MSP初始化配置configtx.yaml定义了Org1Idemix和Org2Idemix两个组织,注意MSP类型是idemix,支持mspdir的文件是结构CA生成的Issuer公共密钥,

组织:

- Org1ide混合版

# # defaultorgdefinestheorganizationwhichisusedinthesampleconfig

# # of the结构. gitdevelopmentenvironment

name: idemixMSP1

# # id为加载MSP定义为

id: idemixMSPID1

MSP类型: ide混合

MSP dir :加密/对等组织/Org3. Example.com

- Org2ide混合版

# # defaultorgdefinestheorganizationwhichisusedinthesampleconfig

# # of the结构. gitdevelopmentenvironment

name: idemixMSP2

# # id为加载MSP定义为

id: idemixMSPID2

MSP类型: ide混合

MSP dir :加密/对等组织/Org4.示例.com

轮廓:

TwoOrgsOrdererGenesis_v13:

能力:

订单生成器:

组织:

- * *订单错误

能力:

联盟号

:

SampleConsortium:

Organizations:

- *Org1

- *Org2

- *Org1Idemix

- *Org2Idemix

Application:

Organizations:

- *OrdererOrg

Capabilities:

TwoOrgsChannel_v13:

Consortium: SampleConsortium

Application:

Organizations:

- *Org1

- *Org2

- *Org1Idemix

- *Org2Idemix

Capabilities:

(3) CA客户端生成用户

IdemixEnrollment idemixEnrollment = hfcaClient.idemixEnroll(x509enrollment, "idemixMSPID1");

(4)验证者链码如何获取idemixer信息 暂时go的链码的cid(Client Identity)库才支持获取idemixer证书信息。

func GetAttributeValue(stub ChaincodeStubInterface, attrName string) (value string, found bool, err error)type ChaincodeStubInterface interface {// GetCreator returns `SignatureHeader.Creator` (e.g. an identity)// of the `SignedProposal`. This is the identity of the agent (or user)// submitting the transaction.GetCreator ([]byte, error)}type ClientIdentity interface {// GetID returns the ID associated with the invoking identity. This ID// is guaranteed to be unique within the MSP.GetID (string, error)// Return the MSP ID of the clientGetMSPID (string, error)// GetAttributeValue returns the value of the client's attribute named `attrName`.// If the client possesses the attribute, `found` is true and `value` equals the// value of the attribute.// If the client does not possess the attribute, `found` is false and `value`// equals "".GetAttributeValue(attrName string) (value string, found bool, err error)// AssertAttributeValue verifies that the client has the attribute named `attrName`// with a value of `attrValue`; otherwise, an error is returned.AssertAttributeValue(attrName, attrValue string) error// GetX509Certificate returns the X509 certificate associated with the client,// or nil if it was not identified by an X509 certificate.GetX509Certificate (*x509.Certificate, error)}

暂时idemixer的GetAttributeValue只支持ou和role

- ou 是identity’s affiliation (e.g. “org1.department1”)

- role 是‘member’ 或 ‘admin’.

具体调用的go链码

package mainimport ("fmt""log""os""strconv""strings""github.com/hyperledger/fabric-chaincode-go/pkg/cid""github.com/hyperledger/fabric-chaincode-go/shim"pb "github.com/hyperledger/fabric-protos-go/peer")// Invoke makes payment of X units from A to Bfunc (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {Info.Println("########### example_cc Invoke ###########")function, args := stub.GetFunctionAndParameters// Getting attributes from an idemix credentialou, found, err := cid.GetAttributeValue(stub, "ou");if err != nil {return shim.Error("Failed to get attribute 'ou'")}if !found {return shim.Error("attribute 'ou' not found")}if !strings.HasSuffix(ou, "department1") {return shim.Error(fmt.Sprintf("Incorrect 'ou' returned, got '%s' expecting to end with 'department1'", ou))}role, found, err := cid.GetAttributeValue(stub, "role");if err != nil {return shim.Error("Failed to get attribute 'role'")}if !found {return shim.Error("attribute 'role' not found")}if role != "member" {return shim.Error(fmt.Sprintf("Incorrect 'role' returned, got '%s' expecting 'member'", role))}if function == "delete" {// Deletes an entity from its statereturn t.delete(stub, args)}if function == "query" {// queries an entity statereturn t.query(stub, args)}if function == "move" {// Deletes an entity from its statereturn t.move(stub, args)}Error.Printf("Unknown action, check the first argument, must be one of 'delete', 'query', or 'move'. But got: %v", args[0])return shim.Error(fmt.Sprintf("Unknown action, check the first argument, must be one of 'delete', 'query', or 'move'. But got: %v", args[0]))}

2.3 idemixer的限制

还不大完善,基本现阶段还是推荐用传统的MSP方式,具体参考https://hyperledger-fabric.readthedocs.io/en/latest/idemix.html#current-limitations

零知识证明在以太坊是推崇的,它的应用场景实际蛮广的,fabric尚需努力,不过貌似2.0那么久还没release或者是推广得不好。不过区块链的前途是光明的,道路是曲折的,多了解下这些基础不是坏事。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。