blob: f7105775c5bedd3c40a539fb05fbe21f793fa34f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
const { describe, it } = require('mocha');
const { expect } = require('chai');
const { SodiumPlus, X25519SecretKey, X25519PublicKey } = require('../index');
let sodium;
describe('Backend', () => {
it('crypto_box_keypair_from_secretkey_and_publickey', async function () {
if (!sodium) sodium = await SodiumPlus.auto();
let a = Buffer.alloc(32);
let b = Buffer.alloc(32);
let c = Buffer.alloc(31);
let d = await sodium.crypto_box_keypair_from_secretkey_and_publickey(
new X25519SecretKey(a),
new X25519PublicKey(b)
);
expect(64).to.be.equal(d.buffer.length);
expect(() => {
sodium.crypto_box_keypair_from_secretkey_and_publickey(
new X25519SecretKey(c),
new X25519PublicKey(b)
)
.then(() => {})
.catch((e) => { throw e });
}).to.throw('X25519 secret keys must be 32 bytes long');
expect(() => {
sodium.crypto_box_keypair_from_secretkey_and_publickey(
new X25519SecretKey(a),
new X25519PublicKey(c)
)
.then(() => {})
.catch((e) => { throw e });
}).to.throw('X25519 public keys must be 32 bytes long');
});
});
|