Skip to content

Commit b4021a1

Browse files
authored
Merge pull request #316 from VRamakrishna/main
Fabric Interoperation Chaincode Upgrade for Attested Foreign Identities
2 parents 835f0df + ba63f75 commit b4021a1

File tree

35 files changed

+2083
-498
lines changed

35 files changed

+2083
-498
lines changed

.github/workflows/test_asset-exchange-fabric.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ on:
2121
jobs:
2222

2323
asset-exchange-fabric:
24-
# if: ${{ false }} # disable
24+
if: ${{ false }} # disable
2525
# The type of runner that the job will run on
2626
runs-on: ubuntu-latest
2727

.github/workflows/test_asset-transfer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2121
jobs:
2222
fabric-asset-transfer:
23-
# if: ${{ false }} # disable
23+
if: ${{ false }} # disable
2424
# The type of runner that the job will run on
2525
runs-on: ubuntu-latest
2626

.github/workflows/test_data-sharing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2121
jobs:
2222
data-sharing:
23-
# if: ${{ false }} # disable
23+
if: ${{ false }} # disable
2424
# The type of runner that the job will run on
2525
runs-on: ubuntu-latest
2626

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

Lines changed: 100 additions & 103 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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,31 @@ message SecurityDomainMemberIdentity {
2929
}
3030

3131
message SecurityDomainMemberIdentityRequest {
32-
SecurityDomainMemberIdentity source_network = 1;
33-
SecurityDomainMemberIdentity requesting_network = 2;
34-
string nonce = 3;
32+
SecurityDomainMemberIdentity source_network = 1;
33+
SecurityDomainMemberIdentity requesting_network = 2;
34+
string nonce = 3;
3535
}
3636

3737
// Association of signature (over arbitrary data) and signer identity
3838
message Attestation {
3939
SecurityDomainMemberIdentity unit_identity = 1;
4040
string certificate = 2;
4141
string signature = 3;
42+
string nonce = 4;
4243
}
4344

4445
// Attested security domain membership by a single member
4546
message AttestedMembership {
46-
common.membership.Membership membership = 1;
47+
string membership = 1; // 'common.membership.Membership': Serialized and Base64-encoded
4748
Attestation attestation = 2;
4849
}
4950

5051
// Counter attestation over security domain membership attested by its participants
5152
message CounterAttestedMembership {
5253
message AttestedMembershipSet {
53-
common.membership.Membership membership = 1;
54+
string membership = 1; // 'common.membership.Membership': Serialized and Base64-encoded
5455
repeated Attestation attestations = 2;
5556
}
56-
AttestedMembershipSet attested_membership_set = 1;
57+
string attested_membership_set = 1; // 'AttestedMembershipSet': Serialized and Base64-encoded
5758
repeated Attestation attestations = 2;
5859
}

core/drivers/corda-driver/makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ build-refresh-dependencies: github.properties
2626
.PHONY: image-local
2727
image-local: build-local
2828
docker build -f Dockerfile.local -t $(DOCKER_IMAGE_NAME):$(DOCKER_TAG) .
29+
docker tag $(DOCKER_IMAGE_NAME):$(DOCKER_TAG) $(DOCKER_IMAGE_NAME):latest
2930

3031
.PHONY: image
3132
image: github.properties

core/drivers/fabric-driver/makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ build-image-local: protos-js weaver-fabric-interop-sdk
4343
(mv package-remote.json package.json && exit 1) # Only if fails
4444
mv package-remote.json package.json # Only if success
4545
rm -rf protos-js
46+
docker tag ${DOCKER_IMAGE_NAME}:$(DOCKER_TAG) $(DOCKER_IMAGE_NAME):latest
4647

4748
build-image: .npmrc
4849
docker build --build-arg BUILD_TAG="remote" --build-arg GIT_URL=$(GIT_URL) -t ${DOCKER_IMAGE_NAME}:$(DOCKER_TAG) -f fabricDriver.dockerfile .

core/network/fabric-interop-cc/contracts/interop/certificate_utils.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ func verifyCaCertificate(cert *x509.Certificate, memberCertificate string) error
9090
return nil
9191
}
9292

