How to use the pvtsutils.isEqual function in pvtsutils

To help you get started, we’ve selected a few pvtsutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PeculiarVentures / 2key-ratchet / test / encryption.ts View on Github external
it("wrong order", async () => {
        const ciphers = await createCiphers();
        const { Alice, Bob } = ciphers;

        const AliceMsg1 = await Alice.encrypt(MESSAGE) as MessageSignedProtocol; // slow message
        await dialog(Alice, Bob, 5);
        assert.isTrue(isEqual(await Bob.decrypt(AliceMsg1), MESSAGE));
        await dialog(Alice, Bob, 5);
    });
github PeculiarVentures / 2key-ratchet / test / protocol.ts View on Github external
it("import/export", async () => {
            const identity = await createIdentity(1);
            const identityProto = await IdentityProtocol.fill(identity);
            const identityBuf = await identityProto.exportProto();
            const identityProto2 = await IdentityProtocol.importProto(identityBuf);
            assert.equal(identityProto.signingKey.id, identityProto2.signingKey.id);
            assert.equal(identityProto.exchangeKey.id, identityProto2.exchangeKey.id);
            assert.isTrue(isEqual(identityProto.signature, identityProto2.signature));
        });
github PeculiarVentures / 2key-ratchet / test / data.ts View on Github external
it("toJSON/fromJSON", async () => {
            const res = await createIdentity(1);
            const identity = await IdentityProtocol.fill(res);
            const remote = await RemoteIdentity.fill(identity);
            const json = await remote.toJSON();
            const remote2 = await RemoteIdentity.fromJSON(json);

            assert.equal(remote.createdAt.toString(), remote2.createdAt.toString());
            assert.equal(remote.signingKey.id, remote2.signingKey.id);
            assert.equal(remote.exchangeKey.id, remote2.exchangeKey.id);
            assert.isTrue(isEqual(remote.signature, remote2.signature));
            assert.equal(remote.id, remote2.id);
        });
github PeculiarVentures / 2key-ratchet / test / protocol.ts View on Github external
it("import/export", async () => {
            const preKeySigned = new PreKeySignedProtocol();
            let preKeySigned2: PreKeySignedProtocol;
            const identity = await createIdentity(1);
            preKeySigned.id = identity.id;
            preKeySigned.key = identity.signingKey.publicKey;
            await preKeySigned.sign(identity.signingKey.privateKey);
            const protocol = await preKeySigned.exportProto();
            const preKey = await PreKeySignedProtocol.importProto(protocol);

            preKeySigned2 = preKey;
            isEqual(preKeySigned.signature, preKeySigned2.signature);
            const ok = await preKeySigned2.verify(identity.signingKey.publicKey);
            assert.isTrue(ok);
        });
github PeculiarVentures / 2key-ratchet / test / encryption.ts View on Github external
async function createCiphers() {
    const AliceID = await createIdentity(1);
    const BobID = await createIdentity(2);
    const AlicePreKeyBundle = await createPreKeyBundle(AliceID);

    const BobRatchet = await AsymmetricRatchet.create(BobID, AlicePreKeyBundle);
    const HelloMessage = await BobRatchet.encrypt(MESSAGE) as PreKeyMessageProtocol;
    const AliceRatchet = await AsymmetricRatchet.create(AliceID, HelloMessage);
    const decrypted = await AliceRatchet.decrypt(HelloMessage.signedMessage);
    assert.isTrue(isEqual(decrypted, MESSAGE));
    return { Alice: AliceRatchet, Bob: BobRatchet };
}
github PeculiarVentures / 2key-ratchet / test / encryption.ts View on Github external
async function sendMessage(fromCipher: AsymmetricRatchet, toCipher: AsymmetricRatchet) {
    const message = await fromCipher.encrypt(MESSAGE) as MessageSignedProtocol;
    assert.isTrue(isEqual(await toCipher.decrypt(message), MESSAGE));
}
github PeculiarVentures / 2key-ratchet / src / crypto / public_key.ts View on Github external
public async isEqual(other: any) {
        if (!(other && other instanceof ECPublicKey)) { return false; }

        return isEqual(this.serialized, other.serialized);
    }
github PeculiarVentures / 2key-ratchet / src / protocol / message_signed.ts View on Github external
public async verify(hmacKey: CryptoKey) {
        const signature = await this.signHMAC(hmacKey);
        return utils.isEqual(signature, this.signature);
    }