Skip to content

Commit 3ee62ac

Browse files
authored
Merge pull request #310 from VRamakrishna/main
Basic code and documentation for Cross-Network Identity Sync Protocol
2 parents af44a02 + bb5ca73 commit 3ee62ac

38 files changed

+1246
-512
lines changed

common/protos-go/identity/agent.pb.go

Lines changed: 402 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/protos-go/identity/agent_grpc.pb.go

Lines changed: 18 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/protos/identity/agent.proto

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ syntax = "proto3";
33
package identity.agent;
44

55
import "common/ack.proto";
6+
import "common/membership.proto";
67

78
option java_package = "com.weaver.protos.identity.agent";
89
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/identity";
@@ -14,17 +15,39 @@ service IINAgent {
1415
// Requesting network unit's state from a foreign IIN agent.
1516
rpc RequestIdentityConfiguration(NetworkUnitIdentity) returns (common.ack.Ack){}
1617
// Handling network unit's state sent by a foreign IIN agent.
17-
rpc SendIdentityConfiguration(NetworkUnitIdentity) returns (common.ack.Ack){}
18-
// user or agent triggers a flow to collect signatures attesting an
19-
// external/foreign network unit's state and recording to ledger
20-
rpc FlowAndRecordAttestations(NetworkUnitIdentity) returns (common.ack.Ack) {}
18+
rpc SendIdentityConfiguration(AttestedMembership) returns (common.ack.Ack){}
2119
// Requesting attestation from a local IIN agent.
22-
rpc RequestAttestation(NetworkUnitIdentity) returns (common.ack.Ack){}
20+
rpc RequestAttestation(AttestedSecurityDomain) returns (common.ack.Ack){}
2321
// Handling attestation sent by a local IIN agent.
24-
rpc SendAttestation(NetworkUnitIdentity) returns (common.ack.Ack){}
22+
rpc SendAttestation(AttestedSecurityDomain) returns (common.ack.Ack){}
2523
}
2624

25+
// Unique identifier for a unit of a network that runs an IIN agent
2726
message NetworkUnitIdentity {
2827
string network_id = 1;
2928
string participant_id = 2;
29+
string nonce = 3;
30+
}
31+
32+
// Association of signature (over arbitrary data) and signer identity
33+
message Attestation {
34+
NetworkUnitIdentity unit_identity = 1;
35+
string certificate = 2;
36+
string signature = 3;
37+
}
38+
39+
// Attested security domain membership by a single member
40+
message AttestedMembership {
41+
common.membership.Membership membership = 1;
42+
Attestation attestation = 2;
43+
}
44+
45+
// Counter attestation over security domain membership attested by its participants
46+
message AttestedSecurityDomain {
47+
message AttestedMembershipSet {
48+
common.membership.Membership membership = 1;
49+
repeated Attestation attestations = 2;
50+
}
51+
AttestedMembershipSet security_domain = 1;
52+
repeated Attestation attestations = 2;
3053
}

