Skip to content

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

Merged
merged 26 commits into from
Apr 24, 2025
Merged

Conversation

barvhaim
Copy link
Contributor

No description provided.

@go install github.com/IBM/idemix/tools/idemixgen
Copy link
Contributor

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.

Copy link
Contributor Author

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

@@ -60,8 +60,8 @@ var (

AllTestTypes = []*InfrastructureType{
WebSocketNoReplication,
LibP2PNoReplication,
WebSocketWithReplication,
//LibP2PNoReplication,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not to forget

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@barvhaim
Copy link
Contributor Author

barvhaim commented Apr 8, 2025

@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

@aaadir aaadir force-pushed the f-904-issuer-action branch from a82122f to c8be372 Compare April 17, 2025 03:55
@adecaro adecaro force-pushed the f-904-issuer-action branch from c8be372 to ae792c2 Compare April 17, 2025 04:39
@aaadir aaadir force-pushed the f-904-issuer-action branch 2 times, most recently from 52176fb to 967ed7e Compare April 22, 2025 09:55
@aaadir aaadir changed the title Redeem: issuer in action for Fabtoken WIP Enhanced redeem with the signature of the issuer Apr 23, 2025
barvhaim and others added 22 commits April 23, 2025 10:30
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: 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]>
@aaadir aaadir force-pushed the f-904-issuer-action branch from d30b1d7 to 9aa7a05 Compare April 23, 2025 07:32
@adecaro adecaro self-assigned this Apr 23, 2025
@adecaro adecaro added the enhancement New feature or request label Apr 23, 2025
@adecaro adecaro marked this pull request as ready for review April 23, 2025 08:08
@adecaro adecaro self-requested a review April 23, 2025 08:08
Copy link
Contributor

@adecaro adecaro left a 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,
Copy link
Contributor

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.

Copy link
Contributor

@aaadir aaadir Apr 23, 2025

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 {
Copy link
Contributor

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.

Copy link
Contributor

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"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -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
Copy link
Contributor

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.

Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

@aaadir aaadir Apr 23, 2025

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 {
Copy link
Contributor

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.

Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, use Debugf here

Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor

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]>
Copy link
Contributor

@adecaro adecaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aaadir aaadir merged commit f28fe70 into main Apr 24, 2025
55 checks passed
@aaadir aaadir deleted the f-904-issuer-action branch April 24, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment