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
In bifold, when two different wallets send messages to each other they use pack and unpack functions for encrypting and decrypting the messages. However, In addition, I am trying to sign message and verify their signature also. For this the approach, e.g. Alice will sign message using his private_key and Bob will verify it using Alice's public_key.
I created a function through which I am trying to sign a message using Alice's private key and then trying to verify it. I tried to sign it and it gives me buffer as response too. However, when I try to verify the signature it gives me error. For testing the sign and verify I created a functions which I am providing below:
Note: Here, for testing only, I am just using the publicKeyBase58 from await agent?.dids.resolveDidDocument(respGetById?.did) . But in future, of course I will use respGetById.theirDid for verifying signature.
constsignAndVerify=async(textMessage,connectionId)=>{constrespGetById=awaitagent?.connections.getById(connectionId)constdidDocData=awaitagent?.dids.resolveDidDocument(respGetById?.did)constpublicKeyBase58=didDocData?.verificationMethod[0].publicKeyBase58constbufferPubKey=TypedArrayEncoder.fromString(publicKeyBase58);// preparing params for signing constkey={publicKeyBase58: publicKeyBase58,keyType: KeyType.Ed25519}constbufferMessage=TypedArrayEncoder.fromString(textMessage);constsignParams: WalletSignOptions={data: bufferMessage, key }console.log("----------------- TEST: Signing... -----------------")constmessageSignature=awaitagent?.context.wallet.sign(signParams)console.log(messageSignature)// Preparing params for veryfingkey.publicKey=bufferPubKeyconstverifyParams={data: bufferMessage,key: key,signature: messageSignature}console.log("================= TEST: veryfing ================")constisSignValid=awaitagent?.context.wallet.verify(verifyParams)/* This above verify func call gives error ==> WARN Possible Unhandled Promise Rejection (id: 11): [WalletError: Error verifying signature of data signed with verkey H5pt8hB33Jnn6Bp141sj2Xt4P8hgqFpes9MMB5QCoRcS] */returnisSignValid}
FYI
I am testing this code from Chat.tsx
The sample code of verify and sign function can be found in "AskarBaseWallet.js" and "AskarWallet.js" within the @aries-framework of node_modules.
One observation is, to verify signature, we need to pass one additional property "publicKey" and if we use any data format other than buffer, uint8array, or don't pass this property, then the app crashes.
The text was updated successfully, but these errors were encountered:
Scenario:
In bifold, when two different wallets send messages to each other they use pack and unpack functions for encrypting and decrypting the messages. However, In addition, I am trying to sign message and verify their signature also. For this the approach, e.g. Alice will sign message using his private_key and Bob will verify it using Alice's public_key.
I created a function through which I am trying to sign a message using Alice's private key and then trying to verify it. I tried to sign it and it gives me buffer as response too. However, when I try to verify the signature it gives me error. For testing the sign and verify I created a functions which I am providing below:
Note: Here, for testing only, I am just using the publicKeyBase58 from
await agent?.dids.resolveDidDocument(respGetById?.did)
. But in future, of course I will userespGetById.theirDid
for verifying signature.FYI
verify
andsign
function can be found in "AskarBaseWallet.js" and "AskarWallet.js" within the @aries-framework of node_modules.The text was updated successfully, but these errors were encountered: