DZhangLab / HIDe-infrastructure

2 stars 0 forks source link

Research digital certification process for adding a new user into the system #12

Closed ebenissan closed 1 year ago

ebenissan commented 2 years ago

To determine verifier registration process—user should be able to add verifier. Will need to generate artificial member IDs that have verifier permissions to test the code.

konoikon commented 1 year ago

Fabric Client Application Flow

Image

Overview

Upon the creation of an organization, a trusted certificate authority is defined. The CA issues credentials for users and registers them to the MSP. (The MSP is set up in the network configuration).

In order to connect to the gateway, you need to provide the wallet path (where the private key is stored), the user ID and the MSP (Membership Service Provider) that will verify registration and rights.

Then you specify the channel and chaincode ID and you can submit transactions.

Enrolling & Registering a User

const secret = await caClient.register({
    affiliation,
    enrollmentID: userId,
    role: 'client',
}, adminUser);
const enrollment = await caClient.enroll({
    enrollmentID: userId,
    enrollmentSecret: secret,
});
const x509Identity = {
    credentials: {
        certificate: enrollment.certificate,
        privateKey: enrollment.key.toBytes(),
    },
    mspId: orgMspId,
    type: 'X.509',
};
await wallet.put(userId, x509Identity);
  1. Register the user to the CA
    1. affiliation is a string like org1.department1
    2. userId is a username, a string like org1user, konoikon, danazhang (Research different types of user IDs we can use, minimize the different identifiers per user).
    3. Must use an admin to register a new user
  2. Enroll the user
    1. Use the username and the registration secret
  3. Create an identity object and store it on the wallet

Connecting to the Gateway


const ccp = buildCCPOrg1(); // Loads the organization configuration
const gateway = new Gateway();

const gatewayOpts: GatewayOptions = {
    wallet,
    identity: org1UserId,
    discovery: { enabled: true, asLocalhost: true },
};

await gateway.connect(ccp, gatewayOpts);

const network = await gateway.getNetwork(channelName);

const contract = network.getContract(chaincodeName);

Resources