joinself / self-crypto-node

A self crypto library for nodejs
MIT License
0 stars 0 forks source link

aliceAccount to create_inbound_session #2

Closed adriacidre closed 3 years ago

adriacidre commented 3 years ago

@purehyperbole can you check this change? comparing this encrypt/decrypt test with with the sdk implementation I think

var sessionWithAlice = crypto.create_inbound_session(aliceAccount, ciphertextForBob)

should be based on alice's account instead of bob's. Am I missing something?

purehyperbole commented 3 years ago

@adriacidre yep, that's a mistake, well spotted. It should be bobAccount

adriacidre commented 3 years ago

Cool @purehyperbole, in that case that test will expose the problem we're facing on encryption with SDK implementation.

Running this test you'll get:

  var sessionWithAlice = crypto.create_inbound_session(aliceAccount, ciphertextForBob)
                                ^

Error: BAD_MESSAGE_KEY_ID
    at Test.<anonymous> (/Users/adriancidrejugo/go/src/github.com/joinself/self-crypto-node/tests/omemo.js:32:33)
    at Test.bound [as _cb] (/Users/adriancidrejugo/go/src/github.com/joinself/self-crypto-node/node_modules/tape/lib/test.js:90:32)
    at Test.run (/Users/adriancidrejugo/go/src/github.com/joinself/self-crypto-node/node_modules/tape/lib/test.js:107:31)
    at Test.bound [as run] (/Users/adriancidrejugo/go/src/github.com/joinself/self-crypto-node/node_modules/tape/lib/test.js:90:32)
    at Immediate.next (/Users/adriancidrejugo/go/src/github.com/joinself/self-crypto-node/node_modules/tape/lib/results.js:89:19)
    at processImmediate (internal/timers.js:456:21) {
  code: 'ERROR'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Which is the error we're getting on the sdk implementation.

purehyperbole commented 3 years ago

@adriacidre my mistake, it was correct before. It should be based on no account. You are creating an inbound session from a message sent for Alice intended for Bob. So we need to use bobs account