-
Notifications
You must be signed in to change notification settings - Fork 64
Enhanced redeem with the signature of the issuer #1027
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
Conversation
@go install github.com/IBM/idemix/tools/idemixgen |
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 think you will need a specific version here. the problem is that the dependency sometimes is updated because of other dependencies during a go mod. then you have to reset it back to that specific version needed.
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 line stayed as-is and out of the scope of this PR
integration/ports.go
Outdated
@@ -60,8 +60,8 @@ var ( | |||
|
|||
AllTestTypes = []*InfrastructureType{ | |||
WebSocketNoReplication, | |||
LibP2PNoReplication, | |||
WebSocketWithReplication, | |||
//LibP2PNoReplication, |
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.
not to forget
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.
done
@aaadir I implemented the fabotken + zkat logic, fixed the failing unit-tests and most of the integration tests.. what is left is integration tests related to "Auditor as an Issuer" cases |
a82122f
to
c8be372
Compare
c8be372
to
ae792c2
Compare
52176fb
to
967ed7e
Compare
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]>
Signed-off-by: bar haim <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: bar haim <[email protected]> Signed-off-by: Allon Adir <[email protected]>
to pass the Issuer network identity. This allows the developer to avoid to call SetBinding Signed-off-by: Angelo De Caro <[email protected]> Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: Allon Adir <[email protected]>
…hByID Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: Allon Adir <[email protected]>
Signed-off-by: Allon Adir <[email protected]>
d30b1d7
to
9aa7a05
Compare
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.
LGTM overall modulo the requested changes. Thanks
@@ -255,6 +255,7 @@ func TestTransferAction_Serialization(t *testing.T) { | |||
Metadata: map[string][]byte{ | |||
"metadata": []byte("{\"foo\":\"bar\"}"), | |||
}, | |||
Issuer: nil, |
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.
Please, a value different from nil to make sure the serialization works as expected.
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.
The Issuer field should be nil for non-Redeem transactions.
For redeem it will be populated to the issuer's-PK inside the action.Serialize() that follows immediately after this line.
This is why the Redeem test also works for the ZK driver.
@@ -164,6 +167,11 @@ func (t *TransferAction) GetMetadata() map[string][]byte { | |||
return t.Metadata | |||
} | |||
|
|||
// GetIssuer returns the issuer to sign the transaction | |||
func (t *TransferAction) GetIssuer() driver.Identity { |
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.
Please, add a unit-test for this function.
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.
Added TestTransferAction_GetIssuer to token/core/fabtoken/v1/actions/transfer_test.go
done.
@@ -10,6 +10,7 @@ import ( | |||
"testing" | |||
|
|||
"github.com/hyperledger-labs/fabric-token-sdk/token/driver" | |||
|
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.
remove this line
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.
done
token/core/fabtoken/v1/transfer.go
Outdated
@@ -46,6 +46,7 @@ func NewTransferService( | |||
// Transfer returns a TransferAction as a function of the passed arguments | |||
// It also returns the corresponding TransferMetadata | |||
func (s *TransferService) Transfer(ctx context.Context, _ string, _ driver.OwnerWallet, tokenIDs []*token.ID, Outputs []*token.Token, opts *driver.TransferOptions) (driver.TransferAction, *driver.TransferMetadata, error) { | |||
var isRedeem bool |
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.
please, move this declaration closer to where it is needed.
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.
it's indeed needed much later, but it's set in the iteration over the outputs here below. But I moved the var declaration to right before this iteration.
done.
@@ -30,6 +30,7 @@ func TransferSignatureValidate(ctx *Context) error { | |||
return errors.Errorf("invalid number of token inputs, expected at least 1") | |||
} | |||
|
|||
var isRedeem bool |
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.
please, move this declaration closer to where it is needed.
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.
done.
@@ -243,6 +247,11 @@ func (t *Action) GetMetadata() map[string][]byte { | |||
return t.Metadata | |||
} | |||
|
|||
// GetIssuer returns the issuer to sign the transaction | |||
func (t *Action) GetIssuer() driver.Identity { |
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.
please, add a unit-tests for this function.
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.
done
@@ -313,6 +322,13 @@ func (t *Action) Serialize() ([]byte, error) { | |||
return nil, errors.Wrap(err, "failed to serialize outputs") | |||
} | |||
|
|||
var issuer *pp.Identity |
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.
please, update TestAction_Validate to check also the added code.
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.
TestAction_Validate doesn't really check the updated Serialize code, just runs action.Validate().
But I added an issuer to the action anyway, to see that Validate works.
Serialize is actually tested in another test here (TestSerialization) so I also updated it (by creating an issuer in randomAction).
done.
} | ||
|
||
if isRedeem { | ||
ctx.Logger.Infof("action is a redeem, verify the signature of the issuer") |
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.
please, use Debugf
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.
done.
(what is the general rule for when to use Infof vs. Debugf?)
@@ -373,6 +373,8 @@ type TransferMetadata struct { | |||
// ExtraSigners is the list of extra identities that are not part of the transfer action per se | |||
// but needs to sign the request | |||
ExtraSigners []Identity | |||
// Issuer contains the identity of the issuer to sign the transfer action | |||
Issuer Identity |
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.
please, update TestTokenRequestMetadataSerialization, to include also this field
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.
done
IssuerFSCIdentityKey = "IssuerFSCIdentityKey" | ||
) | ||
|
||
func WithFSCIssuerIdentity(issuerFSCIdentity view.Identity) token.TransferOption { |
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.
please, add comments to these two functions
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.
done
Signed-off-by: Allon Adir <[email protected]>
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.
LGTM
No description provided.