mirror of
https://github.com/logos-messaging/js-noise.git
synced 2026-01-05 07:03:08 +00:00
fix: add missing .js suffix in imports
This commit is contained in:
parent
b60bc1af1e
commit
4c219c031a
@ -38,6 +38,7 @@
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"moduleResolution": "node16",
|
||||
"license": "Apache-2.0 OR MIT",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
|
||||
@ -3,8 +3,8 @@ import { proto_message } from "js-waku";
|
||||
import { Decoder, Encoder, Message, ProtoMessage } from "js-waku/lib/interfaces";
|
||||
import { MessageV0 } from "js-waku/lib/waku_message/version_0";
|
||||
|
||||
import { HandshakeResult, HandshakeStepResult } from "./handshake";
|
||||
import { PayloadV2 } from "./payload";
|
||||
import { HandshakeResult, HandshakeStepResult } from "./handshake.js";
|
||||
import { PayloadV2 } from "./payload.js";
|
||||
|
||||
const log = debug("waku:message:noise-encoder");
|
||||
|
||||
|
||||
@ -4,12 +4,12 @@ import { equals as uint8ArrayEquals } from "uint8arrays/equals";
|
||||
|
||||
import { bytes32 } from "./@types/basic";
|
||||
import { KeyPair } from "./@types/keypair";
|
||||
import { getHKDFRaw } from "./crypto";
|
||||
import { HandshakeState, NoisePaddingBlockSize } from "./handshake_state";
|
||||
import { CipherState } from "./noise";
|
||||
import { HandshakePattern, PayloadV2ProtocolIDs } from "./patterns";
|
||||
import { MessageNametagBuffer, PayloadV2, toMessageNametag } from "./payload";
|
||||
import { NoisePublicKey } from "./publickey";
|
||||
import { getHKDFRaw } from "./crypto.js";
|
||||
import { HandshakeState, NoisePaddingBlockSize } from "./handshake_state.js";
|
||||
import { CipherState } from "./noise.js";
|
||||
import { HandshakePattern, PayloadV2ProtocolIDs } from "./patterns.js";
|
||||
import { MessageNametagBuffer, PayloadV2, toMessageNametag } from "./payload.js";
|
||||
import { NoisePublicKey } from "./publickey.js";
|
||||
|
||||
// Noise state machine
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ import { MessageNametag } from "./@types/handshake.js";
|
||||
import type { KeyPair } from "./@types/keypair.js";
|
||||
import { Curve25519KeySize, dh, generateX25519KeyPair, getHKDF, intoCurve25519Key } from "./crypto.js";
|
||||
import { SymmetricState } from "./noise.js";
|
||||
import { EmptyPreMessage, HandshakePattern, MessageDirection, NoiseTokens, PreMessagePattern } from "./patterns";
|
||||
import { EmptyPreMessage, HandshakePattern, MessageDirection, NoiseTokens, PreMessagePattern } from "./patterns.js";
|
||||
import { NoisePublicKey } from "./publickey.js";
|
||||
|
||||
// The padding blocksize of a transport message
|
||||
@ -208,7 +208,7 @@ export class HandshakeState {
|
||||
|
||||
// If user is reading the "e" token
|
||||
if (reading) {
|
||||
console.trace("noise pre-message read e");
|
||||
console.debug("noise pre-message read e");
|
||||
|
||||
// We check if current key is encrypted or not. We assume pre-message public keys are all unencrypted on users' end
|
||||
if (currPK.flag == 0) {
|
||||
@ -220,7 +220,7 @@ export class HandshakeState {
|
||||
}
|
||||
// If user is writing the "e" token
|
||||
} else if (writing) {
|
||||
console.trace("noise pre-message write e");
|
||||
console.debug("noise pre-message write e");
|
||||
|
||||
// When writing, the user is sending a public key,
|
||||
// We check that the public part corresponds to the set local key and we call MixHash(e.public_key).
|
||||
@ -252,7 +252,7 @@ export class HandshakeState {
|
||||
|
||||
// If user is reading the "s" token
|
||||
if (reading) {
|
||||
console.trace("noise pre-message read s");
|
||||
console.debug("noise pre-message read s");
|
||||
|
||||
// We check if current key is encrypted or not. We assume pre-message public keys are all unencrypted on users' end
|
||||
if (currPK.flag == 0) {
|
||||
@ -265,7 +265,7 @@ export class HandshakeState {
|
||||
|
||||
// If user is writing the "s" token
|
||||
} else if (writing) {
|
||||
console.trace("noise pre-message write s");
|
||||
console.debug("noise pre-message write s");
|
||||
|
||||
// If writing, it means that the user is sending a public key,
|
||||
// We check that the public part corresponds to the set local key and we call MixHash(s.public_key).
|
||||
@ -345,7 +345,7 @@ export class HandshakeState {
|
||||
case NoiseTokens.e:
|
||||
// If user is reading the "s" token
|
||||
if (reading) {
|
||||
console.trace("noise read e");
|
||||
console.debug("noise read e");
|
||||
|
||||
// We expect an ephemeral key, so we attempt to read it (next PK to process will always be at index 0 of preMessagePKs)
|
||||
if (inHandshakeMessage.length > 0) {
|
||||
@ -384,7 +384,7 @@ export class HandshakeState {
|
||||
|
||||
// If user is writing the "e" token
|
||||
} else if (writing) {
|
||||
console.trace("noise write e");
|
||||
console.debug("noise write e");
|
||||
|
||||
// We generate a new ephemeral keypair
|
||||
this.e = generateX25519KeyPair();
|
||||
@ -408,7 +408,7 @@ export class HandshakeState {
|
||||
case NoiseTokens.s:
|
||||
// If user is reading the "s" token
|
||||
if (reading) {
|
||||
console.trace("noise read s");
|
||||
console.debug("noise read s");
|
||||
|
||||
// We expect a static key, so we attempt to read it (next PK to process will always be at index 0 of preMessagePKs)
|
||||
if (inHandshakeMessage.length > 0) {
|
||||
@ -436,7 +436,7 @@ export class HandshakeState {
|
||||
|
||||
// If user is writing the "s" token
|
||||
} else if (writing) {
|
||||
console.trace("noise write s");
|
||||
console.debug("noise write s");
|
||||
|
||||
// If the local static key is not set (the handshake state was not properly initialized), we raise an error
|
||||
if (!this.s) {
|
||||
@ -462,7 +462,7 @@ export class HandshakeState {
|
||||
case NoiseTokens.psk:
|
||||
// If user is reading the "psk" token
|
||||
|
||||
console.trace("noise psk");
|
||||
console.debug("noise psk");
|
||||
|
||||
// Calls MixKeyAndHash(psk)
|
||||
this.ss.mixKeyAndHash(this.psk);
|
||||
@ -471,7 +471,7 @@ export class HandshakeState {
|
||||
case NoiseTokens.ee:
|
||||
// If user is reading the "ee" token
|
||||
|
||||
console.trace("noise dh ee");
|
||||
console.debug("noise dh ee");
|
||||
|
||||
// If local and/or remote ephemeral keys are not set, we raise an error
|
||||
if (!this.e || !this.re) {
|
||||
@ -485,7 +485,7 @@ export class HandshakeState {
|
||||
case NoiseTokens.es:
|
||||
// If user is reading the "es" token
|
||||
|
||||
console.trace("noise dh es");
|
||||
console.debug("noise dh es");
|
||||
|
||||
// We check if keys are correctly set.
|
||||
// If both present, we call MixKey(DH(e, rs)) if initiator, MixKey(DH(s, re)) if responder.
|
||||
@ -507,7 +507,7 @@ export class HandshakeState {
|
||||
case NoiseTokens.se:
|
||||
// If user is reading the "se" token
|
||||
|
||||
console.trace("noise dh se");
|
||||
console.debug("noise dh se");
|
||||
|
||||
// We check if keys are correctly set.
|
||||
// If both present, call MixKey(DH(s, re)) if initiator, MixKey(DH(e, rs)) if responder.
|
||||
@ -529,7 +529,7 @@ export class HandshakeState {
|
||||
case NoiseTokens.ss:
|
||||
// If user is reading the "ss" token
|
||||
|
||||
console.trace("noise dh ss");
|
||||
console.debug("noise dh ss");
|
||||
|
||||
// If local and/or remote static keys are not set, we raise an error
|
||||
if (!this.s || !this.rs) {
|
||||
|
||||
@ -83,7 +83,7 @@ export class CipherState {
|
||||
this.n.increment();
|
||||
this.n.assertValue();
|
||||
|
||||
console.trace("encryptWithAd", ciphertext, this.n.getUint64() - 1);
|
||||
console.debug("encryptWithAd", ciphertext, this.n.getUint64() - 1);
|
||||
} else {
|
||||
// Otherwise we return the input plaintext according to specification http://www.noiseprotocol.org/noise.html#the-cipherstate-object
|
||||
ciphertext = plaintext;
|
||||
@ -191,7 +191,7 @@ export class SymmetricState {
|
||||
// We update ck and the Cipher state's key k using the output of HDKF
|
||||
this.cs = new CipherState(tempK);
|
||||
this.ck = ck;
|
||||
console.trace("mixKey", this.ck, this.cs.k);
|
||||
console.debug("mixKey", this.ck, this.cs.k);
|
||||
}
|
||||
|
||||
// MixHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object
|
||||
@ -199,7 +199,7 @@ export class SymmetricState {
|
||||
mixHash(data: Uint8Array): void {
|
||||
// We hash the previous handshake hash and input data and store the result in the Symmetric State's handshake hash value
|
||||
this.h = hashSHA256(uint8ArrayConcat([this.h, data]));
|
||||
console.trace("mixHash", this.h);
|
||||
console.debug("mixHash", this.h);
|
||||
}
|
||||
|
||||
// mixKeyAndHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { bytes, uint64 } from "./@types/basic";
|
||||
import type { bytes, uint64 } from "./@types/basic.js";
|
||||
|
||||
export const MIN_NONCE = 0;
|
||||
// For performance reasons, the nonce is represented as a JS `number`
|
||||
|
||||
@ -5,11 +5,11 @@
|
||||
import { concat as uint8ArrayConcat } from "uint8arrays/concat";
|
||||
import { equals as uint8ArrayEquals } from "uint8arrays/equals";
|
||||
|
||||
import { MessageNametag } from "./@types/handshake";
|
||||
import { ChachaPolyTagLen, Curve25519KeySize, hashSHA256 } from "./crypto";
|
||||
import { PayloadV2ProtocolIDs } from "./patterns";
|
||||
import { NoisePublicKey } from "./publickey";
|
||||
import { readUIntLE, writeUIntLE } from "./utils";
|
||||
import { MessageNametag } from "./@types/handshake.js";
|
||||
import { ChachaPolyTagLen, Curve25519KeySize, hashSHA256 } from "./crypto.js";
|
||||
import { PayloadV2ProtocolIDs } from "./patterns.js";
|
||||
import { NoisePublicKey } from "./publickey.js";
|
||||
import { readUIntLE, writeUIntLE } from "./utils.js";
|
||||
|
||||
export const MessageNametagLength = 16;
|
||||
export const MessageNametagBufferSize = 50;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { concat as uint8ArrayConcat } from "uint8arrays/concat";
|
||||
import { equals as uint8ArrayEquals } from "uint8arrays/equals";
|
||||
|
||||
import { bytes32 } from "./@types/basic";
|
||||
import { chaCha20Poly1305Decrypt, chaCha20Poly1305Encrypt } from "./crypto";
|
||||
import { isEmptyKey } from "./noise";
|
||||
import { bytes32 } from "./@types/basic.js";
|
||||
import { chaCha20Poly1305Decrypt, chaCha20Poly1305Encrypt } from "./crypto.js";
|
||||
import { isEmptyKey } from "./noise.js";
|
||||
|
||||
// A ChaChaPoly Cipher State containing key (k), nonce (nonce) and associated data (ad)
|
||||
export class ChaChaPolyCipherState {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user