93-
/* This function works for a Corda network's configuration
94-
The assumption is that a Corda network has a single Root CA and Doorman CA, and one or more Node CAs corresponding to nodes.
95-
This function will receive arguments for exactly one node with the following cert chain assumed: <root cert> -> <int cert 0> -> <int cert 1>
93+
/* This function will receive arguments for exactly one node with the following cert chain assumed: <root cert> -> <int cert 0> -> <int cert 1> -> ......
94+
In a Fabric network, we assume that there are multiple MSPs, each having one or more Root CAs and zero or more Intermediate CAs.
95+
In a Corda network, we assume that there is a single Root CA and Doorman CA, and one or more Node CAs corresponding to nodes.
9696
*/
9797
func verifyCertificateChain(cert *x509.Certificate, certPEMs []string) error {
9898
var parentCert *x509.Certificate
@@ -227,7 +227,7 @@ func validateSignature(message string, cert *x509.Certificate, signature string)
227227
pubKey := getECDSAPublicKeyFromCertificate(cert)
228228
if pubKey != nil {
229229
// Construct the message that was signed
230-
hashed, err := computeSHA2Hash([]byte(message), 256)
230+
hashed, err := computeSHA2Hash([]byte(message), pubKey.Params().BitSize)
231231
if err != nil {
232232
return err
233233
}
@@ -241,6 +241,7 @@ func validateSignature(message string, cert *x509.Certificate, signature string)
241241
return errors.New("Missing or unsupported public key type")
242242
}
243243
}
244+
244245
func parseCert(certString string) (*x509.Certificate, error) {
245246
certBytes, _ := pem.Decode([]byte(certString))
246247

core/network/fabric-interop-cc/contracts/interop/decoders.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
package main
1313

1414
import (
15+
"encoding/base64"
1516
"encoding/json"
1617
"strings"
18+
"fmt"
1719

1820
"github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/common"
21+
"github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/identity"
22+
protoV2 "google.golang.org/protobuf/proto"
1923
)
2024

2125
func decodeMembership(jsonBytes []byte) (*common.Membership, error) {
@@ -29,6 +33,19 @@ func decodeMembership(jsonBytes []byte) (*common.Membership, error) {
2933
return &decodeObj, nil
3034
}
3135

36+
func decodeCounterAttestedMembership(protoBytesBase64 string) (*identity.CounterAttestedMembership, error) {
37+
var decodeObj identity.CounterAttestedMembership
38+
protoBytes, err := base64.StdEncoding.DecodeString(protoBytesBase64)
39+
if err != nil {
40+
return nil, fmt.Errorf("Counter attested membership could not be decoded from base64: %s", err.Error())
41+
}
42+
err = protoV2.Unmarshal(protoBytes, &decodeObj)
43+
if err != nil {
44+
return nil, fmt.Errorf("Unable to unmarshal counter attested membership: %s", err.Error())
45+
}
46+
return &decodeObj, nil
47+
}
48+
3249
func decodeVerificationPolicy(jsonBytes []byte) (*common.VerificationPolicy, error) {
3350
var decodeObj common.VerificationPolicy
3451
dec := json.NewDecoder(strings.NewReader(string(jsonBytes)))

core/network/fabric-interop-cc/contracts/interop/handle_external_request_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ func testHandleExternalRequestSignatureCertificateMismatch(t *testing.T, query *
181181

182182
_, err = interopcc.HandleExternalRequest(ctx, string(b64QueryBytes))
183183
require.EqualError(t, err, fmt.Sprintf("Invalid Signature: asn1: structure error: tags don't match (16 vs {class:1 tag:19 length:105 isCompound:false}) {optional:false explicit:false application:false private:false defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} ECDSASignature @2"))
184+
//require.EqualError(t, err, "Invalid Signature: Signature Verification failed. ECDSA VERIFY")
184185
}
185186

186187
func testHandleExternalRequestInvalidCert(t *testing.T, query *common.Query) {

0 commit comments

Comments
 (0)