core/drivers/fabric-driver/server/events.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ async function subscribeEventHelper(
5151
const errorString: string = `${JSON.stringify(err)}`;
5252
console.error(errorString);
5353
}
54-
ack_send.setMessage('Event subscription error: listener registration failed');
54+
const errorString2 = JSON.stringify(error);
55+
console.error(errorString2);
56+
ack_send.setMessage(`Event subscription error: listener registration failed with error: ${errorString2}`);
5557
ack_send.setStatus(ack_pb.Ack.STATUS.ERROR);
5658
} else {
5759
ack_send.setMessage('Event subscription is successful!');
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
/*
2+
* Copyright IBM Corp. All Rights Reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
17
export class LedgerBase {
28
ledgerId: string; // Unique ID of a ledger in which the Weaver interoperation module is installed
39
contractId: string; // Unique ID of the contract corresponding to the Weaver interoperation module installed in 'ledgerId'
4-
private _isConnected: boolean // Flag indicating whether we are ready to invoke contracts on the ledger
510

611
constructor(ledgerId: string, contractId: string) {
712
this.ledgerId = ledgerId;
813
this.contractId = contractId;
9-
this._isConnected = false;
1014
}
1115

1216
getLedgerID(): string {
@@ -17,17 +21,13 @@ export class LedgerBase {
1721
return this.contractId;
1822
}
1923

20-
isConnected(): boolean {
21-
return this._isConnected;
22-
}
23-
2424
// Setup a user (with wallet and one or more identities) with contract invocation credentials
2525
async setupWalletIdentity() {
2626
}
2727

28-
// Preliminary configuration as a prerequisite for contract invocation
29-
async setupLedgerConnection() {
30-
this._isConnected = true;
28+
// Collect security domain membership info
29+
async getSecurityDomainMembership(): Promise<object> {
30+
return {};
3131
}
3232

3333
// Invoke a contract to drive a transaction
@@ -36,6 +36,7 @@ export class LedgerBase {
3636
}
3737

3838
// Query a contract to fetch information from the ledger
39-
async queryContract() {
39+
async queryContract(): Promise<string> {
40+
return "";
4041
}
4142
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"admin":{
3+
"name":"admin",
4+
"secret":"adminpw"
5+
},
6+
"agent": {
7+
"name":"iin-agent",
8+
"affiliation":"org1.department1",
9+
"role": "client",
10+
"attrs": [{ "name": "iin-agent", "value": "true", "ecert": true }]
11+
},
12+
"mspId":"Org1MSP",
13+
"ordererMspIds": ["OrdererMSP"],
14+
"caUrl":""
15+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright IBM Corp. All Rights Reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import { Contract } from 'fabric-network';
8+
import { LedgerBase } from '../common/ledgerBase';
9+
import { walletSetup } from './walletUtils';
10+
import { getAllMSPConfigurations, invokeFabricChaincode, queryFabricChaincode } from './networkUtils';
11+
import * as path from 'path';
12+
import * as fs from 'fs';
13+
14+
export class FabricConnector extends LedgerBase {
15+
connectionProfilePath: string;
16+
configFilePath: string;
17+
networkId: string;
18+
orgMspId: string;
19+
walletPath: string;
20+
21+
constructor(ledgerId: string, contractId: string, networkId: string, connectionProfilePath: string, configFilePath: string, walletPath: string) {
22+
super(ledgerId, contractId);
23+
this.connectionProfilePath = connectionProfilePath ? connectionProfilePath : path.resolve(__dirname, './', 'connection_profile.json');
24+
this.configFilePath = configFilePath ? configFilePath : path.resolve(__dirname, './', 'config.json');
25+
this.networkId = networkId ? networkId : 'network1';
26+
if (!fs.existsSync(configFilePath)) {
27+
throw new Error('Config does not exist at path: ' + configFilePath);
28+
}
29+
this.orgMspId = JSON.parse(fs.readFileSync(configFilePath, 'utf8').toString()).mspId;
30+
this.walletPath = walletPath ? walletPath : path.join(process.cwd(), `wallet-${this.networkId}`);
31+
}
32+
33+
// Setup a user (with wallet and one or more identities) with contract invocation credentials
34+
async setupWalletIdentity() {
35+
walletSetup(this.walletPath, this.connectionProfilePath, this.configFilePath, this.networkId);
36+
}
37+
38+
// Collect security domain membership info
39+
async getSecurityDomainMembership(): Promise<object> {
40+
const memberships = getAllMSPConfigurations(this.walletPath, this.connectionProfilePath, this.configFilePath, this.ledgerId);
41+
const securityDomainInfo = {
42+
securityDomain: this.networkId,
43+
members: memberships,
44+
}
45+
return securityDomainInfo;
46+
}
47+
48+
// Invoke a contract to drive a transaction
49+
// TODO: Add parameters corresponding to the output of a flow among IIN agents
50+
async invokeContract(): Promise<any> {
51+
return await invokeFabricChaincode(this.walletPath, this.connectionProfilePath, this.configFilePath, this.ledgerId, this.contractId, "", []);
52+
}
53+
54+
// Query a contract to fetch information from the ledger
55+
async queryContract(): Promise<string> {
56+
return await queryFabricChaincode(this.walletPath, this.connectionProfilePath, this.configFilePath, this.ledgerId, this.contractId, "", []);
57+
}
58+
}

0 commit comments

Comments
 (0)