- 
                Notifications
    You must be signed in to change notification settings 
- Fork 9
Enable multiple policies type #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|  | @@ -10,10 +10,14 @@ option go_package = "github.com/hyperledger/fabric-x-committer/api/protoblocktx" | |||||
|  | ||||||
| package protoblocktx; | ||||||
|  | ||||||
| // Represents a transaction in the blockchain. | ||||||
| message Tx { | ||||||
| repeated TxNamespace namespaces = 1; // Namespaces associated with the transaction. | ||||||
| repeated bytes signatures = 2; // Signature per namespace. | ||||||
| // A list of namespaces that define the transaction's scope. | ||||||
| repeated TxNamespace namespaces = 1; | ||||||
|  | ||||||
| // A list of endorsements. | ||||||
| // IMPORTANT: This list MUST be the same size as the namespaces list. | ||||||
| // The Endorsement at index i corresponds to the namespace at index i. | ||||||
| repeated Endorsements endorsements = 2; | ||||||
| } | ||||||
|  | ||||||
| // Represents a namespace within a transaction. | ||||||
|  | @@ -44,9 +48,54 @@ message Write { | |||||
| bytes value = 2; // The value associated with the key being written. | ||||||
| } | ||||||
|  | ||||||
| // Endorsements holds all the signatures that correspond to a single namespace | ||||||
| // in the transaction's namespaces list. | ||||||
| message Endorsements { | ||||||
| // The list of individual signatures for the corresponding namespace. | ||||||
| repeated EndorsementWithIdentity endorsements_with_identity = 1; | ||||||
| } | ||||||
|  | ||||||
| // EndorsementWithIdentity bundles a single signature with the identity of its creator. | ||||||
| message EndorsementWithIdentity { | ||||||
| // The actual cryptographic signature bytes. | ||||||
| bytes endorsement = 1; | ||||||
|  | ||||||
| // The identity of the creator who produced the signature, i.e., the endorsement. | ||||||
| Identity identity = 2; | ||||||
| } | ||||||
|  | ||||||
| message Identity { | ||||||
| // The identifier of the associated membership service provider | ||||||
| string msp_id = 1; | ||||||
|  | ||||||
| oneof creator { | ||||||
| // The full raw bytes of the creator's certificate (e.g., an X.509 certificate). | ||||||
| bytes certificate= 2; | ||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super nit: 
        Suggested change
       
 | ||||||
|  | ||||||
| // An identifier for a certificate that is pre-stored or known by the committer. | ||||||
| string certificate_id = 3; | ||||||
| } | ||||||
| } | ||||||
|  | ||||||
| // Represents a namespace policy. | ||||||
| message NamespacePolicy { | ||||||
| string scheme = 1; // The scheme for signature verification. | ||||||
| PolicyType type = 1; // The type of policy used. | ||||||
| bytes policy = 2; // The policy rule. | ||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: Can we use here  | ||||||
| } | ||||||
|  | ||||||
| enum PolicyType { | ||||||
| // A policy for verifying a single signature that was generated via a Threshold Signature | ||||||
| // Scheme (TSS). In a TSS, a threshold (T) of N parties must cooperate to | ||||||
| // collectively compute and produce the single signature. | ||||||
| THRESHOLD_RULE = 0; | ||||||
|  | ||||||
| // A policy defined by an explicit rule that evaluates one or more required signatures. | ||||||
| // For example: "OR('Org1MSP.admin', 'Org2MSP.admin')" | ||||||
| SIGNATURE_RULE = 1; | ||||||
| } | ||||||
|  | ||||||
| message ThresholdRule { | ||||||
| string scheme = 1; // The scheme for signature verification. | ||||||
| bytes public_key = 2; // The public key for signature verification. | ||||||
| } | ||||||
|  | ||||||
|  | @@ -78,7 +127,7 @@ message NamespacePolicies { | |||||
|  | ||||||
| message PolicyItem { | ||||||
| string namespace = 1; | ||||||
| bytes policy = 2; | ||||||
| bytes policy = 2; // This holds the complete NamespacePolicy. | ||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: Originally, I used  | ||||||
| uint64 version = 3; | ||||||
| } | ||||||
|  | ||||||
|  | ||||||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -13,6 +13,7 @@ import ( | |
|  | ||
| "github.com/onsi/gomega" | ||
| "github.com/stretchr/testify/require" | ||
| "google.golang.org/protobuf/proto" | ||
|  | ||
| "github.com/hyperledger/fabric-x-committer/api/protoblocktx" | ||
| "github.com/hyperledger/fabric-x-committer/api/protoloadgen" | ||
|  | @@ -87,11 +88,13 @@ func TestConfigUpdate(t *testing.T) { | |
|  | ||
| c.AddOrUpdateNamespaces(t, types.MetaNamespaceID) | ||
| metaPolicy := c.TxBuilder.TxSigner.HashSigners[types.MetaNamespaceID].GetVerificationPolicy() | ||
| key := &protoblocktx.ThresholdRule{} | ||
| require.NoError(t, proto.Unmarshal(metaPolicy.Policy, key)) | ||
| submitConfigBlock := func(endpoints []*ordererconn.Endpoint) { | ||
| ordererEnv.SubmitConfigBlock(t, &workload.ConfigBlock{ | ||
| ChannelID: c.SystemConfig.Policy.ChannelID, | ||
| OrdererEndpoints: endpoints, | ||
| MetaNamespaceVerificationKey: metaPolicy.PublicKey, | ||
| MetaNamespaceVerificationKey: key.PublicKey, | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What additional changes are needed to remove the need for the  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the  | ||
| }) | ||
| } | ||
| submitConfigBlock(ordererEnv.AllRealOrdererEndpoints()) | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: Is this field necessary? Can't we infer the MSP from the certificate's issuing CA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field is part of Fabric. It is included in the identity. Hence, I have replicated the same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found only one reference to this field in
utils/signature/verify.go:The question is, can we infer the MSP ID from
s.Identity.GetCertificate()? Then pass it toNewSerializedIdentity().Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may infer the MSP ID from the
Subject: CN=peer0.org1.example.com, OU=peer, O=Hyperledger, ST=North Carolina, C=USin the certificate. I will create an issue to check this later and use the Fabric way for now till we complete the whole feature.Note that the endorser would fill this Identity field.