You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This method assumes that CollectionID is sufficient to uniquely identify a CollectionGuarantee. While this approach is simple, it introduces potential malleability concerns. The identifier computation currently only considers the CollectionID field, leaving out important fields like:
ReferenceBlockID,
ChainID,
SignerIndices,
Signature
This omission means that two CollectionGuarantee instances with the same CollectionID but differing values for these fields would produce the same identifier, which is incorrect.
Proposed Solution
Separate mutable and immutable fields:
Create a CollectionGuaranteeBody struct containing the immutable fields:
CollectionID
ReferenceBlockID,
ChainID.
Implement ID() for CollectionGuaranteeBody:
Use the MakeID() function to compute the identifier for CollectionGuaranteeBody. All fields will be encoded consistently:
Primitive and byte array fields (CollectionID, ReferenceBlockID, ChainID) are encoded directly as raw bytes using RLP (encoding RLP rules).
Update theCollectionGuarantee struct:
Include the CollectionGuaranteeBody struct within CollectionGuarantee.
type CollectionGuarantee struct {
Body CollectionGuaranteeBody
SignerIndices []byte // encoded indices of the signers
Signature crypto.Signature // guarantor signatures
}
Update ID() for CollectionGuarantee:
The ID() method will compute the identifier based on the entire CollectionGuarantee struct using MakeID().
By encoding all fields, this approach guarantees that the resulting ID is malleability-resistant. Changes to any field of CollectionGuarantee will produce a different Identifier.
Remove unused function: The unused Checksum() function will be removed.
Potential problems
During the signing process of CollectionGuarantee : The Signature field is mutable and should not contribute to the signature. Only the immutable fields (CollectionID, ReferenceBlockID, ChainID) should be signed. The Signature forCollectionGuarantee is not implemented yet, but in case that it will be implemented, CollectionGuarantee struct will require refactoring to separate mutable and immutable fields (this refactoring is already described in 1- 4). Such a change would simplify the process of signing the CollectionGuarantee.
Definition of Done
The CollectionGuaranteeBody has been created and CollectionGuaranteeBody.ID() method has been implemented.
The CollectionGuarantee.ID() method has been updated using MakeID.
The unused Checksum() functions has been removed.
Unit tests have been updated to validate the new behavior, ensuring identifiers change as expected when data is modified.
Documentation and comments have been updated to reflect the changes and clarify the purpose of the ID() method.
The text was updated successfully, but these errors were encountered:
CollectionGuarantee Malleability
flow-go/model/flow/collectionGuarantee.go
Lines 7 to 15 in edf27b0
The current
CollectionGuarantee
implementation uses theID()
method to return theCollectionID
as the unique identifier:flow-go/model/flow/collectionGuarantee.go
Lines 18 to 20 in edf27b0
This method assumes that
CollectionID
is sufficient to uniquely identify aCollectionGuarantee
. While this approach is simple, it introduces potential malleability concerns. The identifier computation currently only considers theCollectionID
field, leaving out important fields like:ReferenceBlockID
,ChainID
,SignerIndices
,Signature
This omission means that two
CollectionGuarantee
instances with the sameCollectionID
but differing values for these fields would produce the same identifier, which is incorrect.Proposed Solution
Create a
CollectionGuaranteeBody
struct containing the immutable fields:CollectionID
ReferenceBlockID
,ChainID
.ID()
forCollectionGuaranteeBody
:Use the
MakeID()
function to compute the identifier for CollectionGuaranteeBody. All fields will be encoded consistently:CollectionID
,ReferenceBlockID
,ChainID
) are encoded directly as raw bytes usingRLP
(encoding RLP rules).CollectionGuarantee
struct:Include the
CollectionGuaranteeBody
struct withinCollectionGuarantee
.ID()
forCollectionGuarantee:
The
ID()
method will compute the identifier based on the entireCollectionGuarantee
struct usingMakeID()
.By encoding all fields, this approach guarantees that the resulting ID is malleability-resistant. Changes to any field of
CollectionGuarantee
will produce a differentIdentifier
.Checksum()
function will be removed.Potential problems
CollectionGuarantee
: TheSignature
field is mutable and should not contribute to the signature. Only the immutable fields (CollectionID
,ReferenceBlockID
,ChainID
) should be signed. TheSignature
forCollectionGuarantee
is not implemented yet, but in case that it will be implemented,CollectionGuarantee
struct will require refactoring to separate mutable and immutable fields (this refactoring is already described in 1- 4). Such a change would simplify the process of signing theCollectionGuarantee
.Definition of Done
CollectionGuaranteeBody
has been created andCollectionGuaranteeBody.ID()
method has been implemented.CollectionGuarantee.ID()
method has been updated usingMakeID
.Checksum()
functions has been removed.ID()
method.The text was updated successfully, but these errors were encountered: