Fixed bug in channel hash calculation and decryption
This commit is contained in:
@@ -112,18 +112,12 @@ describe("PrivateKey", () => {
|
||||
});
|
||||
|
||||
describe("SharedSecret", () => {
|
||||
const secret = randomBytes(32);
|
||||
const secret = randomBytes(16);
|
||||
|
||||
it("constructs from 32 bytes", () => {
|
||||
it("constructs from 16 bytes", () => {
|
||||
const ss = new SharedSecret(secret);
|
||||
expect(ss.toBytes()).toEqual(secret);
|
||||
});
|
||||
|
||||
it("pads if 16 bytes", () => {
|
||||
const short = randomBytes(16);
|
||||
const ss = new SharedSecret(short);
|
||||
expect(ss.toBytes().length).toBe(32);
|
||||
expect(Array.from(ss.toBytes()).slice(16)).toEqual(Array.from(short));
|
||||
expect(ss.toBytes().length).toBe(16);
|
||||
expect(bytesToHex(ss.toBytes())).toBe(bytesToHex(secret));
|
||||
});
|
||||
|
||||
it("throws on invalid length", () => {
|
||||
@@ -163,6 +157,9 @@ describe("SharedSecret", () => {
|
||||
it('fromName "Public"', () => {
|
||||
const ss = SharedSecret.fromName("Public");
|
||||
expect(ss).toBeInstanceOf(SharedSecret);
|
||||
const hash = ss.toHash();
|
||||
expect(typeof hash).toBe("number");
|
||||
expect(hash).toBe(0x11);
|
||||
});
|
||||
|
||||
it("fromName with #group", () => {
|
||||
|
||||
Reference in New Issue
Block a user