From 7bb6d28b64ee63a9dac4a30dd3074524e5bf59d5 Mon Sep 17 00:00:00 2001 From: Shota Jolbordi Date: Fri, 21 Jun 2024 19:17:07 +0400 Subject: [PATCH 1/3] strip leading zero in Ecdsa256k1singnature2019 proof generation for jwd Signed-off-by: Shota Jolbordi --- .../org/hyperledger/identus/pollux/vc/jwt/Proof.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/Proof.scala b/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/Proof.scala index 47c91132fb..0ee6ffebbf 100644 --- a/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/Proof.scala +++ b/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/Proof.scala @@ -51,6 +51,9 @@ object Proof { } object EcdsaSecp256k1Signature2019ProofGenerator { + private def stripLeadingZero(arr: Array[Byte]): Array[Byte] = { + if (arr.length == 33 && arr.head == 0) then arr.tail else arr + } def generateProof(payload: Json, signer: ECDSASigner, pk: ECPublicKey): Task[EcdsaSecp256k1Signature2019Proof] = { for { dataToSign <- ZIO.fromEither(JsonUtils.canonicalizeJsonLDoRdf(payload.spaces2)) @@ -63,8 +66,8 @@ object EcdsaSecp256k1Signature2019ProofGenerator { jwsObject = JWSObject(header, payload) _ = jwsObject.sign(signer) jws = jwsObject.serialize(true) - x = pk.getW.getAffineX.toByteArray - y = pk.getW.getAffineY.toByteArray + x = stripLeadingZero(pk.getW.getAffineX.toByteArray) + y = stripLeadingZero(pk.getW.getAffineY.toByteArray) jwk = JsonWebKey( kty = "EC", crv = Some("secp256k1"), From 739a1eb678e713f8d512cc465e520ccdabda14cf Mon Sep 17 00:00:00 2001 From: Shota Jolbordi Date: Fri, 21 Jun 2024 19:27:28 +0400 Subject: [PATCH 2/3] Undo flaky test supression Signed-off-by: Shota Jolbordi --- .../features/proofs/present_proof.feature | 2 -- .../revocation/revoke_jwt_credential.feature | 8 ++++---- .../src/tests/flows/present-proof-flow-test.ts | 14 +++++++------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/integration-tests/src/test/resources/features/proofs/present_proof.feature b/tests/integration-tests/src/test/resources/features/proofs/present_proof.feature index e1e8828a17..f19b73090d 100644 --- a/tests/integration-tests/src/test/resources/features/proofs/present_proof.feature +++ b/tests/integration-tests/src/test/resources/features/proofs/present_proof.feature @@ -1,7 +1,6 @@ @proof @jwt Feature: Present Proof Protocol - @flaky Scenario: Holder presents credential proof to verifier Given Verifier and Holder have an existing connection And Holder has an issued credential from Issuer @@ -18,7 +17,6 @@ Feature: Present Proof Protocol And Holder rejects the proof Then Holder sees the proof is rejected - @flaky Scenario: Holder presents proof to verifier which is the issuer itself Given Issuer and Holder have an existing connection And Holder has an issued credential from Issuer diff --git a/tests/integration-tests/src/test/resources/features/revocation/revoke_jwt_credential.feature b/tests/integration-tests/src/test/resources/features/revocation/revoke_jwt_credential.feature index b804d8554e..2ac02f447b 100644 --- a/tests/integration-tests/src/test/resources/features/revocation/revoke_jwt_credential.feature +++ b/tests/integration-tests/src/test/resources/features/revocation/revoke_jwt_credential.feature @@ -1,4 +1,4 @@ -@revocation @jwt @flaky +@revocation @jwt Feature: Credential revocation - JWT Background: @@ -10,12 +10,12 @@ Feature: Credential revocation - JWT When Issuer sends a request for proof presentation to Holder And Holder receives the request And Holder makes the presentation of the proof to Issuer -# Then Issuer sees the proof returned verification failed + Then Issuer sees the proof returned verification failed Scenario: Holder tries to revoke credential from issuer When Holder tries to revoke credential from Issuer And Issuer sends a request for proof presentation to Holder And Holder receives the request And Holder makes the presentation of the proof to Issuer -# Then Issuer has the proof verified -# And Issuer should see the credential is not revoked + Then Issuer has the proof verified + And Issuer should see the credential is not revoked diff --git a/tests/performance-tests/agent-performance-tests-k6/src/tests/flows/present-proof-flow-test.ts b/tests/performance-tests/agent-performance-tests-k6/src/tests/flows/present-proof-flow-test.ts index e1c0ed1d32..09c7dfeee6 100644 --- a/tests/performance-tests/agent-performance-tests-k6/src/tests/flows/present-proof-flow-test.ts +++ b/tests/performance-tests/agent-performance-tests-k6/src/tests/flows/present-proof-flow-test.ts @@ -76,11 +76,11 @@ export default (data: { verifier.finalizeConnectionWithHolder() holder.finalizeConnectionWithVerifier() }) - // && - // - // describe("Verifier requests proof from Holder", function () { - // verifier.requestProof(); - // holder.waitAndAcceptProofRequest(verifier.presentation!.thid); - // verifier.acknowledgeProof(); - // }); + && + + describe("Verifier requests proof from Holder", function () { + verifier.requestProof(); + holder.waitAndAcceptProofRequest(verifier.presentation!.thid); + verifier.acknowledgeProof(); + }); } From 35cd986856bf9f0587ed55a6cde605b77f95ecab Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2024 19:38:20 +0400 Subject: [PATCH 3/3] style: apply linters automatic fixes (#1216) Signed-off-by: Hyperledger Bot Co-authored-by: Hyperledger Bot --- .../src/tests/flows/present-proof-flow-test.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/performance-tests/agent-performance-tests-k6/src/tests/flows/present-proof-flow-test.ts b/tests/performance-tests/agent-performance-tests-k6/src/tests/flows/present-proof-flow-test.ts index 09c7dfeee6..4d733540ff 100644 --- a/tests/performance-tests/agent-performance-tests-k6/src/tests/flows/present-proof-flow-test.ts +++ b/tests/performance-tests/agent-performance-tests-k6/src/tests/flows/present-proof-flow-test.ts @@ -75,12 +75,11 @@ export default (data: { holder.acceptVerifierConnection(verifier.connectionWithHolder!.invitation) verifier.finalizeConnectionWithHolder() holder.finalizeConnectionWithVerifier() - }) - && + }) && - describe("Verifier requests proof from Holder", function () { - verifier.requestProof(); - holder.waitAndAcceptProofRequest(verifier.presentation!.thid); - verifier.acknowledgeProof(); - }); + describe('Verifier requests proof from Holder', function () { + verifier.requestProof() + holder.waitAndAcceptProofRequest(verifier.presentation!.thid) + verifier.acknowledgeProof() + }) }