getFile Error: Decryption failed: failure in MAC check

tried getting a file from another user but got “Error: Decryption failed: failure in MAC check”
I have already added the publish_data scope but not sure why is it still failing?

Anyway I can get more verbose log?

You’re probably using the wrong private key to decrypt. cc @aaron

I am testing with 2 accounts.
I noticed that the appPrivateKey that is returned is different from each other.

Is it supposed to be so?
I am still very unclear how this multiplayer storage thing works.

Yes – each account will have a separate app private key. The app private key is a BIP32-derived key derived from your seed phrase, the name you’re signing in as, and the application’s Origin.

thanks…that mean’s it’s the user’s private key for that app.
I was wondering before that why the app’s private key was exposed in loadUserData()

In that case, since I won’t be keeping track of each user’s app private key at the backend, I will not encrypt any data at all.

I was wondering before that why the app’s private key was exposed in loadUserData()

The app private key is generated by the Blockstack browser on sign-in, and passed to the app on sign-in completion. It gets stored to local storage so it can be retrieved with loadUserData().

I think there’s a common pitfall with multi-player reads in blockstack.js

putFile and getFile set the encrypt and decrypt values to true — meaning that they usually encrypt and decrypt with the current user’s private key. If you try to use those with multi-player reads, you’ll get these kinds of errors.

Instead, you want to at first disable encryption for any multi-player reads, and then add back in encryption once you have a way to share public keys between users in your app:

USERA:       putFile('foo', 'foo.txt', {encrypt: false})
USERB:       getFile('foo.txt', { username: 'USERA', decrypt: false } )

The example application here shows how to load other user’s information in app: